docker部署zabbix
1、部署mysql
# docker run --name mysql-server -t \ -v /data/mysql/data:/var/lib/mysql \ -e MYSQL_DATABASE="zabbix" \ -e MYSQL_USER="zabbix" \ -e MYSQL_PASSWORD="123456" \ -e MYSQL_ROOT_PASSWORD="123456" \ --restart=unless-stopped \ -p 3306:3306 \ -d mysql:8.0 \ --character-set-server=utf8 --collation-server=utf8_bin \ --default-authentication-plugin=mysql_native_password
mysql数据持久化
2、部署zabbix-java-gateway
# docker run --name zabbix-java-gateway -t \ --restart=unless-stopped \ -d zabbix/zabbix-java-gateway
3、部署zabix服务端
# docker run --name zabbix-server-mysql -t \ -e DB_SERVER_HOST="192.168.4.11" \ -e MYSQL_DATABASE="zabbix" \ -e MYSQL_USER="zabbix" \ -e MYSQL_PASSWORD="123456" \ -e MYSQL_ROOT_PASSWORD="123456" \ -e ZBX_JAVAGATEWAY="zabbix-java-gateway" \
--link mysql-server:mysql \ --link zabbix-java-gateway:zabbix-java-gateway \ --restart=unless-stopped \ -p 10051:10051 \ -d zabbix/zabbix-server-mysql
--link参数,实现mysql和java-gateway容器间的互相通信
4、部署web界面
# docker run --name zabbix-web-nginx-mysql -t \ -e PHP_TZ="Asia/Shanghai" \ -e ZBX_SERVER_HOST="zabbix-server-mysql" \ -e DB_SERVER_HOST="192.168.4.11" \ -e MYSQL_DATABASE="zabbix" \ -e MYSQL_USER="zabbix" \ -e MYSQL_PASSWORD="123456" \ -e MYSQL_ROOT_PASSWORD="123456" \
--link mysql-server:mysql \ --link zabbix-server-mysql:zabbix-server \ -p 80:8080 \ --restart unless-stopped \ -d zabbix/zabbix-web-nginx-mysql
5、部署zabbix客户端
# docker run --name zabbix-agent -t \ -e ZBX_HOSTNAME="host-01" \ -e ZBX_SERVER_HOST="172.17.1.6" \ -e ZBX_SERVER_PORT=10051 \ -p 10050:10050 \ --restart=unless-stopped \ --privileged \ -d zabbix/zabbix-agent
若部署在zabbix服务端的agent,ZBX_SERVER_HOST是容器IP,不是主机IP
6、总结
问题:docker容器ping不通宿主机网关
方法1:升级内核 方法2:自定义网桥 # systemctl stop docker # ifconfig docker0 down # brctl delbr docker0 # brctl addbr docker0 # ip addr add 172.17.2.1/24 dev docker0 # ip link set dev docker0 up # vim /etc/docker/daemon.json {"bip":"172.17.1.1/24"}
# systemctl daemon-reload
# systemctl restart iptables
# systemctl restart docker
QQ:328864113 微信:wuhg2008