Centos7.5yum搭建zabbix4.0

Centos7.5搭建zabbix4.0
系统环境:centos7.5 64bit
执行命令

环境准备

Centos7.5-1  ipaddress:192.168.200.101  hostname:zabbix-server
Centos7.5-2  ipaddress:192.168.200.102	  hostname:zabbix-client

Centos7.5-1操作

[root@localhost ~]# ifconfig ens33
ens33: flags=4163  mtu 1500
        inet 192.168.200.101  netmask 255.255.255.0  broadcast 192.168.200.255
        inet6 fe80::20c:29ff:fe4a:b550  prefixlen 64  scopeid 0x20
        ether 00:0c:29:4a:b5:50  txqueuelen 1000  (Ethernet)
        RX packets 32245  bytes 47336754 (45.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 7602  bytes 713708 (696.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost ~]# nslookup www.baidu.com
Server:		202.106.0.20
Address:	202.106.0.20#53

Non-authoritative answer:
www.baidu.com	canonical name = www.a.shifen.com.
Name:	www.a.shifen.com
Address: 119.75.217.109
Name:	www.a.shifen.com
Address: 119.75.217.26

[root@localhost ~]# vim /etc/hostname 
[root@localhost ~]# cat /etc/hostname
zabbix-server
[root@localhost ~]# hostname $(cat /etc/hostname)
[root@localhost ~]# bash
[root@zabbix-server ~]# systemctl stop firewalld
[root@zabbix-server ~]# setenforce 0
setenforce: SELinux is disabled
[root@zabbix-server ~]# ll /etc/yum.repos.d/
总用量 32
drwxr-xr-x. 2 root root   162 10月 24 09:46 bak
-rw-r--r--. 1 root root  2523 6月  16 06:22 Centos-7.repo
-rw-r--r--. 1 root root   630 10月 24 09:46 CentOS-Media.repo
-rw-r--r--. 1 root root 15080 10月  3 2017 epel-release-latest-7.noarch.rpm
-rw-r--r--. 1 root root   951 10月  3 2017 epel.repo
-rw-r--r--. 1 root root  1050 10月  3 2017 epel-testing.repo
Centos7.5-2
[root@localhost ~]# ifconfig ens33
ens33: flags=4163  mtu 1500
        inet 192.168.200.102  netmask 255.255.255.0  broadcast 192.168.200.255
        inet6 fe80::20c:29ff:fe3a:182d  prefixlen 64  scopeid 0x20
        ether 00:0c:29:3a:18:2d  txqueuelen 1000  (Ethernet)
        RX packets 86  bytes 11959 (11.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 144  bytes 16392 (16.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost ~]# nslookup www.baidu.com
Server:		202.106.0.20
Address:	202.106.0.20#53

Non-authoritative answer:
www.baidu.com	canonical name = www.a.shifen.com.
Name:	www.a.shifen.com
Address: 119.75.217.109
Name:	www.a.shifen.com
Address: 119.75.217.26

[root@localhost ~]# vim /etc/hostname
[root@localhost ~]# cat /etc/hostname
zabbix-client
[root@localhost ~]# hostname $(cat /etc/hostname)
[root@localhost ~]# bash
[root@zabbix-server ~]# systemctl stop firewalld
[root@zabbix-server ~]# setenforce 0
setenforce: SELinux is disabled

构建lamp环境

[root@zabbix-server ~]# yum install -y httpd mariadb-server mariadb php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mhash php-mbstring php-bcmath

配置mariadb

[root@zabbix-server ~]# systemctl start mariadb
[root@zabbix-server ~]# mysqladmin -u root password 123123
[root@zabbix-server ~]# mysql -u root -p123123
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> \q
Bye

配置php时区

[root@zabbix-server~]# vim /etc/php.ini
384 max_execution_time = 300
394 max_input_time = 300
672 post_max_size = 16M
878 date.timezone = Asia/Shanghai
修改apache配置文件添加php
[root@zabbix-server ~]# vim /etc/httpd/conf/httpd.conf
164     DirectoryIndex index.html index.php
创建网站目录(index.php)
[root@zabbix-server ~]# vim /var/www/html/index.php
 [root@zabbix-server ~]# cat /var/www/html/index.php
 
[root@zabbix-server ~]# systemctl start httpd
浏览器访问测试php
 
部署zabbix4.0
配置mariadb
[root@zabbix-server ~]# mysql -u root -p123123
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'%' identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> \q
Bye

准备zabbix的yum源

[root@zabbix-server ~]# wget http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
[root@zabbix-server ~]# ll
总用量 24
-rw-------. 1 root root  1716 10月 23 23:55 anaconda-ks.cfg
-rw-r--r--. 1 root root  1747 10月 24 00:15 initial-setup-ks.cfg
-rw-r--r--  1 root root 13648 1月   9 2018 zabbix-release-3.5-1.el7.noarch.rpm
drwxr-xr-x. 2 root root     6 10月 24 00:19 公共
drwxr-xr-x. 2 root root     6 10月 24 00:19 模板
drwxr-xr-x. 2 root root     6 10月 24 00:19 视频
drwxr-xr-x. 2 root root     6 10月 24 00:19 图片
drwxr-xr-x. 2 root root     6 10月 24 00:19 文档
drwxr-xr-x. 2 root root     6 10月 24 00:19 下载
drwxr-xr-x. 2 root root     6 10月 24 00:19 音乐
drwxr-xr-x. 2 root root     6 10月 24 00:19 桌面
[root@zabbix-server ~]# mv zabbix-release-3.5-1.el7.noarch.rpm /etc/yum.repos.d/
[root@zabbix-server ~]# rpm -ivh /etc/yum.repos.d/zabbix-release-3.5-1.el7.noarch.rpm 
[root@zabbix-server ~]# ll /etc/yum.repos.d/
总用量 52
drwxr-xr-x. 2 root root   162 10月 24 09:46 bak
-rw-r--r--. 1 root root  2523 6月  16 06:22 Centos-7.repo
-rw-r--r--. 1 root root   630 10月 24 09:46 CentOS-Media.repo
-rw-r--r--. 1 root root 15080 10月  3 2017 epel-release-latest-7.noarch.rpm
-rw-r--r--. 1 root root   951 10月  3 2017 epel.repo
-rw-r--r--. 1 root root  1050 10月  3 2017 epel-testing.repo
-rw-r--r--  1 root root 13648 1月   9 2018 zabbix-release-3.5-1.el7.noarch.rpm
-rw-r--r--  1 root root   410 12月 20 2017 zabbix.repo
[root@zabbix-server ~]# yum clean all&& yum makecache

安装zabbix

[root@zabbix-server ~]# yum install -y zabbix-server-mysql zabbix-web-mysql 
将zabbix需要的数据导入到mysql数据库中
[root@zabbix-server ~]# zcat /usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz | mysql -u zabbix -pzabbix zabbix
授权localhost的原因就是因为此处需要localhost权限
配置zabbix
[root@zabbix-server ~]# vim /etc/zabbix/zabbix_server.conf 
[root@zabbix-server ~]# egrep -v '^$|^#' /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix		//改这个就可以了125行
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
[root@zabbix-server ~]# cp -r /usr/share/zabbix/ /var/www/html/

启动zabbix访问安装

浏览器访问:http://192.168.200.101/zabbix
Centos7.5yum搭建zabbix4.0_第1张图片
修改了一下这个图是我从我第二个文档源码部署上截图下来的但是页面是一样的

Agent端配置

[root@zabbix-client ~]# cd /etc/yum.repos.d/
[root@zabbix-client yum.repos.d]# ll
总用量 48
drwxr-xr-x. 2 root root   162 10月 24 09:46 bak
-rw-r--r--. 1 root root  2523 6月  16 06:22 Centos-7.repo
-rw-r--r--. 1 root root   630 10月 24 09:46 CentOS-Media.repo
-rw-r--r--. 1 root root 15080 10月  3 2017 epel-release-latest-7.noarch.rpm
-rw-r--r--. 1 root root   951 10月  3 2017 epel.repo
-rw-r--r--. 1 root root  1050 10月  3 2017 epel-testing.repo
-rw-r--r--  1 root root 13648 1月   9 2018 zabbix-release-3.5-1.el7.noarch.rpm
[root@zabbix-client yum.repos.d]# wget http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
[root@zabbix-client yum.repos.d]# rpm -ivh zabbix-release-3.5-1.el7.noarch.rpm 
[root@zabbix-client yum.repos.d]# yum clean all
[root@zabbix-client yum.repos.d]# yum install -y zabbix-agent
配置zabbix并添加监控
[root@zabbix-client ~]# vim /etc/zabbix/zabbix_agentd.conf
98 Server=192.168.200.101
139 ServerActive=192.168.200.101
150 Hostname=zabbix_client
[root@zabbix-client ~]# egrep -v '^#|^$' /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.200.101
ServerActive=192.168.200.101
Hostname=zabbix_client
Include=/etc/zabbix/zabbix_agentd.d/*.conf
[root@zabbix-client ~]# systemctl start zabbix-agent
[root@zabbix-client ~]# netstat -antp | grep 10050
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      62152/zabbix_agentd 
tcp6       0      0 :::10050                :::                       LISTEN      62152/zabbix_agentd

基于LNMP源码部署zabbix4.0文档地址

https://blog.csdn.net/ma_mxr/article/details/86687118

你可能感兴趣的:(zabbix)