docker 之zabbix监控-安装部署完整版-

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#导入镜像包

 

posted @ 2018-10-19 15:53  夜辰雪扬  阅读(...)  评论(...编辑  收藏