2022年11月21日 星期一

ubuntu 簡易安裝docker zabbix

 ubuntu要先安裝docker及docker-compose

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="zabbix_pwd" \

      -e MYSQL_ROOT_PASSWORD="root_pwd" \

      --network=zabbix-net \

      -d mysql:5.7 \

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


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-5.4-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="zabbix_pwd" \

      -e MYSQL_ROOT_PASSWORD="root_pwd" \

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

      --network=zabbix-net \

      -p 10051:10051 \

      --restart unless-stopped \

      -d zabbix/zabbix-server-mysql:alpine-5.4-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="zabbix_pwd" \

      -e MYSQL_ROOT_PASSWORD="root_pwd" \

      --network=zabbix-net \

      -p 80:8080 \

      --restart unless-stopped \

      -d zabbix/zabbix-web-nginx-mysql:alpine-5.4-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 ${server_dir}/agent2/modules:/var/lib/zabbix/modules \

      --privileged \

      --network=zabbix-net \

      --restart unless-stopped \

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

沒有留言:

張貼留言