docker-compose安装单机版zabbix5.0
准备工作
1.关闭防火墙和selinux
2.安装好docker
安装docker-compose
[root@localhost ~]# sudo curl -L "https://github.com/docker/compose/releases/download/1.27.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
[root@localhost ~]# sudo chmod +x /usr/local/bin/docker-compose
[root@localhost ~]# docker-compose version
docker-compose version 1.27.1, build 509cfb99
docker-py version: 4.3.1
CPython version: 3.7.7
OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019
创建挂载目录
[root@localhost ~]# mkdir -p zabbix/{alertscripts,externalscripts,mysqldata}
[root@localhost ~]# cd zabbix
[root@localhost zabbix]# vim docker-compose.yml
编写docker-compose.yml文件
version: "3.8"
services:
mysql-server:
image: mysql:8.0
container_name: mysql-server
restart: always
environment:
MYSQL_DATABASE: zabbix
MYSQL_USER: zabbix
MYSQL_PASSWORD: 123456
MYSQL_ROOT_PASSWORD: 123456
command:
- --character-set-server=utf8
- --collation-server=utf8_bin
- --default-authentication-plugin=mysql_native_password
networks:
- zabbix-net
volumes:
- "/root/zabbix/mysqldata:/var/lib/mysql"
- "/etc/localtime:/etc/localtime"
ports:
- "3306:3306"
zabbix-java-gateway:
image: zabbix/zabbix-java-gateway
container_name: zabbix-java-gateway
volumes:
- "/etc/localtime:/etc/localtime"
ports:
- "10052:10052"
restart: always
networks:
- zabbix-net
zabbix-server-mysql:
image: zabbix/zabbix-server-mysql
container_name: zabbix-server-mysql
networks:
- zabbix-net
restart: always
depends_on:
- mysql-server
environment:
DB_SERVER_HOST: mysql-server
MYSQL_DATABASE: zabbix
MYSQL_USER: zabbix
MYSQL_PASSWORD: 123456
MYSQL_ROOT_PASSWORD: 123456
ZBX_JAVAGATEWAY: zabbix-java-gateway
ZBX_JAVAGATEWAY_ENABLE: "true"
ports:
- "10051:10051"
volumes:
- "/etc/localtime:/etc/localtime"
- "/root/zabbix/alertscripts:/usr/lib/zabbix/alertscripts"
- "/root/zabbix/externalscripts:/usr/lib/zabbix/externalscripts"
links:
- mysql-server:mysql
- zabbix-java-gateway:zabbix-java-gateway
zabbix-web-nginx-mysql:
image: zabbix/zabbix-web-nginx-mysql
container_name: zabbix-web-nginx-mysql
networks:
- zabbix-net
restart: always
depends_on:
- mysql-server
- zabbix-server-mysql
environment:
DB_SERVER_HOST: mysql-server
MYSQL_DATABASE: zabbix
MYSQL_USER: zabbix
MYSQL_PASSWORD: 123456
MYSQL_ROOT_PASSWORD: 123456
ZBX_SERVER_HOST: zabbix-server
PHP_TZ: "Asia/Shanghai"
ports:
- "8080:8080"
volumes:
- "/etc/localtime:/etc/localtime"
links:
- mysql-server:mysql
- zabbix-server-mysql:zabbix-server
zabbix-agent:
image: zabbix/zabbix-agent
container_name: zabbix-agent
restart: always
privileged: true
environment:
ZBX_HOSTNAME: "Zabbix server"
ZBX_SERVER_HOST: "172.18.0.1"
ZBX_SERVER_PORT: 10051
ports:
- "10050:10050"
volumes:
- "/etc/localtime:/etc/localtime"
networks:
- zabbix-net
networks:
zabbix-net:
ipam:
driver: default
config:
- subnet: "172.18.0.0/16"
启动zabbix
[root@localhost zabbix]# docker-compose up -d
网友评论