The road to learning cloud computing - zabbix installation, deployment and monitoring cases

1. Zabbix monitoring deployment

1. Experimental environment
name of server IP address
zabbix-server 192.168.58.155
zabbix-agent 192.168.58.143

Note:
Before starting the deployment, you must do the following:
turn off the firewall,
turn off selinux
to ensure that the yum warehouse is available,
and ensure that the network is available.

2. Deployment of zabbix-server

1) Install zabbix warehouse

After installation, you will see the zabbix.repo warehouse under /etc/yum.repo.d/

[root@zabbix-server ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

2) Install zabbix-server

[root@zabbix-server ~]# yum install zabbix-server-mysql zabbix-agent
The zabbix-server-mysql database is used to store collected data

3) Install the warehouse that zabbix front-end depends on

[root@zabbix-server ~]# yum -y install centos-release-scl

4) Edit the file /etc/yum.repos.d/zabbix.repo and enable the zabbix-frontend repository.

[root@zabbix-server ~]# vim /etc/yum.repos.d/zabbix.repo
Insert image description here
To use the zabbix-frontend warehouse, you need centos-release-scl to provide the plug-in, so the centos-release-scl warehouse is installed first in the previous step.

5) Install zabbix front-end package

[root@zabbix-server ~]# yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl
The function of zabbix-web-mysql is that the web side of Zabbix will display drawings through these data.

6) Install database

[root@zabbix-server ~]# rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

7) Modify the database version, disable 8.0 and enable version 5.7.
Method 1:
Install the yum-utils tool and use shell commands to directly modify the version.

[root@zabbix-server ~]# yum -y install yum-utils
[root@zabbix-server ~]# yum-config-manager --disable mysql80-community
[root@zabbix-server ~]# yum-config-manager --enable mysql57-community

Method 2:
Modify the mysql-community.repo file under /etc/yum.repo.d/
Insert image description here
8) Install the database

[root@zabbix-server ~]# yum -y install mysql mysql-server

An error was reported here. The error content is as follows:

warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-libs-compat-5.7.38-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql


The GPG keys listed for the "MySQL 5.7 Community Server" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.


 Failing package is: mysql-community-libs-compat-5.7.38-1.el7.x86_64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

Solution: Just add the --nogpgcheck
parameter to the installation command to solve the problem

[root@zabbix-server ~]# yum -y install mysql mysql-server --nogpgcheck

9) Start the database

[root@zabbix-server ~]# systemctl start mysqld

10) Modify database password

[root@zabbix-server ~]# cat /var/log/mysqld.log | grep temporary
[root@zabbix-server ~]# mysqladmin -uroot -p'WUeqZ62iGi=j' password 'Zhang@123'

11) Create database zabbix and set the character set to utf-8

[root@zabbix-server ~]# mysql -u root -pZhang@123
mysql> create database zabbix character set utf8 collate utf8_bin;

12) Authorize the account to access the zabbix library

mysql> grant all on zabbix.* to zabbix@'localhost' identified by '123456'

13) Database import into zabbix

[root@zabbix-server ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Insert image description here
The -u followed by the mysql authorized user here, the zabbix after -p is not the password, but the name of the database to be imported. The last password entered is the password of the authorized user, which needs to be compared with step 12.

14) Modify front-end php time zone
Edit the file /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf, uncomment and set the correct time zone for you.

[root@zabbix-server ~]# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
Insert image description here

15) Configure the database password for the zabbix server
and edit the file /etc/zabbix/zabbix_server.conf

[root@zabbix-server ~]# vim /etc/zabbix/zabbix_server.conf
Insert image description here

16) Start zabbix

[root@zabbix-server ~]# systemctl start zabbix-server zabbix-agent httpd rh-php72-php-fpm

[root@zabbix-server ~]# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm#Start on boot


17) Visit http://ip address/zabbix with the browser
and go to the next step, then fill in the database information, and finally fill in the user name and password to log in.
The default username is: Admin Password: zabbix The username and password here are case-sensitive. The final interface is:
Insert image description here

2. Deployment of zabbix-agent side

1) Install the yum source of zabbix

[root@zabbix-agent ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

2) Install zabbix-agent

[root@zabbix-agent ~]# yum -y install zabbix-agent

3) Modify the configuration file /etc/zabbix/zabbix_agentd.conf

[root@zabbix-agent ~]# vim /etc/zabbix/zabbix_agentd.conf
Find the corresponding parameters and make the following modifications:
Server=192.168.58.155 //The ip here is the zabbix-server's
ServerActive=192.168.58.155 //The ip here is the zabbix-server's
Hostname=zabbix-server //Hostname, customized
UnsafeUserParameters=1 //Whether to restrict user-defined keys Using special characters 1 means special characters can be enabled 0 means special characters cannot be enabled

Insert image description here
Insert image description here
Insert image description here
4) Start zabbix-agent

[root@zabbix-agent ~]# systemctl start zabbix-agent

2. Simple zabbix monitoring case (monitoring website access delay)

Use zabbix-server to monitor and manage zabbix-agent

Monitoring case: website access delay (the time required to access a website is called access delay. If it takes a long time to open the website, it will affect the user experience). The premise of this case is to ensure that the monitored end has a running website. Here Install and deploy nginx on the zabbix-agent side as a website service

Install and deploy nginx on the zabbix-agent side as a website service

1. Install nginx

[root@zabbix-agent ~]# yum -y install nginx

2. Create a simple website

[root@zabbix-agent ~]# rm -rf /etc/nginx/nginx.conf
[root@zabbix-agent ~]# cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf
[root@zabbix-agent ~]# echo "zhangyu" > /usr/share/nginx/html/index.html

3. Start nginx

[root@zabbix-agent ~]# systemctl start nginx

● Perform the following operations in the web interface of zabbix-server:

To monitor zabbix-agent, you first need to create a host in the web interface of zabbix-server to associate the monitored terminal zabbix-agent.

1. Create a host group (customized name)
Insert image description here
Insert image description here

2. Create a host.
Insert image description here
Insert image description here
Host name: Customized.
Group: Select the required host group. The existence of the host group is effective in helping to manage the host. Here, select the main
IP address of the host group just created: fill in the IP address of the monitored end, here Fill in the IP address of the zabbix-agent deployed in the first part.

3. Configure monitoring items.
Create monitoring items in the host just created.
Insert image description here
Insert image description here
Insert image description here
Name: Custom
Key value: Select web.page.perf[host,<path>,<port>], and change host, path, and port to the corresponding information.
Information type: floating point
Insert image description here
host: 192.168.58.143 //zabbix-agent’s IP address
path: index.html
port: 80

4. Create the graph
Insert image description here
Insert image description here
Insert image description here
and view the monitoring graph.
Insert image description here
Insert image description here
Finally, seeing this graph indicates that the graph is successfully created and can be monitored in real time.

5. Create a trigger.
Create a trigger in the monitored host.
Insert image description here
Insert image description here
Insert image description here
Name: Custom
Severity: Custom selection
Expression: See the figure below.
Insert image description here
Note: The value of the modified trigger is 0.0000003.
In order to test the alarm function, the value is deliberately set to a small value. , when the website access delay exceeds this value, an alarm will be generated

Go to the dashboard to view alarms
Insert image description here

Note: There are many default monitoring templates. You can learn about the functions and parameters of the monitoring templates and how to use the templates by viewing the official documents. The official document link is:
https://www.zabbix.com/documentation/5.0/zh/manual/config /items/itemtypes/zabbix_agent
uses the monitoring template that comes with zabbix and needs to be used according to the official manual requirements. The parameters in <> are optional. If not set, the default parameters will be used. The default parameters are defined by the official; for example
:
net.if. in[ens33] The <mode> parameter is not used here. According to the official definition, the default value is the number of bytes.
Insert image description here

Guess you like

Origin blog.csdn.net/weixin_44178770/article/details/124621569