容器:Docker
Docker 容器
yum install -y docker
systemctl start docker
systemctl enable docker
镜像准备
拉取镜像
MySQL
docker pull mysql:8.0
Server
Zabbix-Server 镜像分两种:支持 MySQL 数据库的 zabbix-server-mysql 和支持 PostgreSQL 数据库的 zabbix-server-pgsql
docker pull zabbix/zabbix-server-mysql:latest
Web
官方共有五种,习惯性使用 Nginx,所以选择 zabbix-web-nginx-mysql
docker pull zabbix/zabbix-web-nginx-mysql:latest
Java Gateway(选配)
Zabbix 默认不支持 Java,需要安装 zabbix-java-gateway 来监控 JVM/Tomcat 的性能,按需选配
docker pull zabbix/zabbix-java-gateway:latest
构建镜像(进阶)
运行镜像
分批启动
docker network create -d bridge zabbix_net
docker network ls
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 \
docker run --name zabbix-java-gateway -dit \
--restart always \
--network=zabbix_net \
zabbix/zabbix-java-gateway:latest
docker run --name zabbix-server-mysql -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
docker run --name zabbix-web-nginx-mysql -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
批量启动
yum install -y docker-compose
vim zibbix-docker.yml
docker-compose up -d
docker ps
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-mysql:
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-mysql:zabbix-server
depends_on:
- zabbix-mysql
- zabbix-server-mysql