Basic concepts and deployment of zabbix monitoring

Basic concepts and deployment of zabbix monitoring

1. Introduction to zabbix

1.zabbix overview

  • Zabbix is ​​an enterprise-level open source solution that provides distributed system monitoring and network monitoring functions based on the Web
  • Zabbix can monitor various network parameters to ensure the safe operation of the server system; and provide a flexible notification mechanism to allow system administrators to quickly locate/solve various problems that exist
  • zabbix consists of two parts, zabbix server and optional component zabbix agent. Collect data through C/S mode, display and configure on the Web side through B/S mode
  • zabbix server can provide remote server/network status monitoring, data collection and other functions through SNMP, zabbix agent, ping, port monitoring and other methods, and it can run on platforms such as Linux
  • The zabbix agent needs to be installed on the monitored target server, which mainly completes the collection of hardware information or memory, CPU and other information related to the operating system

2. The monitoring principle of zabbix

The zabbix agent is installed on the monitored host. The zabbix agent is responsible for regularly collecting local data from the client and sending it to the zabbix server. After the zabbix server receives the data, it stores the data in the database. Users can see it based on Zabbix WEB Data presents images on the front end. When zabbix monitors a specific project, the project will set a trigger threshold. When the monitored indicator exceeds the threshold set by the trigger, some necessary actions will be taken, including: sending information (email, WeChat, SMS) ), sending commands (shell commands, reboot, restart, install, etc.)

3. Five common procedures

Zabbix monitoring is deployed in the system, including five common programs:

zabbix_ server、zabbix_ agent、zabbix _proxy、zabbix_get、zabbix_sende

  • zabbix server: zabbix server daemon process, in which the data of zabbix_ ​​agent. zabbix_ ​​get. zabbix_ ​​sender and zabbix_ ​​proxy are finally submitted to zabbix server
  • zabbix agent: client daemon, responsible for collecting client data, for example: collecting CPU load, memory, hard disk usage, etc.
  • zabbix proxy: zabbix distributed proxy daemon process, usually larger than 500 hosts, requires distributed monitoring architecture deployment
  • zabbix get: zabbix data receiving tool, a command used alone, usually executed on the server or proxy side to obtain the remote client information command
  • zaabix sender: zabbix data sending tool, the user sends data to the server or proxy end, usually the user takes a long time to check

4. Common architecture

Zabbix can adopt different common architectures for servers with different monitoring numbers

4.1. Server and client

  • It is suitable for monitoring less than 100 servers and a monitoring environment with relatively few devices. It is suitable for a relatively simple network, and it is best to be in a local area network
  • C/S architecture server-client

It is the simplest architecture of zabbix, that is, the monitoring machine and the monitored machine do not undergo any processing, and there is direct data exchange between zabbix server and zabbix agentd

Please add a picture description

4.2. Server-proxy server-client

  • Suitable for monitoring more than 100 servers,
  • server-proxy-client distributed architecture

The proxy is a communication bridge between the server and the client. The proxy itself does not have a front end, and the data that does not exist in itself is only temporarily stored in the data sent by agentd, and then submitted to the server. This architecture often cooperates with the manter-node-client architecture. The comparative architecture is generally applicable to the monitoring of medium-sized network architectures across computer rooms and across networks

Please add a picture description

4.3. manter-node-client architecture

  • Suitable for monitoring tens of thousands of servers

This architecture is the most complex monitoring architecture of zabbix. It is suitable for large-scale environments with many cross-network and cross-computer room devices. Each node has a server side at the same time. The node can be connected to the proxy or directly to the client. The node has its own Configuration files and databases, what needs to be done is to synchronize the configuration information and monitoring data to the master, the failure or damage of the master will affect the integrity of the architecture under the node

Please add a picture description

2. Deploy zabbix service

服务端:192.168.36.10

客户端:192.168.36.20

Server

Turn off the firewall and change the host name for easy identification

systemctl disable --now firewalld
setenforce 0
hostnamectl set-hostname zbx-server

Get the download source of zabbix

rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm 

Replace zabbix.repo with Ali source

cd /etc/yum.repos.d
sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' zabbix.repo
yum clean all && yum makecache

yum install -y zabbix-server-mysql zabbix-agent

Install SCL (Software Collections) to facilitate the subsequent installation of a higher version of php. The default version of php installed by yum is 5.4, which is too low. The minimum version of php for zabbix 5.0 is version 7.2.0. SCL enables multiple versions of software to be used on the same machine without affecting the dependencies of the entire system. Packages will be installed in the /opt/rh directory

yum install -y centos-release-scl

Modify the zabbix-front front-end source, install the zabbix front-end environment to the scl environment

vim zabbix.repo
......
[zabbix-frontend]
......
enabled=1          #开启安装源
......

yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl

Install the database required by zabbix

yum install -y mariadb-server mariadb

systemctl enable --now mariadb

mysql_secure_installation         #初始化数据库,并设置密码,如 abc123

Add database users and database information required by zabbix

mysql -u root -pabc123

CREATE DATABASE zabbix character set utf8 collate utf8_bin;
GRANT all ON zabbix.* TO 'zabbix'@'%' IDENTIFIED BY 'zabbix';
flush privileges;

Import database information

rpm -ql zabbix-server-mysql 		#查询 sql 文件的位置

zcat /usr/share/doc/zabbix-server-mysql-5.0.24/create.sql.gz | mysql -uroot -p123456 zabbix

Modify the zabbix server configuration file and modify the database password

vim /etc/zabbix/zabbix_server.conf 
......
DBPassword=zabbix					#124行,指定 zabbix 数据库的密码

Modify the php configuration file of zabbix

vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
......
php_value[date.timezone] = Asia/Shanghai		#24行,取消注释,修改时区

Start zabbix related services

systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm

Browser access 192.168.36.10

Follow the flow chart to complete the installation and login

Please add a picture description

Please add a picture description

Please add a picture description

Please add a picture description

Please add a picture description

Please add a picture description

Please add a picture description

Solve the Chinese garbled problem of zabbix-server Web page

yum install -y wqy-microhei-fonts

\cp -f /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf

Please add a picture description
Please add a picture description

Please add a picture description

Please add a picture description

client

The zabbix 5.0 version uses a new version of the client agent2 developed in the golang language.
The zabbix server zabbix_server uses port 10051 by default, and the client zabbix_agent2 uses port 10050 by default.

systemctl disable --now firewalld
setenforce 0

Both server and client configure time synchronization

yum install -y ntpdate
ntpdate -u ntp.aliyun.com

The client configures the time zone to be consistent with the server

mv /etc/localtime{,.bak}
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

Set the download source of zabbix and install zabbix-agent2

rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm 

cd /etc/yum.repos.d
sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo

yum install -y zabbix-agent2

Modify the agent2 configuration file

vim /etc/zabbix/zabbix_agent2.conf
......
Server=192.168.36.10			#80行,指定 zabbix 服务端的 IP 地址
ServerActive=192.168.36.10		#120行,指定 zabbix 服务端的 IP 地址
Hostname=zbx-agent01			#131行,指定当前 zabbix 客户端的主机名

Start zabbix-agent2

systemctl start zabbix-agent2
systemctl enable zabbix-agent2

netstat -natp | grep zabbix
tcp6       0      0 :::10050                :::*                    LISTEN      43654/zabbix_agent2 

Verify the connectivity of zabbix-agent2 on the server side

yum install -y zabbix-get				#安装 zabbix 主动获取数据的命令

zabbix_get -s '192.168.36.20' -p 10050 -k 'agent.ping'
1

zabbix_get -s '192.168.36.20' -p 10050 -k 'system.hostname'
zbx-agent01

Add agent host on the web page
Click [Host] in [Configuration] on the left menu bar, click [Create Host]
[Host Name] is set to zbx-agent01
[Visible Name] is set to zbx-agent01-192.168.36.20
[Group] Group] select Linux server
[Interfaces] [IP address] set to 192.168.36.20

Then click [Template] on the upper menu bar
[Link new tampels] to search for Linux, select Template OS Linux by Zabbix agent
and click [Add]

Guess you like

Origin blog.csdn.net/liwenbin19920922/article/details/126902013