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

CentOS 7.7 yum installation and configuration Zabbix 4.0 LTS details (1)

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

Share

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

1. Introduction to Zabbix-related knowledge:

1. The dimension of monitoring:

Monitoring content

Monitoring mode

Physical hardware: CPU temperature, motherboard temperature, fan speed, voltage, power, etc.

IPMI, computer room inspection

Operating system: CPU load, memory utilization, disk utilization, disk Imax O, network card traffic, etc.

Linux template

Application software: Nginx, php-fpm, Redis, MySQL, Tomcat, etc.

Customize open source templates

Business: business status, web speed, PV, UV, IP, number of active users, daily transaction volume, etc.

Tencent Analytics, Matomo, etc.

Switches, routers, UPS and other network equipment

SNMP

Journal

ELK 、 GoAccess 、 AWStats

Explanation: explanation of PV, UV, IP nouns

PV:Page View, the number of visits, that is, the number of page views or clicks, measures the number of pages visited by website users. In a certain statistical period, users record every page they open or refresh, and the number of page views accumulated when they open or refresh the same page many times.

UV:Unique Visitor, an independent visitor, counts the number of users visiting a site in one day (based on cookie). A computer client visiting a website is a visitor, which can be understood as the number of computers visiting a website. The website judges the identity of the visiting computer through the cookies of the visiting computer. If you change the IP but do not clear the cookies, and then visit the same website, the number of UV in the website statistics is unchanged. If the user does not save the cookies access, clears the cookies, or changes device access, the count will add up to 1 single visitor for multiple visits to the same client within the period of 00-24:00.

IP:Internet Protocol, the number of independent IP, refers to the number of independent IP browsing pages in a day, that is, statistics of the number of different IP browsing users. No matter how many pages the same IP visits, the number of independent IP is 1. Different IP browsing pages will be counted and added. IP IP is based on the user's WAN IP address to distinguish different visitors. Multiple users (multiple LAN IP) surf the Internet in the same router (the same WAN IP). It may be recorded as a single IP visitor, and if the user keeps changing IP, it may be counted multiple times.

2. Zabbix components:

(1) Zabbix Server: responsible for receiving report information sent by Zabbix Agent or Zabbix Proxy, and responsible for organizing configuration information, statistical information and operation data, etc.

(2) Zabbix Database: a database used to store configuration information and monitoring data of all Zabbix, including monitoring data

A. Historical data: the result of each sample is kept for a relatively short time.

B. trend data: aggregate data and save data over a relatively long period

(3) the GUI interface of Zabbix Web:Zabbix. Administrators manage Zabbix configuration and view Zabbix-related monitoring information through the Web interface, which can be deployed on separate servers.

(4) Zabbix Agent: deployed on the monitored host, responsible for collecting the data of the monitored host and sending it to Zabbix Server or Zabbix Proxy.

(5) Zabbix Proxy: optional component for distributed monitoring environment, which collects monitoring data of Zabbix Agent in local areas and sends them to Zabbix Server.

Note: in general, Zabbix Agent is deployed on the monitored host to collect data and report to the central host responsible for monitoring, which is the master in the master/agent model. The central host responsible for monitoring is called Zabbix Server,Zabbix Server. The information received from Zabbix Agent is stored in Zabbix Database. If the administrator needs to view all kinds of monitoring information, it needs to use Zabbix Web written by PHP, and depends on the LAMP environment, whether it is Zabbix Server. Or Zabbix Web, you need to connect to Zabbix Database to get the relevant data.

3. Common terms of Zabbix:

(1) host: host, the object to be monitored by Zabbix, and the host must belong to a host group.

(2) host group: host group, which is a logical unit composed of multiple hosts with the same attributes, characteristics and roles.

(3) item: monitoring items, data related to a specific monitoring indicator, which come from monitored objects. Monitoring items are the core of data collection in Zabbix. Without monitoring items, there will be no data. Relative to a monitoring object, each monitoring item is identified by "key".

(4) key: key. If you want to obtain the data corresponding to the monitoring item, you must obtain it through a key. There are some key in Zabbix. These key are often more general. Through these key, you can monitor CPU, memory, hard disk and other common metrics, and obtain different metric information. But if these built-in key can not meet the monitoring needs, you can also customize key and perform corresponding operations through custom key.

(5) trigger: trigger, an expression used to evaluate whether the data received in a particular item of a monitoring object is within its reasonable range, that is, the threshold. When the amount of data received reaches the threshold, the state of the trigger will change from "OK" to "Problem". When the amount of data returns to a reasonable range, its state will change from "Problem" to "OK".

(6) event: event, when the state of the trigger changes, the corresponding event will be generated. The event caused by the change of the state of the trigger is called "trigger event". In Zabbix, the event is divided into trigger event, auto-discovery event, auto-registration event and internal event.

(7) action: an action, which refers to a pre-defined method of handling a specific event, including an action (such as sending a notification) and a condition (when the action is performed).

(8) escalation: a custom scheme for upgrading alarms, sending alarms or executing remote commands, such as sending alarms every 5 minutes for a total of 5 times, etc.

(9) media: a medium, a means or channel for sending notifications, such as Email, Jabber, or SMS.

(10) notification: notification that sends information about an event to the user through a selected medium.

(11) remote command: remote commands, predefined commands that can be executed automatically when the monitored host is under certain conditions.

(12) template: template, which is used to quickly define a set of preset entries for a monitored host, usually including item, trigger, graph, screen, application and low-level discovery rule. The template can be linked directly to a single host.

(13) application: application, a collection of item.

(14) web scennario:web scenario, one or more HTTP requests used to detect the availability of a web site.

(15) frontend: front end, web interface of Zabbix.

4. The communication methods supported by Zabbix:

(1) Agent: monitor through a dedicated agent, which is similar to the common master/agent model. If the monitored object supports the corresponding Agent, this method is recommended.

(2) SSH/Telnet: communicate through remote control protocol.

(3) SNMP:Simple Network Management Protocol, simple network management protocol, communicates with monitored objects through SNMP protocol. It is usually impossible to install Agent on hardware such as routers and switches, but these hardware often support SNMP protocol. SNMP is a relatively old and popular protocol, and most network devices support this protocol. In fact, the working mode of SNMP protocol can also be understood as the working mode of master/agent. It's just that SNMP's Agent is built into these devices.

(4) IPMI:Intelligent Platform Management Interface, the intelligent platform management interface, can be monitored through the IPMI interface, and the physical characteristics of the monitored object can be monitored through the standard IPMI hardware interface, such as voltage, temperature, fan status, power supply status and so on.

(5) JMX:Java Management Extensions,Java management extension, which is more commonly used when monitoring JVM virtual machines.

5. The working mode of Zabbix:

(1) active mode: Zabbix Agent will actively send the collected data to Zabbix Server, which can reduce the pressure on Zabbix Server.

(2) passive mode: Zabbix Agent does not send data actively, but waits for Zabbix Server to pull data. The default mode is passive mode.

Description: no matter it is active mode or passive mode, it is for Zabbix Agent, active mode and passive mode can coexist.

2. Preparatory work:

1. Zabbix version selection: https://www.zabbix.com/life_cycle_and_release_policy

Note: it is recommended to choose LTS (Long Term Support, long-term support) version.

2. Related website:

(1) Zabbix download address: https://www.zabbix.com/download/

(2) Zabbix 4.0LTS Chinese product manual: https://www.zabbix.com/documentation/4.0/zh/manual

3. Demo environment:

IP

Operating system

Hostnam

Role

192.168.0.120

CentOS 7.7 x86_64

Zabbix-server

Zabbix Database 、 Zabbix Server 、 Zabbix Web 、 Zabbix Agent

192.168.0.121

CentOS 7.7 x86_64

Sh-proxy

Zabbix Proxy

192.168.0.122

CentOS 7.7 x86_64

Node-122

Zabbix Agent

192.168.0.130

Windows Server 2012 R2

Node-130

Zabbix Agent

4. All CentOS nodes perform the following operations:

(1) close SELinux and firewalld

(2) configure server time synchronization

(3) configure hostname

(4) configure hosts file:

# vim / etc/hosts

192.168.0.120 zabbix-server

192.168.0.121 sh-proxy

192.168.0.122 node-122

(5) configure Epel source: # rpm-ivh https://mirrors.tuna.tsinghua.edu.cn/epel/epel-release-latest-7.noarch.rpm

(6) configure the yum source of Zabbix:

# rpm-ivh https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm

# rpm-ql zabbix-release

# cat / dev/null > / etc/yum.repos.d/zabbix.repo

# vim / etc/yum.repos.d/zabbix.repo

[aliyun-zabbix]

Name=Aliyun Zabbix Repository-$basearch

Baseurl= https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/$basearch/

Enabled=1

Gpgcheck=1

Gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[aliyun-zabbix-non-supported]

Name=Aliyun Zabbix Repository non-supported-$basearch

Baseurl= https://mirrors.aliyun.com/zabbix/non-supported/rhel/7/$basearch/

Enabled=1

Gpgcheck=1

Gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX

5. Zabbix-server nodes build LAMP environment:

Note: Zabbix Web depends on the LAMP environment. When installing the zabbix-web-mysql (4.0.14) software package, httpd (2.4.6), PHP (5.4.16), zabbix-web (4.0.14) and other related software packages are automatically installed by default. Yum is used here to install PHP version 7.2. The version of MariaDB in CentOS 7.7 is 5.5.64, which is lower. When you import the create.sql file after upgrading to MariaDB 10.4, you will be prompted "ERROR 1118 (42000) at line 1278: Row size too large (> 8126). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline.", so Zabbix Database uses MySQL 5.7. Httpd is not installed separately here, and Zabbix Database, Zabbix Server and Zabbix Web are all deployed on the zabbix-server node, which can be deployed separately in the actual production environment.

(1) install and configure MySQL 5.7:

A. Check whether MariaDB already exists in the system:

# rpm-qa | grep-I mariadb--> mariadb-libs-5.5.64-1.el7.x86_64

# yum-y remove mariadb-libs

B. Install mysql57-community-release-el7.rpm:

# rpm-ivh http://repo.mysql.com/mysql57-community-release-el7.rpm

Note: mysql-community-source.repo and mysql-community.repo will be generated in the / etc/yum.repos.d directory after installation

C. Install MySQL 5.7related software packages:

# yum list all | grep mysql-community

# yum-y install mysql-community-client mysql-community-common mysql-community-devel mysql-community-libs mysql-community-libs-compat mysql-community-server mysql-community-test

D. Initialize MySQL 5.7 user=mysql # mysqld-- initialize-- user=mysql-- datadir=/var/lib/mysql

Note: make sure the / var/lib/mysql directory is empty before initialization

E. Modify the my.cnf configuration file:

# mv / etc/my.cnf / etc/my.cnf.bak

# vim / etc/my.cnf

[mysqld]

Port=3306

Socket=/var/lib/mysql/mysql.sock

Datadir=/var/lib/mysql

Pid-file=/var/run/mysqld/mysqld.pid

Log-error=/var/log/mysqld.log

Lower_case_table_names=1

Character_set_server=utf8mb4

Collation_server=utf8mb4_general_ci

Innodb_file_per_table=1

Skip_name_resolve=1

Slow_query_log=1

Slow_query_log_file=mysql-slow.log

Symbolic-links=0

Explicit_defaults_for_timestamp=1

Server_id=1

Sync_binlog=1

Innodb_flush_log_at_trx_commit=1

Log_bin=mysql-bin

Log_bin_index=mysql-bin.index

Binlog_format=row

F. Start MySQL:

# systemctl start mysqld

# systemctl status mysqld

# ps aux | grep mysqld

# ss-tunlp | grep-w: 3306

# tail-100 / var/log/mysqld.log

G. Configure self-boot: # systemctl enable mysqld

H. Check the initial password of the root@localhost user: # grep password / var/log/mysqld.log

I. Configure Security Wizard: # mysql_secure_installation

J. Authorize root users to log in remotely:

# mysql-uroot-p

Mysql > create user root@'192.168.0.%' identified by '123456'

Mysql > grant all on *. * to root@'192.168.0.%'

Mysql > flush privileges

(2) install and configure PHP 7.2:

A. Install webtatic-release.rpm:# rpm-ivh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

B. Install PHP 7.2 related software packages:

# yum list all | grep php

# yum-y install mod_php72w php72w-cli php72w-common php72w-devel php72w-fpm php72w-gd php72w-ldap php72w-mbstring php72w-mysqlnd php72w-opcache php72w-xml

C. Check the PHP version: # php-version

3. Zabbix-server node deploys Zabbix Server, Zabbix Web and Zabbix Agent:

1. Deploy Zabbix Server:

(1) install zabbix-server-mysql package: # yum-y install zabbix-server-mysql

(2) check the Zabbix Server version: # zabbix_server-V

(3) create zabbix database and 'zbxuser'@'192.168.0.%' user, and authorize' zbxuser'@'192.168.0.%' user to manage remotely:

# mysql-uroot-p

Mysql > create database zabbix character set utf8 collate utf8_bin

Mysql > create user' zbxuser'@'192.168.0.%' identified by '123456'

Mysql > grant all on zabbix.* to 'zbxuser'@'192.168.0.%'

Mysql > flush privileges

(4) Import the create.sql file and initialize the zabbix database (choose one of the following methods):

# zcat / usr/share/doc/zabbix-server-mysql-4.0.14/create.sql.gz | mysql- uzbxuser-h292.168.0.120-p zabbix

Or

# gzip-d / usr/share/doc/zabbix-server-mysql-4.0.14/create.sql.gz

Mysql > use zabbix

Mysql > source / usr/share/doc/zabbix-server-mysql-4.0.14/create.sql

Or

# gzip-d / usr/share/doc/zabbix-server-mysql-4.0.14/create.sql.gz

# mysql-uzbxuser-h292.168.0.120-p zabbix

< /usr/share/doc/zabbix-server-mysql-4.0.14/create.sql 备注:gzip -d执行后自动删除create.sql.gz文件,保留解压后的create.sql文件 (5)检查zabbix数据库中是否创建了表: # mysql -uzbxuser -h292.168.0.120 -p123456 -e 'use zabbix; show tables;' 2>

/ dev/null | wc-l

(6) modify the zabbix_server.conf configuration file:

# rpm-ql zabbix-server-mysql

# cd / etc/zabbix

# cp zabbix_server.conf {, .bak}

# vim zabbix_server.conf

Before modification

After modification

# ListenPort=10051

ListenPort=10051

# LogType=file

LogType=file

LogFile=/var/log/zabbix/zabbix_server.log

Keep the default

LogFileSize=0

Keep the default

PidFile=/var/run/zabbix/zabbix_server.pid

Keep the default

# DBHost=localhost

DBHost=192.168.0.120

DBName=zabbix

Keep the default

DBUser=zabbix

DBUser=zbxuser

# DBPassword=

DBPassword=123456

# DBSocket=

DBSocket=/var/lib/mysql/mysql.sock

# DBPort=

DBPort=3306

# ListenIP=127.0.0.1

ListenIP=192.168.0.120

AlertScriptsPath=/usr/lib/zabbix/alertscripts

Keep the default

ExternalScripts=/usr/lib/zabbix/externalscripts

Keep the default

# FpingLocation=/usr/sbin/fping

FpingLocation=/usr/sbin/fping

# AllowRoot=0

AllowRoot=0

# User=zabbix

User=zabbix

(7) start Zabbix Server:

# systemctl start zabbix-server

# systemctl status zabbix-server

# ps aux | grep zabbix_server

# ss-tunlp | grep-w 10051

# tail-100 / var/log/zabbix/zabbix_server.log

(8) configure self-boot: # systemctl enable zabbix-server

2. Deploy Zabbix Web:

(1) install zabbix-web-mysql package: # yum-y install zabbix-web-mysql

(2) modify the httpd.conf configuration file:

# vim / etc/httpd/conf/httpd.conf

Before modification

After modification

# ServerName www.example.com:80

ServerName 192.168.0.120:80

(3) start httpd:

# systemctl start httpd

# systemctl status httpd

# ps aux | grep httpd

# ss-tunlp | grep-w: 80

(4) configure self-boot: # systemctl enable httpd

(5) browsers access http://192.168.0.120/zabbix

Note: / etc/httpd/conf.d/zabbix.conf configuration file has been optimized for PHP 5.4.But PHP 7.2is currently installed and / etc/php.ini configuration file needs to be modified. Zabbix-related PHP pages are all stored in the / usr/share/zabbix directory.

# vim / etc/php.ini

Before modification

After modification

Post_max_size = 8m

Post_max_size = 16m

Max_execution_time = 30

Max_execution_time = 300

Max_input_time = 60

Max_input_time = 300

; date.timezone =

Date.timezone = Asia/Shanghai

Restart httpd:# systemctl restart httpd

Refresh the page, all check items must be "OK" to continue:

Configuration file generated after installation: / etc/zabbix/web/zabbix.conf.php

Log in to Zabbix Web, user name Admin, password zabbix:

3. Simple configuration of Zabbix Web:

(1) modify the default password of Admin user:

Administration-- > Users-- > Admin-- > Change password-- > enter the new password root@123-- > Update twice

New password: root@123

Log out and log back in

(2) disable guest users:

Administration-- > User groups-- > check Guests group-- > Disable

Administration-- > Users-- > guest user's status has changed to Disabled

(3) modify the interval between refreshing unsupported items:

Administration-- > General-- > Other-- > Refresh unsupported items default 10m is modified to 30s-- > Update

(4) adjust the number of rows displayed per page. The default is 50 rows:

Upper right corner Admin-- > User-- > Rows per page-- > Update

(5) enable the voice of the frontend message:

Upper right corner Admin-- > Messaging-- > Frontend messaging-- > Update

4. Deploy Zabbix Agent:

Note: the above monitoring prompt appears because the zabbix-server node does not have Zabbix Agent installed

(1) install zabbix-agent package: # yum-y install zabbix-agent

(2) modify the zabbix_agentd.conf configuration file:

# cd / etc/zabbix

# cp zabbix_agentd.conf {, .bak}

# vim zabbix_agentd.conf

Before modification

After modification

PidFile=/var/run/zabbix/zabbix_agentd.pid

Keep the default

# LogType=file

LogType=file

LogFile=/var/log/zabbix/zabbix_agentd.log

Keep the default

LogFileSize=0

Keep the default

# EnableRemoteCommands=0

EnableRemoteCommands=1

Server=127.0.0.1

Server=192.168.0.120

# ListenPort=10050

ListenPort=10050

# ListenIP=0.0.0.0

ListenIP=192.168.0.120

ServerActive=127.0.0.1

ServerActive=192.168.0.120

Hostname=Zabbix server

Hostname=zabbix-server

# AllowRoot=0

AllowRoot=0

# User=zabbix

User=zabbix

Include=/etc/zabbix/zabbix_agentd.d/*.conf

Keep the default

# UnsafeUserParameters=0

UnsafeUserParameters=1

Description:

Server: used in passive mode to specify which Zabbix Server is allowed to actively pull data from the current Zabbix Agent. This IP is the IP of Zabbix Server and implements IP-based access control. If there are multiple IP, use comma separation.

ServerActive: used in active mode to specify which Zabbix Server the Zabbix Agent will actively push the information to. If there are multiple IP, use a comma to separate it.

(3) start Zabbix Agent:

# systemctl start zabbix-agent

# systemctl status zabbix-agent

# ps aux | grep zabbix_agent

# ss-tunlp | grep-w 10050

# tail-100 / var/log/zabbix/zabbix_agentd.log

(4) configure self-boot: # systemctl enable zabbix-agent

5. Configure Zabbix Web:

Configuration-- > Hosts-- > Zabbix server-- > Update

Before modification

After modification

Host name: Zabbix server

Host name: zabbix-server

Visible name:

Visible name: Zabbix server

IP address: 127.0.0.1

IP address: 192.168.0.120

Note: the Hostname value in the above Zabbix Web should be the same as the hostname of the node and the Hostname parameter value in the / etc/zabbix/zabbix_agentd.conf configuration file.

Note: zabbix-server nodes complete the monitoring of their own status

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