docker 部署 zabbix5.0LTS - 知乎 (zhihu.com)
docker 安装 (centos)yum版 : 连接
1- 创建网络
docker network create --subnet 172.20.0.0/16 --ip-range 172.20.240.0/20 zabbix-net
2- mysql:
先建一个配置文件:
mkdir -p /mydata/mysql/conf
cd /mydata/mysql/conf
vi my.cnf
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
cat 1zbx5-mysql.sh
#!/bin/bash
docker run --name zbx5-mysql -d \
--network=zabbix-net \
-p 3306:3306 \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf/my.cnf:/etc/my.cnf \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix" \
-e MYSQL_ROOT_PASSWORD="root" \
--restart unless-stopped mysql:5.7 \
--character-set-server=utf8 --collation-server=utf8_bin \
--default-authentication-plugin=mysql_native_password
注意这里 -p 可以不用带
3- zabbix 服务端
cat 2zbx5-server-mysql.sh
#!/bin/bash
docker run --name zbx5-server-mysql -d \
--network=zabbix-net \
-p 10051:10051 \
-e DB_SERVER_HOST="zbx5-mysql" \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix" \
-e MYSQL_ROOT_PASSWORD="root" \
--restart unless-stopped \
zabbix/zabbix-server-mysql:5.0-centos-latest
4- zabbix 前端
cat 3zbx5-web-nginx-mysql.s
#!/bin/bash
docker run --name zbx5-web-nginx-mysql -d \
--network=zabbix-net \
-p 8080:8080 \
-e ZBX_SERVER_HOST="zbx5-server-mysql" \
-e DB_SERVER_HOST="zbx5-mysql" \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix" \
-e MYSQL_ROOT_PASSWORD="root" \
--restart unless-stopped \
zabbix/zabbix-web-nginx-mysql:5.0-centos-latest
5- 可以访问了
http://10.0.0.206:8080
默认用户名/密码是:Admin/zabbix
6- zabbxi 客户端安装 (每个服务器都要安装)
cat 4zabx5-agent.sh
#!/bin/bash
docker run --name zbx5-agent -d \
-e ZBX_HOSTNAME="local-agent" \
-e ZBX_SERVER_HOST="10.0.0.206" \
--network=host \
--restart unless-stopped \
zabbix/zabbix-agent:5.0-centos-latest