Docker 安装zabbix 5

我自横刀向天笑,去留肝胆两昆仑。这篇文章主要讲述Docker 安装zabbix 5相关的知识,希望能为你提供帮助。
安装docker

yum -y install gcc
yum -y install gcc-c++
yum install -y yum-utils
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum install docker-ce docker-ce-cli containerd.io
systemctl start docker
systemctl enable docker
mkdir -p /etc/docker
tee /etc/docker/daemon.json < < -EOF

"registry-mirrors": ["https://c6tg5yoo.mirror.aliyuncs.com"]

EOF
systemctl daemon-reload
systemctl restart docker
groupadd docker
usermod -aG docker $USER
newgrp docker

下载镜像
systemctl stop firewalld
systemctl disable firewalld
docker pull mysql:5.7
docker pull zabbix/zabbix-java-gateway:latest
docker pull zabbix/zabbix-server-mysql:centos-latest
docker pull zabbix/zabbix-web-nginx-mysql:latest
docker pull zabbix/zabbix-agent:latest
docker network create --subnet 192.168.0.0/24 -d bridge zabbix_network

部署zabbix-mysql
docker run --name zabbix-mysql -t \\
--network zabbix_network --ip 192.168.0.2 \\
-v /usr/local/docker/mysql/conf:/etc/mysql \\
-v /usr/local/docker/mysql/logs:/var/log/mysql \\
-v /usr/local/docker/mysql/data:/var/lib/mysql \\
-v /etc/localtime:/etc/localtime \\
-e MYSQL_DATABASE="zabbix" \\
-e MYSQL_USER="zabbix" \\
-e MYSQL_PASSWORD="123456" \\
-e MYSQL_ROOT_PASSWORD="123456" \\
--restart=always \\
-d mysql:5.7 \\
--character-set-server=utf8 --collation-server=utf8_bin

部署zabbix-java-gateway
docker run --name zabbix-java-gateway -t \\
--network zabbix_network --ip 192.168.0.5 \\
-v /etc/localtime:/etc/localtime \\
--restart=always \\
-d zabbix/zabbix-java-gateway:latest

部署zabbix-server-mysql
docker run --name zabbix-server-mysql -t \\
--network zabbix_network --ip 192.168.0.6 \\
-p 10051:10051 \\
-e DB_SERVER_HOST="zabbix-mysql" \\
-e MYSQL_DATABASE="zabbix" \\
-e MYSQL_USER="zabbix" \\
-e MYSQL_PASSWORD="123456" \\
-e MYSQL_ROOT_PASSWORD="123456" \\
-e ZBX_JAVAGATEWAY="zabbix-java-gateway" \\
-v /home/docker/server/zabbix/server/zabbix_server.conf:/etc/zabbix/zabbix_server.conf \\
-v /home/docker/server/zabbix/server/alertscripts:/usr/lib/zabbix/alertscripts \\
-v /home/docker/server/zabbix/server/externalscripts:/usr/lib/zabbix/externalscripts \\
-v /home/docker/server/zabbix/server/modules:/var/lib/zabbix/modules \\
-v /home/docker/server/zabbix/server/enc:/var/lib/zabbix/enc \\
-v /home/docker/server/zabbix/server/ssh_keys:/var/lib/zabbix/ssh_keys \\
-v /home/docker/server/zabbix/server/ssl/certs:/var/lib/zabbix/ssl/certs \\
-v /home/docker/server/zabbix/server/ssl/keys:/var/lib/zabbix/ssl/keys \\
-v /home/docker/server/zabbix/server/ssl/ssl_ca:/var/lib/zabbix/ssl/ssl_ca \\
-v /home/docker/server/zabbix/server/snmptraps:/var/lib/zabbix/snmptraps \\
-v /home/docker/server/zabbix/server/mibs:/var/lib/zabbix/mibs \\
--mount source=zabbix-server-vol,target=/etc/zabbix \\
--restart=always \\
-d zabbix/zabbix-server-mysql:centos-latest

部署zabbix-web-nginx-mysql
docker run --name zabbix-web-nginx-mysql -t \\
--network zabbix_network --ip 192.168.0.3 \\
-v /home/docker/server/zabbix/zabbix-web:/usr/share/zabbix \\
-v /etc/localtime:/etc/localtime \\
-e DB_SERVER_HOST="zabbix-mysql" \\
-e MYSQL_DATABASE="zabbix" \\
-e MYSQL_USER="zabbix" \\
-e MYSQL_PASSWORD="123456" \\
-e MYSQL_ROOT_PASSWORD="123456" \\
-e php_TZ="Asia/Shanghai" \\
-e ZBX_SERVER_HOST="zabbix-server-mysql" \\
-p 8888:8080 \\
--restart=always \\
-d zabbix/zabbix-web-nginx-mysql:latest

部署zabbix-agent
docker run --name zabbix-agent -t \\
--network zabbix_network --ip 192.168.0.4 \\
--link zabbix-server-mysql \\
-v /home/docker/server/zabbix/zabbix-agent/zabbix_agentd.conf:/etc/zabbix/zabbix_agentd.conf \\
-v /etc/localtime:/etc/localtime \\
-e ZBX_HOSTNAME="zabbix-server-mysql" \\
-e ZBX_SERVER_HOST="zabbix-server-mysql" \\
-e ZBX_SERVER_PORT=10051 \\
-p 10050:10050 \\
--restart=always \\
--privileged \\
-d zabbix/zabbix-agent:latest

添加字体
docker cp /tmp/msyh.ttc zabbix-web-nginx-mysql:/usr/share/zabbix/assets/fonts/
docker exec -it -u root zabbix-web-nginx-mysql /bin/bash
cd /usr/share/zabbix/assets/fonts/
mv DejaVuSans.ttf DejaVuSans.ttf_bak
ln -s msyh.ttc DejaVuSans.ttf

登录管理控制台
http://宿主机ip:8888
打开配置-主机,接口那的ip为127.0.0.1,这个IP是宿主机的IP,修改为 zabbix-agent 容器的IP。

























【Docker 安装zabbix 5】


    推荐阅读