In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
I. preparatory work
Two VMware virtual machines
One acts as a zabbix server (install docker) ip:192.168.73.133
One acts as a zabbix agent (install docker) ip:192.168.73.136
Basic environment
Cat / etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
Dcoker installation
# disable the firewall:
Systemctl stop firewalld
Systemctl disable firewalld
# close selinux:
Sed-I's etc/selinux/config for Eng.
Setenforce 0
# install dependency packages
Yum install-y yum-utils device-mapper-persistent-data lvm2
# add Docker package source
Yum-config-manager-- add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# install Docker ce
Yum install-y docker-ce
# start Docker service and set boot
Systemctl start docker
Systemctl enable docker
# check the version number
[root@localhost] # docker versionClient: Docker Engine-Community Version: 19.03.1 API version: 1.40 Go version: go1.12.5 Git commit: 74b1e89 Built: Thu Jul 25 21:21:07 2019 OS/Arch: linux/amd64 Experimental: falseServer: Docker Engine-Community Engine: Version: 19.03.1 API version: 1.40 ( Minimum version 1.12) Go version: go1.12.5 Git commit: 74b1e89 Built: Thu Jul 25 21:19:36 2019 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.2.6 GitCommit: 894b81a4b802e4eb2a91d1ce216b8817763c29fb runc: Version: 1.0.0-rc8 GitCommit: 425e105d5a03fabd737a126ad93d62a9eeede87f docker-init: Version: 0.18.0 GitCommit: fec3683
# configure Image Accelerator
Curl-sSL https://get.daocloud.io/daotools/set_mirror.sh | sh-s http://f1361db2.m.daocloud.io`
# restart the image
Systemctl restart docker
Docker installation is complete!
Zabbix server end operation
Provide two different installation methods
1. Use the contents of the docker installation chapter in the zabbix official website to pull the image in the official image library to install.
Https://www.zabbix.com/documentation/4.0/zh/manual/installation/containers
The local directory structure directory of the host in this document is set up to store the data of the container under / home/zabbix. Other directories can be selected according to the actual application. The following operation commands need to connect to the public network for image pull, and no public network needs to download the image package offline.
1) start a separate database mysql to save zabbix data
Docker run-- name mysql-server-t\-e MYSQL_DATABASE= "zabbix"\-e MYSQL_USER= "zabbix"\-e MYSQL_PASSWORD= "zabbix"\-e MYSQL_ROOT_PASSWORD= "zabbix"\-v / home/zabbix/data:/var/lib/mysql\-d mysql:5.7\-- character-set-server=utf8\-collation-server=utf8_bin\-restart=always\-p 3306Suzhou 3306
The database name zabbix, the database user zabbix and the password zabbix are defined to persist the running data of the mysql container in the local directory / home/zabbix/data to ensure that the data will not be lost after the container exits. The last two items define the character set of the database as utf8, which solves the problem of saving Chinese in mysql database.
2) start the zabbix server service, and associate the service to the mysql database instance that has been started above, to ensure that the data of zabbix can be saved to the mysql database, and that there are other contents mounted in the local directory. You can flexibly decide whether to mount it according to the actual situation of the production environment. If you mount it through the container, you can directly load the script or authentication information in the local directory, and the centos version used by the mirror version. It is convenient to use python script later, and the py environment is preinstalled.
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"\-e MYSQL_ROOT_PASSWORD= "zabbix"\-link mysql-server:mysql\-v / home/zabbix/alertscripts:/usr/lib/zabbix/alertscripts\-v / home/zabbix/externalscripts:/usr/lib/zabbix/externalscripts\-v / home/ Zabbix/modules:/var/lib/zabbix/modules\-v / home/zabbix/enc:/var/lib/zabbix/enc\-v / home/zabbix/ssh_keys:/var/lib/zabbix/ssh_keys\-v / home/zabbix/ssl/certs:/var/lib/zabbix/ssl/certs\-v / home/zabbix/ssl/keys:/var/lib/zabbix/ssl/keys\-v / home/zabbix/ssl/ssl_ca:/var/lib/zabbix/ssl/ssl _ ca\-v / home/zabbix/snmptraps:/var/lib/zabbix/snmptraps\-v / home/zabbix/mibs:/var/lib/zabbix/mibs\-p 10051 zabbix/zabbix-server-mysql:centos-latest 10051\-d zabbix/zabbix-server-mysql:centos-latest\-restart=always
Mounting instructions:
/ usr/lib/zabbix/alertscripts
This volume is used to save the custom alert script, which is the AlertScriptsPath parameter zabbix_server.conf
/ usr/lib/zabbix/externalscripts
The external check (project type) uses this volume, which is the ExternalScripts parameter zabbix_server.conf
/ var/lib/zabbix/modules
This volume allows you to load other modules and extend the Zabbix server using the LoadModule feature.
/ var/lib/zabbix/enc
This volume is used to store TLS-related files. The names of these files use the specified ZBX_TLSCAFILE,ZBX_TLSCRLFILE,ZBX_TLSKEY_FILE and ZBX_TLSPSKFILE variables.
/ var/lib/zabbix/ssh_keys
The volume is used as the location of the public and private keys for SSH inspection and operation. It is the SSHKeyLocation parameter zabbix_server.conf.
/ var/lib/zabbix/ssl/certs
The volume is used as the location of the SSL client certificate file for client authentication. It is the SSLCertLocation parameter zabbix_server.conf.
/ var/lib/zabbix/ssl/keys
The volume is used as the location of the SSL private key file for client authentication. It is the SSLKeyLocation parameter zabbix_server.conf.
/ var/lib/zabbix/ssl/ssl_ca
This volume is used as the location of the Certificate Authority (CA) file for SSL server certificate verification. It is the SSLCALocation parameter zabbix_server.conf.
/ var/lib/zabbix/snmptraps
The volume is used as the location of the snmptraps.log file. It can be shared by the zabbix-snmptraps container and inherited by volumes_from using the Docker option when creating a new instance of the Zabbix server.
The SNMP trap handling feature true can be enabled by using shared volumes and swapping ZBX_ENABLE_SNMP_TRAPS environment variables.
/ var/lib/zabbix/mibs
This volume allows you to add new MIB files. It does not support subdirectories and must place all MIB / var/lib/zabbix/mibs
Note: the path where the script is stored and the path to the configuration file are usually used
3) start the web interface instance of the zabbix front end, and compare the web interface instance with the previous mysql database service instance
Docker run-- rm-- name zabbix-web-nginx-mysql-t\-e DB_SERVER_HOST= "mysql-server"\-e MYSQL_DATABASE= "zabbix"\-e MYSQL_USER= "zabbix"\-e MYSQL_PASSWORD= "zabbix"\-e MYSQL_ROOT_PASSWORD= "zabbix"\-e PHP_TZ= "Asia/Shanghai"\-- link mysql-server:mysql\- -link zabbix-server-mysql:zabbix-server\-p 8080pur80\-d zabbix/zabbix-web-nginx-mysql:latest
Mounting instructions:
-- link mysql-server:mysql connects to the database instance. The mysql-server must be exactly the same as the name mysql-server in the first step.
-- link zabbix-server-mysql:zabbix-server connects to the zabbix server instance. The zabbix-server-mysql must be exactly the same as the name zabbix-server-mysql in step 2.
The value of the DB_SERVER_HOST variable should be the same as the-e DB_SERVER_HOST= "mysql-server" specified in step 2.
4) check whether the three installed containers are started properly
In the above state, all three containers are started normally.
# if there is no startup, you can use to view the list of all containers.
[root@localhost] # docker ps-a
# find the container ID that failed to start, and then check the log
[root@localhost ~] # docker logs 0eeb1dbdb279
5) on the host, use the normal installation of zabbix-agent instead of containers
# rpm-ivh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-agent-4.2.5-1.el7.x86_64.rpm#yum install zabbix-agent# vim / etc/zabbix/zabbix_agentd.conf # modify the configuration file Server=172.17.0.3ServerActive=172.17.0.3:10050Hostname=Zabbix server#systemctl restart zabbix-agent#systemctl enable zabbix-agent
Note: if you want to monitor the host, edit the zabbix_agentd.conf of the host. Change the Server address, default 127.0.0.1, to docker-server container address, otherwise it will not work. If you want to monitor other hosts, use the IP of the docker-zabbix-server host.
6) verify the login host port 8080 to see if you can log in normally
Use the host ip where zabbix server is installed plus port 8080 to log in, account Admin, password zabbix, default is English, white background, you can adjust the language and background color in the user button options in the upper right corner
2. Use docker-compose for installation
1) install docker-compose
Curl-L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname-s`-`uname-m`-o / usr/local/bin/docker-composechmod + x / usr/local/bin/docker-composedocker-compose-- versiondocker-compose version 1.23.1, build b02f1306
2) write yml orchestration file
Create a folder
Mkdir / docker-composecd / docker-compose/vim docker-compose.yml
Write docker-compose
Version: '3'mysql: image: mysql:5.7 ports:-"3306 image 3306" volumes: -. / home/zabbix/data:/var/lib/mysql -. / home/zabbix/data:/etc/mysql -. / home/zabbix/data:/var/log/mysql environment:-MYSQL_USER=zabbix-MYSQL_DATABASE=zabbix-MYSQL_PASSWORD=zabbix -MYSQL_ROOT_PASSWORD=123321-LANG=en_US.utf8-TZ=Asia/Shanghai restart: alwaysservices: zabbix-server: container_name: zabbix-server image: zabbix/zabbix-server-mysql:centos-latest restart: always network_mode: host# ports:#-"10051 purl 10051" environment:-DB_SERVER_HOST=192.168.73.133-MYSQL_USER=zabbix-MYSQL_DATABASE=zabbix -MYSQL_PASSWORD=zabbix-DB_SERVER_ROOT_USER=root-DB_SERVER_ROOT_PASS=123321-TZ='Asia/Shanghai' volumes:-/ home/zabbix/zabbixconfig:/etc/zabbix-/ home/zabbix/alertscripts:/usr/lib/zabbix/alertscripts-/ home/zabbix/externalscripts:/usr/lib/zabbix/externalscripts-/ home/zabbix/modules:/var/lib/zabbix/modules -/ home/zabbix/enc:/var/lib/zabbix/enc-/ home/zabbix/ssh_keys:/var/lib/zabbix/ssh_keys-/ home/zabbix/ssl/certs:/var/lib/zabbix/ssl/certs-/ home/zabbix/ssl/keys:/var/lib/zabbix/ssl/keys-/ home/zabbix/ssl/ssl_ca:/var/lib/zabbix/ssl/ssl_ca -/ home/zabbix/snmptraps:/var/lib/zabbix/snmptraps-/ home/zabbix/mibs:/var/lib/zabbix/mibs zabbix-web-nginx: image: zabbix/zabbix-web-nginx-mysql:latest restart: always network_mode: bridge ports:-"8080 home/zabbix/snmptraps:/var/lib/zabbix/snmptraps 80" environment:-DB_SERVER_HOST=192.168.73.133-MYSQL_DATABASE=zabbix-MYSQL_USER=zabbix -MYSQL_PASSWORD=zabbix-MYSQL_ROOT_PASSWORD=123321-ZBX_SERVER_HOST=192.168.73.133-PHP_TZ= "Asia/Shanghai"-TZ='Asia/Shanghai' zabbix-agent: image: zabbix/zabbix-agent:latest environment:-ZBX_HOSTNAME=Zabbix server-ZBX_SERVER_HOST=127.0.0.1-ZBX_SERVER_PORT=10051-TZ='Asia/Shanghai' network_mode: host# Ports:#-"10050 always privileged 10050" restart: true# links:#-zabbix-server:zabbixhost
3) modify according to the ip address of your host, mainly to modify the orchestration file docker-compose.yml
Line 53-DB_SERVER_HOST= current host IP
Line 105-DB_SERVER_HOST= current host IP
Line 115-ZBX_SERVER_HOST= current host IP
4) load the yml orchestration file (you need to wait some time because you need to download the image)
Docker-compose-f docker-compose.yml up-d
5) check whether the container group is running after loading
[root@localhost cmp_zabbix_server] # docker-compose ps Name Command State Ports-- -cmp_zabbix_server_zabbix-agent_1_95447af24cfd / sbin/tini-/ usr/bin/doc. Up cmp_zabbix_server_zabbix-web-nginx_1_aeec36553371 docker-entrypoint.sh Up 443/tcp, 0. 0. 0. 0. 0. 8080-> 80/tcpzabbix-server
Zabbix agent end operation
1 if the host has installed docker, you can also use docker-compose, write and orchestrate the yml file to install, and modify line 8 ip according to the host ip address
Mkdir / docker-composecd / docker-compose/vim docerk-compose.ymlversion: '3'version:' 3'services: zabbix-agent: image: zabbix/zabbix-agent:latest container_name: zabbix-agent environment:-ZBX_HOSTNAME=192.168.73.136-ZBX_SERVER_HOST=192.168.73.133-ZBX_SERVER_PORT=10051-TZ='Asia/Shanghai' network_mode: bridge ports:-"10050 ZBX_SERVER_HOST=192.168.73.133 10050" restart: always privileged: true
Load orchestration file
Docker-compose-f docker-compose.yml up-d-- build
Check to see if the container started successfully
Docker-compose ps
If the host does not have docker installed, you can install it using the rpm package. See the agent installation steps for the zabbix-server host.
Web end operation
Verify the login host port 8080 to see if you can log in normally. Log in using ip plus port 8080 of the host installed with zabbix server, account number admin, password zabbix, default is English, white background, you can adjust the language and background color in the user button options in the upper right corner, and add the host of the agent just installed in the configuration options
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.