当前位置:网站首页>ZABBIX enterprise distributed monitoring

ZABBIX enterprise distributed monitoring

2022-06-24 05:46:00 Extraordinary

One . Prepare the environment

1.  Environment initialization

(1) Configure the domain name

hostnamectl set-hostname  server
hostnamectl set-hostname  agent01
hostnamectl set-hostname  agent02

cat > /etc/hosts << EOF
192.168.10.1 server
192.168.10.2 agent01
192.168.10.3 agent02
EOF

(2) Turn off firewall , Close the kernel ,

systemctl stop firewalld  && systemctl disable firewalld
setenforce 0	&& sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

(3) Time synchronization

yum install chrony -y 
systemctl enable chronyd 
systemctl start chronyd 
chronyc sources

2.yum Source installation

 wget -O /etc/yum.repos.d/aliyun.base.repo http://mirrors.aliyun.com/repo/Centos-7.repo http://mirrors.aliyun.com/repo/Centos-7.repo
 rpm -Uvh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
 rpm -Uvh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm

Two . install MySQL

1. stay server Install the database on the host

yum install -y mariadb-server 
systemctl start mariadb 
systemctl enable mariadb 
 It is also possible to install MySQL For the first time, the database lets you set the password , The order is as follows :
ph
 First, set the password , You will be prompted to enter the password first 
Enter current password for root (enter for none):<– First run direct return 
 Set the password 
Set root password? [Y/n] <–  Whether to set up root User password , Input y And enter or directly enter 
New password: <–  Set up root User's password 
Re-enter new password: <–  Enter your password again 
 Other configuration 
Remove anonymous users? [Y/n] <–  Whether to delete anonymous users , enter 
Disallow root login remotely? [Y/n] <– Whether to ban root Remote login , enter ,
Remove test database and access to it? [Y/n] <–  Whether or not to delete test database , enter 
Reload privilege tables now? [Y/n] <–  Whether to reload the permission table , enter 
 initialization MariaDB complete , Next, test login 
mysql -uroot -ppassword
 complete .

2. Sign in mysql Create database and authorize

 mysql 			## The initial password is empty 
mysql> CREATE DATABASE zabbix character set utf8 collate utf8_bin;
 CREATE DATABASE zabbix_proxy character set utf8 collate utf8_bin; 
 USE mysql;

UPDATE mysql.user SET password = PASSWORD('zabbix') WHERE user = 'root';  ## Set up root  The account password is 'zabbix'
mysql> GRANT ALL PRIVILEGES ON zabbix.* TO [email protected]'localhost' IDENTIFIED BY 'zabbix'; ## to grant authorization zabbix  Account password 'zabbix' Local access  zabbix  database 
mysql> GRANT ALL PRIVILEGES ON zabbix.* TO [email protected]'%' IDENTIFIED BY 'zabbix';  ## to grant authorization zabbix  Account password 'zabbix' The remote access  zabbix  database 

mysql>GRANT ALL PRIVILEGES ON zabbix_proxy.* TO 'zabbix'@'localhost' IDENTIFIED BY 'zabbix';  ## to grant authorization zabbix  Account password 'zabbix' Local access  zabbix\_proxy  database 

mysql>GRANT ALL PRIVILEGES ON zabbix_proxy.* TO 'zabbix'@'%' IDENTIFIED BY 'zabbix';  ## to grant authorization zabbix  Account password 'zabbix' The remote access  zabbix\_proxy  database 

mysql> FLUSH PRIVILEGES;

mysql> quit;

3、 ... and . Deploy LNMP + Zabbix Server

stay Ministry office Zabbix Server And front , The first First want with Set up LNMP Ring habitat , LNMP yes Linux+Nginx+MySQL+PHP Abbreviation , yes Linux It is commonly used in the system php Scripting language running environment .

1 .  install Nginx  And php-fpm

[email protected]~# yum install -y epel-release
[email protected]~# yum install -y nginx php-fpm

2 .  The installation is based on MySQL  Of Zabbix Server  and Zabbix Web

[email protected]~#  yum install -y zabbix-server-mysql-3.2.11   zabbix-web-mysql

3 .  initialization Zabbix  database

[email protected]~# zcat /usr/share/doc/zabbix-server-mysql-3.2.*/create.sql.gz | mysql -uzabbix -p zabbix 

4 .  edit Zabbix Server  The configuration file , Modify database connection information  

[email protected]~# vim /etc/zabbix/zabbix_server.conf
DBHost=localhost 
DBName=zabbix 
DBUser=zabbix
DBPassword=<password> 		## Enter the actual database account password here , In this case  zabbix

 `

5 .  start-up zabbix-server

[email protected]~# systemctl start zabbix-server 
[email protected]~# systemctl enable zabbix-server

6 .  edit Nginx  The configuration file

stay Nginx In profile , Add the contents of the following table line numbers , add to php Module support .

[email protected]~# vim /etc/nginx/nginx.conf
user nginx;
worker\\_processes auto; 
error\\_log /var/log/nginx/error.log; 
pid /run/nginx.pid;
#Load dynamic modules. See /usr/share/nginx/README.dynamic. 
include /usr/share/nginx/modules/\\*.conf;
events {
   worker\\_connections 1024;
} 
http { 
log\\_format main '$remote\\_addr - $remote\\_user $time\\_local "$request" ' 
                  '$status $body\\_bytes\\_sent "$http\\_referer" ' 
                  '"$http\\_user\\_agent" "$http\\_x\\_forwarded\\_for"';
access\\_log /var/log/nginx/access.log main; 

sendfile on;
tcp\\_nopush on;
tcp\\_nodelay on; 
keepalive\\_timeout 65;
types\\_hash\\_max\\_size 2048;
include /etc/nginx/mime.types; 
default_type application/octet-stream;
Load modular configuration files from the /etc/nginx/conf.d directory. 
# See [http://nginx.org/en/docs/ngx\\_core\\_module.html#include](http://nginx.org/en/docs/ngx_core_module.html#include)for more information.include /etc/nginx/conf.d/\\*.conf; 
server {
   listen 80 defaultserver;
   listen :::80 default\\_server;
   server_name ;

   index index.html index.php;		         ##42 That's ok 

   root /usr/share/nginx/html;
#Load configuration files for the default server block. 
include /etc/nginx/default.d/\\*.conf;
location / {
} 

 location ~ .php$  {                              ##47 That's ok 
            fastcgi_pass   127.0.0.1:9000;            ##48 That's ok 
            fastcgi_index  index.php;                  ##49 That's ok 
            fastcgi_split_path_info ^(.+\.php)(/.+)$;   ##50 That's ok 
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;   ##51 That's ok 
            fastcgi_param  PATH_INFO  $fastcgi_path_info;                        ##52 That's ok 
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;   ##53 That's ok 
            include        fastcgi_params;                                       ##54 That's ok 
        }                                                                        ##55 That's ok 
   

error\\_page 404 /404.html; location = /40x.html {

}

error\\_page 500 502 503 504 /50x.html; location = /50x.html {

}

}

}

7 .  edit php.ini  file

stay php.ini In file , Modify the following configuration items .

[email protected]~# vim /etc/php.ini 
post_max_size = 16M 				##672 That's ok 
max_execution_time = 300			##384
max_input_time = 300 				##394
memory_limit = 128M 				##405
upload_max_filesize = 2M 			##800
date.timezone = Asia/Shanghai		##878

 `

8 .  Copy Web  Catalog

Copy Zabbix Server Of Web Directory to Nginx Home directory .

[email protected]~# cp -rp /usr/share/zabbix /usr/share/nginx/html/

 `

9 .  start-up Nginx  And php-fpm

[email protected]~# systemctl start nginx php-fpm
[email protected]~# systemctl enable nginx php-fpm

 `

10 .  install Zabbix Web  End

Access in a browser http://192.168.10.1/zabbix/index.php, Will enter into Zabbix Install the boot page .

3.  Detect configuration items

Click on “NextStep” Button ,Zabbix It will automatically detect the php Configuration item . Show “OK” Indicates that the test passed ; Show “Fail” Indicates that the detection failed . here , Users can continue to modify according to the suggested value php.ini file , And then restart php-fpm service , And refresh the page , Continue with the installation steps , Pictured 1.4 Shown .

chart 1.4 Automatically detect dependent php Configuration item

4.  Fill in the configuration

If all tests pass , Click on “NextStep” Button , Enter the database configuration page , And fill in the correct configuration , Pictured

5.  Set up Zabbix Server  Host name, port and other information

Click on “NextStep” Button , Enter the details setting page . You can set Zabbix Server Host name, port and other information , Keep the default , Pictured 1.6 Shown .

6.  Information confirmation

Click on “NextStep” Button , Enter the information confirmation page , Pictured 1.7 Shown .

chart 1.7 Information confirmation

7.  Complete the installation

Click on “NextStep” Button , Enter the installation completion page , Pictured 1.8 Shown .

chart 1.8 Complete the installation

8.  Enter the login page

Click on “Finish” Button , Get into Zabbix Web The login page , Pictured 1.9 Shown .

chart 1.9 The login page

9.  Enter the monitoring instrument page

Enter the default user name / password :Admin/zabbix, After logging in , Enter the monitoring instrument page , Pictured 1.10 the in .

chart 1.6 Set up Zabbix Server Host name and port information of

chart 1.10 Monitoring instrument page

10.  Change the page language and login password

Click the administrator icon in the upper right corner of the monitoring instrument page , Enter the administrator settings page , Pictured 1.11 Shown .

chart 1.11 Change the page language and login password

They are shown in the figure 1.11 Of Password and Language Change the administrator password and page language . After the modification is completed , Click on “Update” Button , Change the page language to Chinese information , Pictured 1.12 Shown .

chart 1.12 Chinese interface

1.1.1  Deploy Zabbix Agent 192.168.10.2

The following is the 192.168.10.2 Installation on 、 Deploy Zabbix Agent Steps for .

1.  install Zabbix Agent

Execute the following command , install Zabbix Agent Software .

rpm -Uvh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
yum install -y zabbix-agent

2.  edit Zabbix Agent  The configuration file

Zabbix Agent In profile , Modify the following configuration items :

[[email protected]~]# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.10.1			##95 That's ok 
ServerActive=192.168.10.1		##134 That's ok 
Hostname=agent01	 #Agent  Local name , This name needs to be the same as  server  Terminal  Web  The host names on the page are consistent , Name customization 

3.  start-up Zabbix Agent

[[email protected]~]# systemctl start zabbix-agent.service 
systemctl enable zabbix-agent.service

1.1.2  Deploy Zabbix Proxy 192.168.10.3

stay 192.168.10.3 On , The installation is based on MySQL Of Zabbix Proxy.

1.  The installation is based on MySQL  Of Zabbix Proxy

rpm -Uvh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm
[[email protected]~]# yum install -y zabbix-proxy-mysql

Zabbix The database initialization commands are as follows .

[[email protected]~]#yum install -y mysql &&   zcat /usr/share/doc/zabbix-proxy-mysql-3.2.*/schema.sql.gz | mysql -h192.168.10.1 -uzabbix zabbix_proxy -p

2.  edit Zabbix Proxy  The configuration file

edit Zabbix Proxy The configuration file , Modify the following information .

[[email protected]~]# vim /etc/zabbix/zabbix_proxy.conf 
Server=192.168.10.1
Hostname=zabbix proxy	##Proxy  Local name , This name needs to be in the future  server  Terminal Web  Proxy on page 
 The program names are consistent , Name customization 
DBHost=192.168.10.1			##128 That's ok 
DBName=zabbix_proxy 		##167
DBUser=zabbix				##182
DBPassword= 			## Enter the actual password , In this experiment  zabbix 
DBPort=3306

3.  start-up zabbix-proxy

[[email protected]~]# systemctl start zabbix-proxy
 systemctl enable zabbix-proxy

1.  install Zabbix Agent 192.168.10.3

stay 192.168.10.3 Installed on the host agent, Operating procedures and 192.168.10.2 identical . modify Zabbix Agent The contents of the configuration file are as follows :

yum install -y zabbix-agent
[[email protected]~]# vim /etc/zabbix/zabbix_agentd.conf 
Server=192.168.10.3		# Point to  Proxy  Address 		97 That's ok 
ServerActive=192.168.10.3 	# Point to  Proxy  Address 		
Hostname=aget02	 #Agent  Local name , Need and future in  Server  Terminal  Web  The host names on the page are consistent , Name customization 
systemctl start  zabbix-agent.service
 systemctl enable  zabbix-agent.service

1.1.1 Zabbix Web  The front-end configuration

Zabbix Web The front-end configuration , Is in Zabbix Server Of Web Specific monitoring configuration of the management interface . It is divided into adding hosts 、 Add host group 、 To configure Proxy、 Define monitoring items and so on . Let's start with “ Add host ” To configure .

1.  Add host

stay Web Select... In the interface : To configure , host à, Create a host , Pictured 1.13 Shown .

chart 1.13 Create a host

According to the figure 1.14 Instructions in , Fill in client related information .

chart 1.14 Fill in client related information

After filling in the client information, select “ Templates ” tab , Select a monitoring template for the client host , Pictured 1.15 the in .

chart 1.15 Select monitoring template

Check the appropriate template for the client host , And click the “ choice ” Button , Pictured 1.16 Shown .

chart 1.16 Select template

In turn, click “ add to ” Button and “ to update ” Button , Complete the addition of the client host , Pictured 1.17 Shown .

chart 1.17 Update template

After adding, return to the host list , Green on the right “ZBX” Represents the successful addition . If it's red “ZBX” It means that the addition failed , Now move the mouse to red “ZBX” There will be specific prompt information on the , Pictured 1.18 Shown .

chart 1.18 Host added successfully

2.  Add host group

stay Web Select... On the page : To configure , Host group , Create a host group , Pictured 1.19 Shown .

chart 1.19 Create a host group

Fill in the group name and select the group members , Pictured 1.20 Shown .

chart 1.20 Fill in the group name and select the group members

3.  To configure Proxy

(1)  add to Proxy

stay Web Select... In the interface : management àagent agent à To create the agent , Pictured 1.21 Shown .

chart 1.21 To create the agent

Fill in Proxy Host name , And click the “ add to ” Button , complete Proxy establish , Pictured 1.22 Shown

chart 1.22 Complete agent creation

(2)  add to Agent  host

Add steps and 192.168.10.2 identical , On the host page, select use agent Agent monitoring , Pictured

chart 1.23 add to agent host

4.  Custom monitor 、 Triggers and monitoring templates

(1)  Create monitor item

In turn, click “ To configure ” à“ host ”, On the host to be configured column , Click on “ Monitoring item ”, Pictured 1.24 Shown .

chart 1.24 Ready to set monitoring items

Click on “ Create monitor item ”, Pictured 1.25 Shown .

chart 1.25 Create monitor item

Fill in relevant information of monitoring items , And click the “ add to ” Button to complete the creation of monitoring items , Pictured 1.26 Shown .

chart 1.26 Complete the creation of monitoring items

After successful addition , The list of monitoring items will appear “CpuNum” Monitoring item , Pictured 1.27 Shown .

chart 1.27 Monitoring item list information

(2)  Create trigger

chart 1.28 Ready to create trigger

In turn, click “ To configure ”à“ host ”, On the host to be configured column , Click on “ trigger ”, Pictured 1.28 Shown .

Click on “ Create trigger ”, Pictured 1.29 Shown .

chart 1.29 Create trigger

According to the figure 1.30 Instructions in , Fill in trigger related information .

chart 1.30 Fill in trigger related information

Once created , In the trigger list, you can see “{192.168.10.2:system.cpu.util[,idle].avg(1m)}<15”, Pictured 1.31 Shown .

chart 1.31 Created trigger information list

1.1.1 Zabbix  The main function

Zabbix Can monitor Windows、Linux And other host operating systems , It can also monitor common application systems , such as Web System 、 Mail system, etc. . Now monitor from the server 、SSH Application monitoring 、Web System monitoring 、 Several aspects of network topology configuration , Give an example to explain Zabbix Common features of .

1.  Server monitoring

Linux Basic server monitoring items exist in the template Template OS Linux in , Simply associate the client host with the template , The basic monitoring of the server can be realized . In this example, both client hosts have been associated with this template .

2.  Application monitoring

To monitor sshd For example , First create a monitor item , monitor sshd The number of processes , Pictured 1.36 Shown .

chart 1.36 Create program monitoring items

secondly , Create trigger , When the number of processes is less than 1 An exception event is triggered when . Click Configure in turn à host à touch Hair apparatus , Select Create trigger , Pictured 1.37 Shown .

chart 1.37 Create trigger
原网站

版权声明
本文为[Extraordinary]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/08/20210804144345136j.html

随机推荐