# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
IP:10.1.1.19
二、安装docker
1.yum安装
# yum -y install epel-release
# yum -y install docker
三、安装后设置
# systemctl daemon-reload
# systemctl start docker
启动报错内核问题
(Error starting daemon: SELinux is not supported with the overlay2 graph driver on this kernel. Either boot into a newer kernel or disable selinux in docker (--selinux-enabled=false)
# systemctl status docker
# systemctl enable docker
# docker info
# docker version
三、命令行依次起如下容器
# docker run --name mysql-svr -t \
--restart always \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix_pwd" \
-e MYSQL_ROOT_PASSWORD="root_pwd" \
-d mysql:5.7 \
--character-set-server=utf8 --collation-server=utf8_bin
【 docker run --name mysql-svr -t --restart always -e MYSQL_DATABASE="zabbix" -e MYSQL_USER="zabbix" -e MYSQL_PASSWORD="zabbixpasswd" -e MYSQL_ROOT_PASSWORD="123456" -d mysql:5.7 --character-set-server=utf8 --collation-server=utf8_bin】
# docker run --name zabbix-java-gateway -t \
-d zabbix/zabbix-java-gateway:latest
#【docker run --name zabbix-java-gateway -t -d zabbix/zabbix-java-gateway:latest】
# docker run --name zabbix-server-mysql -t \
-e DB_SERVER_HOST="mysql-server" \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix_pwd" \
-e MYSQL_ROOT_PASSWORD="root_pwd" \
-e ZBX_JAVAGATEWAY="zabbix-java-gateway" \
--link mysql-server:mysql \
--link zabbix-java-gateway:zabbix-java-gateway \
-p 10051:10051 \
-d zabbix/zabbix-server-mysql:latest
【docker run --name zabbix-server-mysql -t --restart always -e DB_SERVER_HOST="mysql-svr" -e MYSQL_DATABASE="zabbix" -e MYSQL_USER="zabbix" -e MYSQL_PASSWORD="zabbixpasswd" -e MYSQL_ROOT_PASSWORD="123456" -e ZBX_JAVAGATEWAY="zabbix-java-gateway" --link mysql-svr:mysql --link zabbix-java-gateway:zabbix-java-gateway -p 10051:10051 -d zabbix/zabbix-svr-mysql:latest 】
(报错iptables: No chain/target/match by that name. 解决:systemctl restart docker)
# docker run --name zabbix-agent -t \
-e ZBX_HOSTNAME="zabbix-agent" \
-e ZBX_SERVER_HOST="zabbix-server-mysql" \
--link zabbix-server-mysql:zabbix-server \
-p 10050:10050 \
-d zabbix/zabbix-agent:latest
# docker run --name zabbix-web-nginx-mysql -t \
-e DB_SERVER_HOST="mysql-server" \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix_pwd" \
-e MYSQL_ROOT_PASSWORD="root_pwd" \
--link mysql-server:mysql \
--link zabbix-server-mysql:zabbix-server \
-p 80:80 \
-d zabbix/zabbix-web-nginx-mysql:latest
我们也可以现在一个shell里,执行脚本起如上五个容器:
如果要设置docker启动,容器启动,可在每个容器的启动参数里添加--restart always
四、查看所起容器状态和端口监听
# dokcer ps -a
# ss -tan
五、登录web,enable本机监控
http://10.1.1.19/index.php
Admin/zabbix
注意:
此处IP 不能为 127.0.0.1,应该为zabbix-agent 的容器IP
# docker ps -a
# docker exec -it $(docker ps -a | grep "zabbix-agent" | awk '{print $1}') "ifconfig"
测试中几个有用的命令:
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker exec -it $(docker ps -a | grep "zabbix-agent" | awk '{print $1}') "ifconfig"
六、参考
Zabbix Documentation 3.2
https://www.zabbix.com/documentation/3.2/manual/installation/containers
zabbix/zabbix-agent
https://hub.docker.com/r/zabbix/zabbix-agent
作者:MissHandsome
链接:https://www.jianshu.com/p/b2d44c733c2d
来源:
著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。