zabbix中文 文檔
https://www.zabbix.com/documentation/4.0/zh/manual/installation/containers
http://www.weadmin.com/download
1.安裝docker環境
yum -y install docker#安裝docker
vi /etc/docker/daemon.json#加速設置
改: {}
為:
{ "registry-mirrors": ["https://e9yneuy4.mirror.aliyuncs.com"] }
systemctl daemon-reload #加載文件 systemctl restart docker#重啟docker vi /etc/sysctl.conf #路由轉發不設置轉發ip可能會報錯 net.ipv4.ip_forward = 1 sysctl -p #生效
2.拉取鏡像
docker pull mysql:5.6.36 docker pull zabbix/zabbix-server-mysql docker pull zabbix/zabbix-web-nginx-mysql docker images
3鏡像部署
3.1 啟動mysql:5.6.36
docker run --name zabbix_mysql --hostname zabbix_mysql --restart=always -e MYSQL_ROOT_PASSWORD="123456" -e MYSQL_USER="zabbix" -e MYSQL_PASSWORD="123456" -e MYSQL_DATABASE="zabbix" -p 3306:3306 -v /home/docker/data/mysql:/var/lib/mysql -d mysql:5.6.36
3.2啟動zabbix_server
docker run --name zabbix_server --restart=always --link zabbix_mysql:mysql -e DB_SERVER_HOST="mysql" -e MYSQL_USER="zabbix" -e MYSQL_DATABASE="zabbix" -e MYSQL_PASSWORD="123456" -v /etc/localtime:/etc/localtime:ro -v /home/docker/data/zabbix:/usr/lib/zabbix -p 10051:10051 -d zabbix/zabbix-server-mysql
3.3 啟動zabbix_nginx_web
docker run --name zabbix_web --restart=always --link zabbix_mysql:mysql --link zabbix_server:zabbix_server -e DB_SERVER_HOST="mysql" -e MYSQL_USER="zabbix" -e MYSQL_PASSWORD="123456" -e MYSQL_DATABASE="zabbix" -e ZBX_SERVER_HOST="zabbix_server" -e PHP_TZ="Asia/Shanghai" -p 80:80 -p 8443:443 -d zabbix/zabbix-web-nginx-mysql
登錄信息
192.168.1.65/zabbix
admin,密碼:zabbix
4客戶端agent部署#注意客戶端不能用docker安裝因為那監控的是docker內的情況,zabbix server需要單獨配置agent ip用


rpm -i https://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm yum list yum install zabbix-agent -y #安裝zabbix 客戶端 zabbixserver端監控也需要重新配置agent ip用docker的ip cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf_ori.bak sed -i "s/Server=127.0.0.1/Server=192.168.1.65/" /etc/zabbix/zabbix_agentd.conf sed -i "s/ServerActive=127.0.0.1/ServerActive=192.168.1.65/" /etc/zabbix/zabbix_agentd.conf sed -i "s/Hostname=/Hostname=$hostname/" /etc/zabbix/zabbix_agentd.conf systemctl restart zabbix-agent #啟動失敗可能是hostname沒有配置好可以看日志 systemctl enable zabbix-agent
注意清空防火牆可能無法訪問
docker restart zabbix_web;docker restart zabbix_server;docker restart zabbix_mysql #重啟服務 sysctl -p systemctl restart docker#加載轉發重啟docker后正常
日志查看
docker logs zabbix_server
docker logs zabbix_agent
docker logs zabbix_web
docker logs zabbix_mysql
字符集替換 qq群共享有字體
因為DejaVuSans.ttf字體在圖表里不支持中文會顯示方塊
bash-4.4# find / -name "DejaVuSans.ttf"
/usr/share/fonts/ttf-dejavu/DejaVuSans.ttf
docker ps docker exec -it f665da46f7c0 /bin/bash #ngnix的docker mv /usr/share/fonts/ttf-dejavu/DejaVuSans.ttf /usr/share/fonts/ttf-dejavu/DejaVuSans.ttf.bak備份源文件 docker cp DejaVuSans-zabbix.ttf f665da46f7c0:/usr/share/fonts/ttf-dejavu/DejaVuSans.ttf
docker鏡像打包導出導入
docker commit f665da46f7c0 docker.io/zabbix/zabbix-web-nginx-mysql-zf#打包 docker save -o docker.io-centos-ngnix-image.tar docker.io/zabbix/zabbix-web-nginx-mysql-zf#導出 docker load < docker.io-centos-ngnix-image.tar#導入鏡像包
