Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Docker zabbix installation

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Reference: www.cnblogs.com/double-dong/p/11441168.html

Mirror ready.

Download images: mysql, zabbix/zabbix-server-mysql, zabbix/zabbix-web-nginx-mysql

docker pull mysql:5.7docker pull zabbix/zabbix-server-mysqldocker pull zabbix/zabbix-web-nginx-mysql[root@localhost ~]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEzabbix/zabbix-web-nginx-mysql latest 9102571b2fef 3 weeks ago 155MBzabbix/zabbix-server-mysql latest 6da679c2a6c6 3 weeks ago 65.8MBzabbix/zabbix-agent latest be72aee790c3 3 weeks ago 16.6MBzabbix/zabbix-java-gateway latest e175083b2981 3 weeks ago 83.4MBmysql 5.7 1e4405fe1ea9 3 weeks ago 437MB

MySQL installation

docker run --name mysql-server \-v /etc/localtime:/etc/localtime -t \-v /home/docker/data/mysql:/var/lib/mysql \--hostname zabbix_mysql \-p 3306:3306 \--restart=always \-e MYSQL_DATABASE="zabbix" \-e MYSQL_USER="zabbix" \-e MYSQL_PASSWORD="zabbix" \-e MYSQL_ROOT_PASSWORD="zabbix" \-d mysql:5.7 \--character-set-server=utf8 --collation-server=utf8_bin

Install java-gateway

docker run --name zabbix-java-gateway \-v /etc/localtime:/etc/localtime -t \-d zabbix/zabbix-java-gateway:latest

Install zabbix-server

docker run --name zabbix-server-mysql \-v /etc/localtime:/etc/localtime:ro -t \-v /home/docker/data/zabbix:/usr/lib/zabbix \-v /home/zabbix/alertscripts:/usr/lib/zabbix/alertscripts \ -v /home/zabbix/externalscripts:/usr/lib/zabbix/externalscripts \--restart=always \-e DB_SERVER_HOST="mysql-server" \-e MYSQL_DATABASE="zabbix" \-e MYSQL_USER="zabbix" \-e MYSQL_PASSWORD="zabbix" \-e MYSQL_ROOT_PASSWORD="zabbix" \-e ZBX_JAVAGATEWAY="zabbix-java-gateway" \--link mysql-server:mysql \--link zabbix-java-gateway:zabbix-java-gateway \-p 10051:10051 \-d zabbix/zabbix-server-mysql:latest

/usr/lib/zabbix/alertscripts

This volume holds custom alert scripts and is the AlertScriptsPath parameter zabbix_server.conf

/usr/lib/zabbix/externalscripts

External check (project type) uses this volume, which is ExternalScripts parameter zabbix_server.conf

The installation front-end page maps localtime of the host to localtime of the container

docker run --name zabbix-web-nginx-mysql \-v /etc/localtime:/etc/localtime -t \--restart=always \-e PHP_TZ="Asia/Shanghai" \-e DB_SERVER_HOST="mysql-server" \-e MYSQL_DATABASE="zabbix" \-e MYSQL_USER="zabbix" \-e MYSQL_PASSWORD="zabbix" \-e MYSQL_ROOT_PASSWORD="zabbix" \--link mysql-server:mysql \--link zabbix-server-mysql:zabbix-server \-p 8080:80 \-p 8443:443 \-d zabbix/zabbix-web-nginx-mysql:latest

At this time, the browser accesses port 8080 of the host machine and can use zabbix-server service.

Account: admin, Password: zabbix

Export and Import of Mirrors

Mirror export

docker save -o/opt/zabbix_agent.tar zabbix/zabbix-agent:latest#/opt/zabbix_agent.tar export mirror location and name #zabbix/zabbix-agent:latest export mirror REPOSITORY and TAGdocker save -o/opt/zabbix_server.tar zabbix/zabbix-server-mysql:latestdocker save -o/opt/zabbix_nginx.tar zabbix-web-nginx-mysql:latestdocker save -o/opt/zabbix_mysql. tar mysql:5.7

We look at the list of files under/opt and see that the export succeeded

ll /opt

-rw------- 1 root root 61114368 Dec 16 14:54 zabbix_agent.tar

-rw------- 1 root root 305571840 Dec 16 15:02 zabbix_mysql.tar

-rw------- 1 root root 182195200 Dec 16 15:01 zabbix_nginx.tar

-rw------- 1 root root 112269824 Dec 16 15:00 zabbix_server.tar

Import Mirror:

docker load -i /opt/zabbix_agent.tar

#/opt/zabbix_agent.tar is the image just exported

docker load -i /opt/zabbix_server.tar

docker load -i /opt/zabbix_nginx.tar

docker load -i /opt/zabbix_mysql.tar

Using docker images again, you can see that the image has been successfully imported and can be used on the currently unconnected machine.

zabbix redeployment and migration

For zabbix that uses docker, because we have already mapped the storage, the database and zabbix configuration can be migrated to other machines in containers, copy the following directories on the host, and then redeploy the zabbix container.

/home/docker/data/zabbix

/home/docker/data/mysql

Since the mapping is stored on the host, cloud backups can be used to prevent data loss.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report