#!/usr/bin/env bash
__mian() {
cat >docker-compose.yaml <<EOF
version: "3.9"
services:
# zabbix 数据库
zabbix-mysql:
container_name: zabbix-mysql
image: mysql:8.0.29
command: --character-set-server=utf8mb4
--collation-server=utf8mb4_unicode_ci
--default-authentication-plugin=mysql_native_password
networks:
zabbix_net:
aliases:
- zabbix-mysql
ports:
- "3306:3306"
environment:
- TZ=Asia/Shanghai
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=bad_password
- MYSQL_ROOT_PASSWORD=bad_password
- MYSQL_DB=zabbix
volumes:
- ./volumes/mysql/conf/:/etc/mysql.copy/
# - ./volumes/mysql/conf/:/etc/mysql/
- ./volumes/mysql/data/:/var/lib/mysql
- ./volumes/mysql/files/:/var/lib/mysql-files
- ./volumes/mysql/back/:/backups
stop_grace_period: 1m
# zabbix 服务端
zabbix-server:
container_name: zabbix-server
image: zabbix/zabbix-server-mysql:ubuntu-6.0.3
networks:
zabbix_net:
aliases:
- zabbix-server
ports:
- "10051:10051"
environment:
- TZ=Asia/Shanghai
- DB_SERVER_HOST=zabbix-mysql
- MYSQL_USER=root
- MYSQL_PASSWORD=bad_password
depends_on:
- zabbix-mysql
volumes:
- ./volumes/zabbix_server:/etc/zabbix.copy
# - ./volumes/zabbix_server/zabbix_server.conf:/etc/zabbix/zabbix_server.conf
# zabbix web
zabbix-web:
container_name: zabbix-web
image: zabbix/zabbix-web-nginx-mysql:ubuntu-6.0.3
networks:
- zabbix_net
ports:
- "8080:8080"
environment:
- TZ=Asia/Shanghai
- ZBX_SERVER_HOST=zabbix-server
- DB_SERVER_HOST=zabbix-mysql
- MYSQL_USER=root
- MYSQL_PASSWORD=bad_password
- PHP_TZ=Asia/Shanghai
networks:
zabbix_net:
external: true
EOF
docker network create -d bridge --subnet=172.22.1.0/24 --gateway=172.22.1.254 zabbix_net
docker-compose -p zabbix -f docker-compose.yaml up -d
sleep 2s
docker exec -it -u root zabbix-mysql bash -c 'cp -rf /etc/mysql/* /etc/mysql.copy/'
docker exec -it -u root zabbix-server bash -c 'cp -rf /etc/zabbix/* /etc/zabbix.copy/'
}
__mian