原 【DB宝39】使用Docker分分钟搭建Zabbix 5.0配置MySQL监控
Tags: 原创LinuxMySQLDocker监控其它Zabbix
一、部署Zabbix 5.0环境
1.1、下载Zabbix 5.0镜像
1 2 3 4 5 6 7 | [root@docker36 ~]# docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/lhrzabbix5:1.0 1.0: Pulling from lhrbest/lhrzabbix5 c1e1cb5fc6d2: Already exists f36cbc8bf71f: Pull complete Digest: sha256:5e22edb3347a27a731bd48742c982e34dcbcd47b63db2e9b64549ad69488475e Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/lhrbest/lhrzabbix5:1.0 registry.cn-hangzhou.aliyuncs.com/lhrbest/lhrzabbix5:1.0 |
1.2、创建镜像
1 2 3 4 5 6 7 8 9 10 11 12 | [root@docker36 ~]# docker run -d --name lhrzabbix5 -h lhrzabbix5 \ > -p 225:22 -p 23306:3306 -p 280:80 -p 20051:10051 \ > -v /sys/fs/cgroup:/sys/fs/cgroup \ > --privileged=true \ > lhrbest/lhrzabbix5:1.0 /usr/sbin/init Unable to find image 'lhrbest/lhrzabbix5:1.0' locally 1.0: Pulling from lhrbest/lhrzabbix5 Digest: sha256:5e22edb3347a27a731bd48742c982e34dcbcd47b63db2e9b64549ad69488475e Status: Downloaded newer image for lhrbest/lhrzabbix5:1.0 7fa309da58043680aa0fa14b0692b35249ad5557d5d4cf0d0897a29afad13256 [root@docker36 ~]# docker exec -it lhrzabbix5 bash [root@lhrzabbix5 /]# |
1.3、浏览器访问
访问Zabbix:http://192.168.66.36:280/zabbix
默认用户名密码:Admin/zabbix
二、监控Linux主机
监控Linux主机可以通过snmp(Simple Network Management Protocol)简单网络管理协议,也可以通过zabbix-agent监控。本文使用snmp来配置。
1 2 3 4 5 | yum install -y net-snmp net-snmp-utils systemctl start snmpd systemctl status snmpd systemctl enable snmpd |
配置文件:vi /etc/snmp/snmpd.conf,添加如下内容:
1 | view systemview included .1 |
启动snmpd:
1 2 3 4 5 6 7 8 9 10 11 12 13 | [root@lhrzabbix5 ~]# systemctl status snmpd ● snmpd.service - Simple Network Management Protocol (SNMP) Daemon. Loaded: loaded (/usr/lib/systemd/system/snmpd.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2021-01-13 16:37:24 CST; 39s ago Main PID: 81937 (snmpd) CGroup: /system.slice/snmpd.service └─81937 /usr/sbin/snmpd -LS0-6d -f Jan 13 16:37:24 docker36 systemd[1]: Starting Simple Network Management Protocol (SNMP) Daemon.... Jan 13 16:37:24 docker36 snmpd[81937]: NET-SNMP version 5.7.2 Jan 13 16:37:24 docker36 systemd[1]: Started Simple Network Management Protocol (SNMP) Daemon.. [root@docker36 ~]# netstat -anp | grep 161 udp 0 0 0.0.0.0:161 0.0.0.0:* 81937/snmpd |
在zabbix server上测试:
1 2 | nc -zvu localhost 161 snmpwalk -v 2c -c public localhost | wc -l |
结果:
1 2 3 4 5 6 7 | [root@lhrzabbix5 /]# nc -zvu localhost 161 Ncat: Version 7.50 ( https://nmap.org/ncat ) Ncat: Connected to 127.0.0.1:161. Ncat: UDP packet sent successfully Ncat: 1 bytes sent, 0 bytes received in 2.02 seconds. [root@lhrzabbix5 /]# snmpwalk -v 2c -c public localhost | wc -l 7086 |
此时需要在server端配置:
配置——主机——创建主机——移除interface的客户端——添加SNMP客户端
——填写主机名称、可见名称、群组、IP地址,如图所示:
点击添加,然后等待1分钟,等待图标变成绿色即正常,如图所示: