利用zabbix搭建分布式监控(2)

结合nginx搭建zabbix监控:

实验环境:server3:  172.25.38.3  agent端  企业6
     loaclhost: 172.25.38.11      企业7
     server2:   172.25.38.2  proxy端  企业6
     最后的代理实验就是agent-->proxy-->localhost

在企业6版本的server3,:
关于企业6企业7版本虚拟机的封装可以查看https://blog.csdn.net/aaaaaab_/article/details/81712766

[root@server3 ~]# ls
mysql-proxy-0.8.5-linux-el6-x86-64bit.tar.gz
zabbix-agent-3.4.6-1.el6.x86_64.rpm
[root@server3 ~]# ls
mysql-proxy-0.8.5-linux-el6-x86-64bit.tar.gz
nginx-1.8.0-1.el6.ngx.x86_64.rpm
zabbix-agent-3.4.6-1.el6.x86_64.rpm
[root@server3 ~]# rpm -ivh nginx-1.8.0-1.el6.ngx.x86_64.rpm   安装nginx
warning: nginx-1.8.0-1.el6.ngx.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY
Preparing...                ########################################### [100%]
   1:nginx                  ########################################### [100%]
----------------------------------------------------------------------

Thanks for using nginx!

Please find the official documentation for nginx here:
* http://nginx.org/en/docs/

Commercial subscriptions for nginx are available on:
* http://nginx.com/products/

----------------------------------------------------------------------

这里写图片描述

[root@server3 ~]# pwd
/root
[root@server3 ~]# ls
mysql-proxy-0.8.5-linux-el6-x86-64bit.tar.gz
nginx-1.8.0-1.el6.ngx.x86_64.rpm
zabbix-agent-3.4.6-1.el6.x86_64.rpm
[root@server3 ~]# cd /etc/nginx/
[root@server3 nginx]# ls
conf.d          koi-utf  mime.types  scgi_params   win-utf
fastcgi_params  koi-win  nginx.conf  uwsgi_params
[root@server3 nginx]# cd conf.d/
[root@server3 conf.d]# ls
default.conf  example_ssl.conf
[root@server3 conf.d]# cd ..
[root@server3 nginx]# cd -
/etc/nginx/conf.d
[root@server3 conf.d]# ls
default.conf  example_ssl.conf
[root@server3 conf.d]# vim default.conf   加入一个location

这里写图片描述
这里写图片描述

[root@server3 conf.d]# nginx -t  检测nginx语法
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@server3 conf.d]# nginx 启动nginx
[root@server3 conf.d]# nginx -s reload 重载服务

这里写图片描述
在网页测试可以查看到状态:
这里写图片描述
添加访问黑白名单,为了安全性:

[root@server3 conf.d]# vim default.conf   加入允许访问的主机,拒绝所有,即只有127.0.0.1可以访问
[root@server3 conf.d]# nginx -s reload   重载服务生效

这里写图片描述
用其他主机(企业7版本的localhost主机)测试无法访问:

[root@localhost ~]# curl -s http://172.25.38.3/status
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.8.0</center>
</body>
</html>
[root@localhost ~]# 

这里写图片描述
用server3访问测试黑白名单:

[root@server3 conf.d]# curl -s http://127.0.0.1/status  127.0.0.1可以访问
Active connections: 1 
server accepts handled requests
 327 327 338 
Reading: 0 Writing: 1 Waiting: 0 
[root@server3 conf.d]# curl -s http://172.25.38.3/status   本机IP都无法调用访问
<html> 
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.8.0</center>
</body>
</html>

这里写图片描述
利用正则表达式取出各个状态值:

[root@server3 conf.d]# curl -s http://127.0.0.1/status | grep Active | awk '{print $3}' 过滤active行打印第三列
1
[root@server3 conf.d]# curl -s http://127.0.0.1/status | grep Active | awk '{print $NF}'  NF也代表最后一列效果相同
1
[root@server3 conf.d]# cd /etc/zabbix/
[root@server3 zabbix]# ls
zabbix_agentd.conf  zabbix_agentd.d
[root@server3 zabbix]# cd zabbix_agentd.d/
[root@server3 zabbix_agentd.d]# ls
userparameter_mysql.conf
[root@server3 zabbix_agentd.d]# cp userparameter_mysql.conf userparameter_nginx.conf 
[root@server3 zabbix_agentd.d]# vim userparameter_nginx.conf 
[root@server3 zabbix_agentd.d]# cat userparameter_nginx.conf 
UserParameter=nginx.active,curl -s http://127.0.0.1/status | grep Active | awk '{print $3}'
[root@server3 zabbix_agentd.d]# /etc/init.d/zabbix-agent restart
Shutting down Zabbix agent:                                [FAILED]
Starting Zabbix agent:                                     [  OK  ]
[root@server3 zabbix_agentd.d]# /etc/init.d/zabbix-agent restart   重启服务
Shutting down Zabbix agent:                                [  OK  ]
Starting Zabbix agent:                                     [  OK  ]

这里写图片描述
同理取出其他状态值进行绘制监控图形:

[root@server3 zabbix_agentd.d]# curl -s http://127.0.0.1/status |awk NR==3 | awk '{print $2}'
24    取出NR=3代表第三行,$2代表第二列
[root@server3 zabbix_agentd.d]# curl -s http://127.0.0.1/status |awk NR==3 | awk '{print $3}'
35
[root@server3 zabbix_agentd.d]# curl -s http://127.0.0.1/status |awk NR==3 | awk '{print $1}'
26
[root@server3 zabbix_agentd.d]# ls
userparameter_mysql.conf  userparameter_nginx.conf
[root@server3 zabbix_agentd.d]# vim userparameter_nginx.conf 
[root@server3 zabbix_agentd.d]# /etc/init.d/zabbix-agent restart
Shutting down Zabbix agent:                                [  OK  ]
Starting Zabbix agent:                                     [  OK  ]
[root@server3 zabbix_agentd.d]# cat userparameter_nginx.conf    添加到配置文件,nginx.active这个是键值,得与监控图形中一一对应
UserParameter=nginx.active,curl -s http://127.0.0.1/status | grep Active | awk '{print $3}'
UserParameter=nginx1.active,curl -s http://127.0.0.1/status |awk NR==3 | awk '{print $1}'
UserParameter=nginx2.active,curl -s http://127.0.0.1/status |awk NR==3 | awk '{print $2}'
UserParameter=nginx3.active,curl -s http://127.0.0.1/status |awk NR==3 | awk '{print $3}'

这里写图片描述
在企业7版本虚拟机开启服务:

[root@localhost ~]# systemctl start mariadb   开启数据库
[root@localhost ~]# systemctl enable mariadb   开机自动启动可以防止我们掉电启动之后出现服务忘记开启的情况
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@localhost ~]# systemctl start zabbix-server  开启zabbix-server
\[root@localhost ~]# systemctl enable zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
[root@localhost ~]# zabbix_get -s 172.25.38.3 -p 10050 -k 'nginx.active'  可以获取到servr3的状态值
1
[root@localhost ~]# systemctl start httpd  开启阿帕其
[root@localhost ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# zabbix_get -s 172.25.38.3 -p 10050 -k 'nginx1.active'
72
[root@localhost ~]# zabbix_get -s 172.25.38.3 -p 10050 -k 'nginx2.active'
73
[root@localhost ~]# zabbix_get -s 172.25.38.3 -p 10050 -k 'nginx3.active'
84

这里写图片描述
在网页添加监控项添加图形:
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
结合percona进行zabbix的监控:

Percona Server为 MySQL 数据库服务器进行了改进,在功能和性能上较 MySQL 有着很显著的提升。
该版本提升了在高负载情况下的 InnoDB 的性能、为 DBA 提供一些非常有用的性能诊断工具;另外有
更多的参数和命令来控制服务器行为。

实验部署:

[root@localhost ~]# rpm -ivh percona-zabbix-templates-1.1.8-1.noarch.rpm  安装percona-zabbix安装包
[root@localhost ~]# cd /var/lib/zabbix/percona/templates/
[root@localhost templates]# ls
userparameter_percona_mysql.conf
zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.8.xml
[root@localhost templates]# cp userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/
[root@localhost templates]# cd /etc/zabbix/zabbix_agentd.d/
[root@localhost zabbix_agentd.d]# ls
userparameter_mysql.conf  userparameter_percona_mysql.conf
[root@localhost zabbix_agentd.d]# systemctl restart zabbix-agent
[root@localhost zabbix_agentd.d]# ls
userparameter_mysql.conf  userparameter_percona_mysql.conf

这里写图片描述

[root@localhost zabbix_agentd.d]# cd -
/var/lib/zabbix/percona/templates
[root@localhost templates]# cd /var/lib/zabbix/
[root@localhost zabbix]# ls
percona
[root@localhost zabbix]# cd 
[root@localhost ~]# cd -
/var/lib/zabbix
[root@localhost zabbix]# cd percona/
[root@localhost percona]# ls
scripts  templates
[root@localhost percona]# cd scripts/
[root@localhost scripts]# ls
get_mysql_stats_wrapper.sh  ss_get_mysql_stats.php
[root@localhost scripts]# vim ss_get_mysql_stats.php 
[root@localhost scripts]# ls
get_mysql_stats_wrapper.sh  ss_get_mysql_stats.php
[root@localhost scripts]# vim /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php.cnf
[root@localhost scripts]# cat /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php.cnf
<?
$mysql_user = 'root';
$mysql_pass = 'westos'

这里写图片描述

[root@localhost scripts]# mysql -p  可以正常登陆数据库
MariaDB [(none)]> quit
Bye
[root@localhost scripts]# ls
get_mysql_stats_wrapper.sh  ss_get_mysql_stats.php  ss_get_mysql_stats.php.cnf
[root@localhost scripts]# cd /tmp/
[root@localhost tmp]# ls

这里写图片描述

[root@localhost ~]# vim ~zabbix/.my.cnf
[root@localhost ~]# cat ~zabbix/.my.cnf
[client]
user=root
password=westos
[root@localhost ~]# zabbix_get -s 127.0.0.1 -p 10050 -k 'MySQL.Threads-cached'

[root@localhost ~]# systemctl restart zabbix-agent  重启服务
[root@localhost ~]# netstat -antlp

这里写图片描述
在网页进行部署:
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
结合apache-tomcat部署zabbix监控:

[root@server3 ~]# ls
apache-tomcat-7.0.90.tar.gz                   nginx-1.8.0-1.el6.ngx.x86_64.rpm
jdk-8u121-linux-x64.rpm                       zabbix-agent-3.4.6-1.el6.x86_64.rpm
mysql-proxy-0.8.5-linux-el6-x86-64bit.tar.gz
[root@server3 ~]# rpm -ivh jdk-8u121-linux-x64.rpm 先安装jdk
[root@server3 ~]# tar zxf apache-tomcat-7.0.90.tar.gz -C /usr/local/ 
[root@server3 ~]# cd /usr/local/

这里写图片描述

[root@server3 local]# ls
apache-tomcat-7.0.90  etc    include  lib64    mysql-proxy  share
bin                   games  lib      libexec  sbin         src
[root@server3 local]# ln -s apache-tomcat-7.0.90/ tomcat  制作软链接
[root@server3 local]# cd
[root@server3 ~]# cd /usr/local/tomcat/
[root@server3 tomcat]# ls
bin           conf             lib      logs    README.md      RUNNING.txt  webapps
BUILDING.txt  CONTRIBUTING.md  LICENSE  NOTICE  RELEASE-NOTES  temp         work
[root@server3 tomcat]# bin/startup.sh   开启服务
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@server3 bin]# netstat -antlp |grep :8080  过滤8080端口
tcp        0      0 :::8080                     :::*                        LISTEN      11101/java          
tcp        0      0 ::ffff:127.0.0.1:8080       ::ffff:127.0.0.1:53405      TIME_WAIT   -   

这里写图片描述

[root@server3 tomcat]# cd bin/
[root@server3 bin]# ls
bootstrap.jar                 configtest.bat    setclasspath.sh  tomcat-native.tar.gz
catalina.bat                  configtest.sh     shutdown.bat     tool-wrapper.bat
catalina.sh                   daemon.sh         shutdown.sh      tool-wrapper.sh
catalina-tasks.xml            digest.bat        startup.bat      version.bat
commons-daemon.jar            digest.sh         startup.sh       version.sh
commons-daemon-native.tar.gz  setclasspath.bat  tomcat-juli.jar
[root@server3 bin]# vim catalina.sh 写入端口

这里写图片描述

[root@server3 bin]# vim catalina.sh 
[root@server3 bin]# ./shutdown.sh   先关闭服务
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@server3 bin]# ./startup.sh   打开服务
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@server3 bin]# netstat -antlp |grep :8888 可以看到8888
tcp        0      0 :::8888                     :::*                        LISTEN      12243/java          

这里写图片描述
在企业7的虚拟机进行配置:

[root@localhost ~]# ls
apache-tomcat-7.0.90.tar.gz                  zabbix-agent-3.4.6-1.el7.x86_64.rpm
fping-3.10-1.el7.x86_64.rpm                  zabbix-get-3.4.6-1.el7.x86_64.rpm
iksemel-1.4-2.el7.centos.x86_64.rpm          zabbix-java-gateway-3.4.6-1.el7.x86_64.rpm
jdk-8u121-linux-x64.rpm                      zabbix-proxy-mysql-3.4.6-1.el7.x86_64.rpm
percona-zabbix-templates-1.1.8-1.noarch.rpm  zabbix-server-mysql-3.4.6-1.el7.x86_64.rpm
php-bcmath-5.4.16-42.el7.x86_64.rpm          zabbix-web-3.4.6-1.el7.noarch.rpm
php-mbstring-5.4.16-42.el7.x86_64.rpm        zabbix-web-mysql-3.4.6-1.el7.noarch.rpm
[root@localhost ~]# rpm -ivh zabbix-java-gateway-3.4.6-1.el7.x86_64.rpm 
[root@localhost ~]# cd /etc/zabbix/
[root@localhost zabbix]# ls
web                 zabbix_java_gateway.conf         zabbix_server.conf
zabbix_agentd.conf  zabbix_java_gateway_logback.xml
zabbix_agentd.d     zabbix_proxy.conf
[root@localhost zabbix]# vim zabbix_java_gateway.conf 

这里写图片描述

[root@localhost zabbix]# systemctl start zabbix-java-gateway
[root@localhost zabbix]# netstat -antlp| grep :10052  可以看到10052端口
tcp6       0      0 :::10052                :::*                    LISTEN      6999/java           
[root@localhost zabbix]# ls
web                 zabbix_java_gateway.conf         zabbix_server.conf
zabbix_agentd.conf  zabbix_java_gateway_logback.xml
zabbix_agentd.d     zabbix_proxy.conf
[root@localhost zabbix]# vim zabbix_server.conf 
[root@localhost zabbix]# systemctl restart zabbix-server  重启服务

这里写图片描述
在网页进行部署:
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
部署onealert监控:
在真机添加策略:

[root@foundation38 Desktop]# iptables -t nat -I POSTROUTING -s 172.25.38.0/24 -j MASQUERADE

这里写图片描述
在企业7的主机进行配置:

[root@localhost zabbix]# ls
web                 zabbix_java_gateway.conf         zabbix_server.conf
zabbix_agentd.conf  zabbix_java_gateway_logback.xml
zabbix_agentd.d     zabbix_proxy.conf
[root@localhost zabbix]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.25.0.0      0.0.0.0         255.255.0.0     U     100    0        0 eth0
[root@localhost zabbix]# route add default gw 172.25.38.250  添加网关
[root@localhost zabbix]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.25.38.250   0.0.0.0         UG    0      0        0 eth0
172.25.0.0      0.0.0.0         255.255.0.0     U     100    0        0 eth0
[root@localhost zabbix]# vim /etc/resolv.conf  
[root@localhost zabbix]# cat /etc/resolv.conf 
nameserver 114.114.114.114
[root@localhost zabbix]# ping baidu.com  必须保证可以上网
PING baidu.com (220.181.57.216) 56(84) bytes of data.
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=1 ttl=48 time=119 ms
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=2 ttl=48 time=368 ms
^C
--- baidu.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 119.696/244.046/368.397/124.351 ms
[root@localhost zabbix]# 

这里写图片描述
在网页操作先开始注册oneAlert云告警平台并添加应用生成KEY:
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述

[root@localhost zabbix]# vim /etc/zabbix/zabbix_server.conf 
[root@localhost zabbix]# cd /usr/lib/zabbix/alertscripts/
[root@localhost alertscripts]# ls
oneitsm_zabbix_release-1.2.0.tar.gz
[root@localhost alertscripts]# tar zxf oneitsm_zabbix_release-1.2.0.tar.gz 
[root@localhost alertscripts]# ls
oneitsm  oneitsm_zabbix_release-1.2.0.tar.gz
[root@localhost alertscripts]# cd oneitsm
[root@localhost oneitsm]# ls
bin  logs  release  update
[root@localhost oneitsm]# cd bin/
[root@localhost bin]# ls
alert.sh  install.sh  log.sh  update.sh

这里写图片描述

[root@localhost bin]# ./install.sh  08619cba-b2f6-d2f9-cd25-ec20c34a9b86
./log.sh: line 6: /usr/lib/zabbix/alertscripts/oneitsm/bin/oneitsm.conf: No such file or directory
start to create config file...
Zabbix管理地址: 172.25.38.11/zabbix
Zabbix管理员账号: Admin
Zabbix管理员密码: westos就是登陆zabbix的密码
start to auth by zabbix admin user and password...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   195  100    70  100   125    764   1364 --:--:-- --:--:-- --:--:--  1373
auth success!
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   109  100    41  100    68    770   1277 --:--:-- --:--:-- --:--:--  1283
start to create mediatype...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   356  100    56  100   300    500   2682 --:--:-- --:--:-- --:--:--  2702
create media type success!
start to create user group...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   214  100    54  100   160    762   2259 --:--:-- --:--:-- --:--:--  2285
create user group success!
start to create user in zabbix...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   623  100    51  100   572    725   8134 --:--:-- --:--:-- --:--:--  8056
create user success!
start to create action...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2013  100    51  100  1962    351  13534 --:--:-- --:--:-- --:--:-- 13625
create action success!
安装成功:

这里写图片描述
在网页进行部署添加媒介:
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
在企业6主机停止zabbix-agent模拟报警:

[root@server3 bin]# /etc/init.d/zabbix-agent stop
Shutting down Zabbix agent:                                [  OK  ]
[root@server3 bin]# 

这里写图片描述
在网页查看会有报警信息:
这里写图片描述
这里写图片描述
这里写图片描述
会给你绑定的邮箱发消息:
这里写图片描述
在OneAlert会有待处理信息认领之后就会变成处理中:
这里写图片描述
这里写图片描述
server3再次打开服务:

[root@server3 bin]# /etc/init.d/zabbix-agent start
Starting Zabbix agent:                                     [  OK  ]
[root@server3 bin]# 

这里写图片描述
刷新ONeAlert会跑到已关闭邮件:
这里写图片描述
手机邮箱会出来信息显示已经处理:
这里写图片描述
进行监控项的更新:
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
配置企业6的虚拟机:

[root@server2 ~]# ls
zabbix-agent-3.4.6-1.el6.x86_64.rpm
[root@server2 ~]# rpm -ivh zabbix-agent-3.4.6-1.el6.x86_64.rpm 
[root@server2 ~]# cd /etc/zabbix/
[root@server2 zabbix]# ls
zabbix_agentd.conf  zabbix_agentd.d
[root@server2 zabbix]# hostname
server2
[root@server2 zabbix]# /etc/init.d/zabbix-agent start
Starting Zabbix agent:                                     [  OK  ]

这里写图片描述

[root@server2 zabbix]# cd /var/log/
[root@server2 log]# cd zabbix/
[root@server2 zabbix]# cat zabbix_agentd.log  查看日志
  1468:20180815:174702.736 Starting Zabbix Agent [server2]. Zabbix 3.4.6 (revision 76823).
  1468:20180815:174702.736 **** Enabled features ****
  1468:20180815:174702.736 IPv6 support:          YES
  1468:20180815:174702.736 TLS support:           YES
  1468:20180815:174702.736 **************************
  1468:20180815:174702.736 using configuration file: /etc/zabbix/zabbix_agentd.conf
  1468:20180815:174702.736 agent #0 started [main process]
  1470:20180815:174702.737 agent #2 started [active checks #1]
  1469:20180815:174702.739 agent #1 started [collector]
  1470:20180815:174705.739 active check configuration update from [172.25.38.11:10051] started to fail (ZBX_TCP_READ() timed out)
[root@server2 zabbix]# ls
zabbix_agentd.log
[root@server2 zabbix]# cd /etc/zabbix/
[root@server2 zabbix]# ls
zabbix_agentd.conf  zabbix_agentd.d
[root@server2 zabbix]# vim zabbix_agentd.conf 

这里写图片描述

[root@server2 zabbix]# vim zabbix_agentd.conf  文件更改内容

这里写图片描述
这里写图片描述
这里写图片描述

[root@server2 zabbix]# /etc/init.d/zabbix-agent restart 重载服务
[root@server2 zabbix]# netstat -antlp  查看端口会出来10050
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      906/sshd            
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      982/master          
tcp        0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      1537/zabbix_agentd  
tcp        0      0 172.25.38.2:44745           172.25.38.11:10051          ESTABLISHED 1542/zabbix_agentd  
tcp        0      0 172.25.38.2:22              172.25.38.250:42488         ESTABLISHED 1377/sshd           
tcp        0      0 :::22                       :::*                        LISTEN      906/sshd            
tcp        0      0 ::1:25                      :::*                        LISTEN      982/master          
tcp        0      0 :::10050                    :::*                        LISTEN      1537/zabbix_agentd  

这里写图片描述
进行agent的主被动配置:
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
进行proxy代理:

[root@server2 ~]# ls
fping-2.4b2-16.el6.x86_64.rpm
zabbix-agent-3.4.6-1.el6.x86_64.rpm
zabbix-proxy-mysql-3.4.6-1.el6.x86_64.rpm
[root@server2 ~]# yum install zabbix-proxy-mysql-3.4.6-1.el6.x86_64.rpm fping-2.4b2-16.el6.x86_64.rpm -y

这里写图片描述

[root@server2 ~]# yum install mysql-server -y  安装数据库
[root@server2 ~]# /etc/init.d/mysqld start  开启服务
[root@server2 ~]# cd /etc/zabbix/
[root@server2 zabbix]# ls
zabbix_agentd.conf  zabbix_agentd.d  zabbix_proxy.conf
[root@server2 zabbix]# vim zabbix_proxy.conf 
24 Server=172.25.38.11
43 Hostname=server2
190 DBPassword=westos
197 DBSocket=/var/lib/mysql/mysql.sock

这里写图片描述
这里写图片描述

[root@server2 zabbix]# mysql
mysql> create database zabbix_proxy character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on zabbix_proxy.* to zabbix@localhost identified by 'westos'; 授权
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[root@server2 zabbix]# cd /usr/share/doc/
[root@server2 doc]# cd zabbix-proxy-mysql-3.4.6/
[root@server2 zabbix-proxy-mysql-3.4.6]# ls
AUTHORS  ChangeLog  COPYING  NEWS  README  schema.sql.gz
[root@server2 zabbix-proxy-mysql-3.4.6]# zcat schema.sql.gz | mysql -u zabbix -p zabbix_proxy
Enter password: westos

这里写图片描述
在网页进行配置:
这里写图片描述
这里写图片描述
这里写图片描述
在agent端:

[root@server3 ~]# vim /etc/zabbix/zabbix_agentd.conf
97 Server=172.25.38.2
......
138 ServerActive=172.25.38.2
[root@server3 ~]# /etc/init.d/zabbix-agent restart
Shutting down Zabbix agent:                                [  OK  ]
Starting Zabbix agent:                                     [  OK  ]
[root@server3 ~]# 

在网页可以看到有代理:
这里写图片描述

猜你喜欢

转载自blog.csdn.net/aaaaaab_/article/details/81668724