2023年8月2日 星期三

簡易安裝docker zabbix

 Detailed Guide – Method: 1

The example demonstrates how to run Zabbix server with MySQL database support, Zabbix web interface based on the Nginx web server and Zabbix Java gateway.


1. Create network dedicated for Zabbix component containers:

# docker network create --subnet 172.20.0.0/16 --ip-range 172.20.240.0/20 zabbix-net


2. Start empty MySQL server instance

# docker run --name mysql-server -t \

      -e MYSQL_DATABASE="zabbix" \

      -e MYSQL_USER="zabbix" \

      -e MYSQL_PASSWORD="1qaz2wsx" \

      -e MYSQL_ROOT_PASSWORD="1qaz2wsx" \

      --network=zabbix-net \

      --restart unless-stopped \

      -d mysql:8.0 \

      --character-set-server=utf8 --collation-server=utf8_bin \

      --default-authentication-plugin=mysql_native_password


3. Start Zabbix Java gateway instance

# docker run --name zabbix-java-gateway -t \

      --network=zabbix-net \

      --restart unless-stopped \

      -d zabbix/zabbix-java-gateway:alpine-6.2-latest


4. Start Zabbix server instance and link the instance with created MySQL server instance

# docker run --name zabbix-server-mysql -t \

      -e DB_SERVER_HOST="mysql-server" \

      -e MYSQL_DATABASE="zabbix" \

      -e MYSQL_USER="zabbix" \

      -e MYSQL_PASSWORD="1qaz2wsx" \

      -e MYSQL_ROOT_PASSWORD="1qaz2wsx" \

      -e ZBX_JAVAGATEWAY="zabbix-java-gateway" \

      --network=zabbix-net \

      -p 10051:10051 \

      --restart unless-stopped \

      -d zabbix/zabbix-server-mysql:alpine-6.2-latest


5. Start Zabbix web interface and link the instance with created MySQL server and Zabbix server instances

# docker run --name zabbix-web-nginx-mysql -t \

      -e ZBX_SERVER_HOST="zabbix-server-mysql" \

      -e DB_SERVER_HOST="mysql-server" \

      -e MYSQL_DATABASE="zabbix" \

      -e MYSQL_USER="zabbix" \

      -e MYSQL_PASSWORD="1qaz2wsx" \

      -e MYSQL_ROOT_PASSWORD="1qaz2wsx" \

      --network=zabbix-net \

      -p 80:8080 \

      --restart unless-stopped \

      -d zabbix/zabbix-web-nginx-mysql:alpine-6.2-latest


Zabbix web interface instance exposes 80/TCP port (HTTP) to host machine.



Zabbix server主機安裝Zabbix agent2服務

sudo mkdir /var/lib/docker/volumes/zabbix-agent2-volume

docker volume create zabbix-agent2-volume

docker run -v /etc/localtime:/etc/localtime \

      --name zabbix-agent2 \

      -v zabbix-agent2-volume:/etc/zabbix \

      -e ZBX_HOSTNAME="zabbix-server" \

      -e ZBX_SERVER_HOST="zabbix-server-mysql" \

      -p 10050:10050 \

      -e ZBX_SERVER_PORT=10051 \

      -v /opt/zabbix/agent2/modules:/var/lib/zabbix/modules \

      --privileged \

      --network=zabbix-net \

      --restart unless-stopped \

      -d zabbix/zabbix-agent2:ubuntu-6.0-latest


給/var/run/docker.sock 所有用戶可讀權限(zabbix用戶)

sudo chmod 666 /var/run/docker.sock

沒有留言:

張貼留言