服务器信息:
[root@localhost zabbix]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 4.3G 34G 12% /
devtmpfs 3.7G 0 3.7G 0% /dev
tmpfs 3.7G 0 3.7G 0% /dev/shm
tmpfs 3.7G 864K 3.7G 1% /run
tmpfs 3.7G 0 3.7G 0% /sys/fs/cgroup
tmpfs 756M 0 756M 0% /run/user/0
overlay 40G 4.3G 34G 12% /var/lib/docker/overlay2/409add149fb5468dea0470bcf5c0fccf07f8d82326e30f3d8d2770cc429554d4/merged
shm 64M 0 64M 0% /var/lib/docker/containers/d2c7759ec4982225a78d9a526361a3c8e22d6a2319d0316fa8c61fb714edd32a/mounts/shm
overlay 40G 4.3G 34G 12% /var/lib/docker/overlay2/d5316e29e4771782a0fac5a230cc5b6af37225be92f21a3fd52b303aa999424c/merged
overlay 40G 4.3G 34G 12% /var/lib/docker/overlay2/00f44ae8e5e25ab6d929083d85b928752ebb0c9611b5d58c4264a0e24c1eab7a/merged
shm 64M 0 64M 0% /var/lib/docker/containers/b41222cbeb6085b67cff9368fc11ad92fe1b21326aded5d934f9cd19004f733f/mounts/shm
shm 64M 0 64M 0% /var/lib/docker/containers/bfba0321601a42594b7958166c392b6fe949ed9fdf5ec189bc2aeb18fd25c755/mounts/shm
overlay 40G 4.3G 34G 12% /var/lib/docker/overlay2/1e8867e0765e0cf34431a89280d8fd9bbe5e311e0b12f0c6e072339d1f4f9536/merged
shm 64M 0 64M 0% /var/lib/docker/containers/338f4bf2baf3466db78805ae22a1f7d8342e8abd4f51930ca86856a00d8616c5/mounts/shm
overlay 40G 4.3G 34G 12% /var/lib/docker/overlay2/89fceb1b7716acbb4304b9d8e8582ba2ef3c235862af500a5382e1598aa87268/merged
shm 64M 0 64M 0% /var/lib/docker/containers/1fe7d88b5144f0dbc78a4c01fe0da7788632edea7bda90ac45ca147f8be7a81c/mounts/shm
[root@localhost zabbix]#
[root@localhost zabbix]# free -m
total used free shared buff/cache available
Mem: 7551 893 5482 10 1176 6378
Swap: 0 0 0
[root@localhost zabbix]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@localhost zabbix]#
一、创建目录
[root@localhost zabbix]# mkdir -p /opt/earth/zabbix/{mysql/{data,conf,logs},font
,snmptraps,mibs,alertscripts,externalscripts}
[root@localhost zabbix]# pwd
/opt/earth/zabbix
[root@localhost zabbix]# tree -L 2
.
├── alertscripts
├── docker-compose.yml
├── externalscripts
├── font
│ └── simfang.ttf
├── mibs
├── mysql
│ ├── conf
│ ├── data
│ └── logs
└── snmptraps
10 directories, 1 file
[root@localhost zabbix]#
二、拉取镜像
docker pull mysql:8.0
docker pull zabbix/zabbix-java-gateway:6.0-centos-latest
docker pull zabbix/zabbix-snmptraps:6.0-centos-latest
docker pull zabbix/zabbix-server-mysql:6.0-centos-latest
docker pull zabbix/zabbix-web-nginx-mysql:6.0-centos-latest
[root@localhost zabbix]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
zabbix/zabbix-web-nginx-mysql 6.0-centos-latest e456c53230da 7 days ago 465MB
zabbix/zabbix-snmptraps 6.0-centos-latest 7d9302f4583a 7 days ago 275MB
zabbix/zabbix-server-mysql 6.0-centos-latest b41030bd4574 7 days ago 350MB
zabbix/zabbix-java-gateway 6.0-centos-latest 2f819bf978bc 7 days ago 450MB
mysql 8.0 c3ef21d6632d 8 days ago 603MB
三、编辑docker-compose.yml文件
[root@localhost zabbix]# pwd
/opt/earth/zabbix
[root@localhost zabbix]# ll
total 28
drwxr-xr-x 2 root root 4096 Apr 3 15:29 alertscripts
-rw-r--r-- 1 root root 2829 Apr 3 16:03 docker-compose.yml
drwxr-xr-x 2 root root 4096 Apr 3 15:29 externalscripts
drwxr-xr-x 3 root root 4096 Apr 3 16:04 font
drwxr-xr-x 2 root root 4096 Apr 3 15:29 mibs
drwxr-xr-x 5 root root 4096 Apr 3 15:29 mysql
drwxr-xr-x 2 root root 4096 Apr 3 15:29 snmptraps
[root@localhost zabbix]#
[root@localhost zabbix]# cat docker-compose.yml
---
version: '3'
services:
mysql:
image: mysql:8.0
container_name: mysql
volumes:
- ./mysql/data:/var/lib/mysql
- ./mysql/conf:/etc/mysql/conf.d
- ./mysql/logs:/var/log/mysql
- /etc/localtime:/etc/localtime
restart: always
privileged: true
environment:
- MYSQL_ROOT_PASSWORD=myrootpass
- MYSQL_DATABASE=zabbix
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=mypass
- TZ=Asia/Shanghai
- LANG=en_US.UTF-8
expose:
- "3306"
zabbix-gateway:
image: zabbix/zabbix-java-gateway:6.0-centos-latest
container_name: zabbix-gateway
volumes:
- /etc/localtime:/etc/localtime
restart: always
privileged: true
ports:
- "10052:10052"
zabbix-snmptraps:
image: zabbix/zabbix-snmptraps:6.0-centos-latest
container_name: zabbix-snmptraps
volumes:
- /etc/localtime:/etc/localtime
- ./snmptraps:/var/lib/zabbix/snmptraps
- ./mibs:/var/lib/zabbix/mibs
restart: always
privileged: true
ports:
- "1162:1162/udp"
zabbix-server:
image: zabbix/zabbix-server-mysql:6.0-centos-latest
container_name: zabbix-server
volumes:
- /etc/localtime:/etc/localtime
- ./snmptraps:/var/lib/zabbix/snmptraps
- ./mibs:/var/lib/zabbix/mibs
- ./alertscripts:/usr/lib/zabbix/alertscripts
- ./externalscripts:/usr/lib/zabbix/externalscripts
restart: always
privileged: true
environment:
- ZBX_LISTENPORT=10051
- DB_SERVER_HOST=mysql
- DB_SERVER_PORT=3306
- MYSQL_DATABASE=zabbix
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=mypass
- MYSQL_ROOT_PASSWORD=myrootpass
- ZBX_CACHESIZE=1G
- ZBX_HISTORYCACHESIZE=512M
- ZBX_HISTORYINDEXCACHESIZE=16M
- ZBX_TRENDCACHESIZE=256M
- ZBX_VALUECACHESIZE=256M
- ZBX_STARTPINGERS=64
- ZBX_IPMIPOLLERS=1
- ZBX_ENABLE_SNMP_TRAPS=true
- ZBX_STARTTRAPPERS=1
- ZBX_JAVAGATEWAY_ENABLE=true
- ZBX_JAVAGATEWAY=zabbix-gateway
- ZBX_STARTJAVAPOLLERS=1
ports:
- "10051:10051"
links:
- mysql
- zabbix-gateway
zabbix-web:
image: zabbix/zabbix-web-nginx-mysql:6.0-centos-latest
container_name: zabbix-web
volumes:
- ./font/simfang.ttf:/usr/share/zabbix/assets/fonts/DejaVuSans.ttf
- /etc/localtime:/etc/localtime
restart: always
privileged: true
environment:
- ZBX_SERVER_NAME=Zabbix 6.0
- ZBX_SERVER_HOST=zabbix-server
- ZBX_SERVER_PORT=10051
- DB_SERVER_HOST=mysql
- DB_SERVER_PORT=3306
- MYSQL_DATABASE=zabbix
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=mypass
- MYSQL_ROOT_PASSWORD=myrootpass
- PHP_TZ=Asia/Shanghai
ports:
- "80:8080"
links:
- mysql
- zabbix-server
四、docker-compose安装zabbix
[root@localhost zabbix]# docker-compose up -d
[root@localhost zabbix]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
abab3ca947e5 zabbix/zabbix-web-nginx-mysql:6.0-centos-latest "docker-entrypoint.sh" 49 seconds ago Up 48 seconds 8443/tcp, 0.0.0.0:80->8080/tcp zabbix-web
1c3a475e2db9 zabbix/zabbix-server-mysql:6.0-centos-latest "/usr/bin/tini -- /u…" 49 seconds ago Up 49 seconds 0.0.0.0:10051->10051/tcp zabbix-server
77196b9f307d zabbix/zabbix-snmptraps:6.0-centos-latest "/usr/sbin/snmptrapd…" 50 seconds ago Up 49 seconds 0.0.0.0:1162->1162/udp zabbix-snmptraps
8e7852828d32 mysql:8.0 "docker-entrypoint.s…" 50 seconds ago Up 49 seconds 3306/tcp, 33060/tcp mysql
17cd6b8870c5 zabbix/zabbix-java-gateway:6.0-centos-latest "docker-entrypoint.s…" 50 seconds ago Up 49 seconds 0.0.0.0:10052->10052/tcp zabbix-gateway
五、浏览器访问zabbix
URL : http://ip/
用户: Admin
密码: zabbix