1
2
3
yum install -y docker
systemctl start docker
systemctl enable docker

镜像准备

Zabbix 官方镜像

MySQL

1
docker pull mysql:8.0

Server

Zabbix-Server 镜像分两种:支持 MySQL 数据库的 zabbix-server-mysql 和支持 PostgreSQL 数据库的 zabbix-server-pgsql

1
docker pull zabbix/zabbix-server-mysql:latest

Web

官方共有五种,习惯性使用 Nginx,所以选择 zabbix-web-nginx-mysql

1
docker pull zabbix/zabbix-web-nginx-mysql:latest

Java Gateway

选配,Zabbix 默认不支持 Java,需要安装 zabbix-java-gateway 来监控 JVM/Tomcat 的性能,按需选配

1
docker pull zabbix/zabbix-java-gateway:latest

构建镜像

进阶

运行镜像

分批启动

1
2
3
#创建网络
docker network create -d bridge zabbix_net
docker network ls
1
2
3
4
5
6
7
8
9
10
11
12
docker run --name zabbix-mysql -dit \
-p 13306:3306 \
--restart=always \
--network zabbix_net \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix1@#$" \
-e MYSQL_ROOT_PASSWORD="root_1@#$" \
--character-set-server=utf8 --collation-server=utf8_bin
-v /data/zabbix/mysql:/var/lib/mysql \
-v /etc/localtime:/etc/localtime \
mysql:8.0 \
1
2
3
4
docker run --name zabbix-java-gateway -dit \
--restart always \
--network=zabbix_net \
zabbix/zabbix-java-gateway:latest
1
2
3
4
5
6
7
8
9
10
11
docker run --name zabbix-server -dit \
-p 10051:10051 \
--restart always \
--network=zabbix_net \
-e DB_SERVER_HOST="zabbix-mysql" \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix1@#$" \
-e MYSQL_ROOT_PASSWORD="root_1@#$" \
-e ZBX_JAVAGATEWAY="zabbix-java-gateway" \
zabbix/zabbix-server-mysql:latest
1
2
3
4
5
6
7
8
9
10
11
docker run --name zabbix-web -dit \
-p 80:8080 \
--restart always \
--network=zabbix_net \
-e ZBX_SERVER_HOST="zabbix-server-mysql" \
-e DB_SERVER_HOST="zabbix-mysql" \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix1@#$" \
-e MYSQL_ROOT_PASSWORD="root_1@#$" \
zabbix/zabbix-web-nginx-mysql:latest

批量启动

1
2
3
4
yum install -y docker-compose
vim zibbix-docker.yml
docker-compose up -d
docker ps
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
version: "3"
services:
mysql-server:
image: mysql:8.0
container_name: zabbix-mysql
environment:
- MYSQL_DATABASE=zabbix
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=zabbix1@#$
- MYSQL_ROOT_PASSWORD=roo_1@#$
ports:
- 13306:3306
volumes:
- /data/zabbix/mysql:/var/lib/mysql
command:
--character-set-server=utf8
--collation-server=utf8_bin

zabbix-server:
image: zabbix/zabbix-server-mysql:latest
container_name: zabbix-server-mysql
environment:
- DB_SERVER_HOST=zabbix-mysql
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=zabbix1@#$
- MYSQL_DATABASE=zabbix
- MYSQL_ROOT_PASSWORD=root_1@#$
ports:
- 10051:10051
links:
- zabbix-mysql:mysql
depends_on:
- zabbix-mysql
volumes:
- /etc/localtime:/etc/localtime
- /data/zabbix/etc/zabbix:/etc/zabbix
- /data/zabbix/alertscripts:/usr/lib/zabbix/alertscripts

zabbix-web:
image: zabbix/zabbix-web-nginx-mysql:latest
environment:
- DB_SERVER_HOST=mysql-server
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=zabbix1@#$
- MYSQL_DATABASE=zabbix
- MYSQL_ROOT_PASSWORD=roo_1@#$
ports:
- 80:80
volumes:
- /etc/localtime:/etc/localtime
links:
- zabbix-mysql:mysql
- zabbix-server:zabbix-server
depends_on:
- zabbix-mysql
- zabbix-server