Zabbix monitoring system construction

1. Experimental environment preparation

  • There are 3 centos7.5 system servers, one as the monitoring server, and two as the monitored node. The yum source is configured, the firewall is turned off, the clock service of
    each node is synchronized, and the nodes can communicate with each other through the host name.

Two.zabbix installation

1. Modify the host name

[root@localhost ~]# hostnamectl --static set-hostname zabbix

2. Turn off the firewall and Selinux

[root@zabbix ~]#  systemctl stop iptables firewalld
[root@zabbix ~]#  systemctl disable iptables firewalld
[root@zabbix ~]#  sed -ri '/SELINUX=/cSELINUX=disabled' /etc/selinux/config
[root@zabbix ~]#  setenforce 0           # 临时关闭SELinux
[root@zabbix ~]#  reboot

3. Turn on the mail service

[root@zabbix ~]# systemctl start postfix
[root@zabbix ~]# systemctl enable postfix

4. Add hosts

[root@zabbix ~]# vim /etc/hosts

Insert picture description here

5. Install yum warehouse

  • This is a foreign source. If you download it normally or if the network is not good, the download will fail several times. After several times, the download will be completed without reporting an error.
[root@zabbix ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

6. Update yum warehouse

[root@zabbix ~]# yum repolist 

Insert picture description here

7. Install zabbix server and agent

[root@zabbix ~]# yum -y install epel-release.noarch
[root@zabbix ~]# yum -y install zabbix-agent zabbix-get zabbix-sender zabbix-server-mysql 

8. Install zabbix front end

[root@zabbix ~]# yum -y install centos-release-scl
  • Open the front-end installation source warehouse configuration

[root@zabbix ~]# vim /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]

enabled=1

  • Install zabbix frontend
[root@zabbix ~]# yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl

3. Install and set up the database

1. Create mariadb.repo

[root@zabbix ~]# vim /etc/yum.repos.d/mariadb.repo

Add the following

[mariadb]
name = MariaDB
baseurl =https://mirrors.ustc.edu.cn/mariadb/yum/10.5/centos7-amd64
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1

2.yum install the latest version of mariadb

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

3. Modify the configuration file

Find [mysqld], add below

[root@zabbix ~]# vim /etc/my.cnf.d/server.cnf

[mysqld]
skip_name_resolve = ON
innodb_file_per_table = ON
innodb_buffer_pool_size = 256M
max_connections = 2000
log-bin = master-log

4. Restart the database service

[root@zabbix ~]# systemctl restart mariadb
[root@zabbix ~]# mysql_secure_installation  # 初始化mariadb

5. Create a database and authorize an account

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;  
MariaDB [(none)]> grant all on zabbix.* to 'zabbix'@'192.168.152.%' identified by '1234.com';	
MariaDB [(none)]> flush privileges; 

6. Import Zabbix service table

  • Check out what zabbix-server-mysql package provides

[root@zabbix ~]# rpm -ql zabbix-server-mysql
/etc/logrotate.d/zabbix-server /etc/zabbix/zabbix_server.conf
/usr/lib/systemd/system/zabbix-server.service
/usr/ lib/tmpfiles.d/zabbix-server.conf /usr/lib/zabbix
/ alertscripts /usr/lib/ zabbix /externalscripts /usr/sbin/zabbix_server_mysql
/usr/share/doc/zabbix-server-mysql-5.0.2
/ usr/share/doc/zabbix-server-mysql-5.0.2/AUTHORS
/usr/share/doc/zabbix-server-mysql-5.0.2/COPYING
/usr/share/doc/zabbix-server-mysql-5.0. 2/ChangeLog
/usr/share/doc/zabbix-server-mysql-5.0.2/NEWS
/usr/share/doc/zabbix-server-mysql-5.0.2/README
/usr/share/doc/zabbix-server- mysql-5.0.2/create.sql.gz # Various scripts to generate tables
/usr/share/doc/zabbix-server-mysql-5.0.2/double.sql
/usr/share/man/man8/zabbix_server.8.gz /var/log/zabbix /var/run/zabbix

  • Install gzip
[root@zabbix ~]# gzip -d /usr/share/doc/zabbix-server-mysql-5.0.2/create.sql.gz
[root@zabbix ~]# ls
anaconda-ks.cfg

7. Import information (two ways)

①Enter the database

sorce /usr/share/doc/zabbix-server-mysql-5.0.2/create.sql

[root@zabbix ~]# mysql -uzabbix -h192.168.37.111 -p'1234.com' zabbix < /usr/share/doc/zabbix-server-mysql-5.0.2/create.sql

  • Imported successfully

Four. Configure the server side

1.

[root@zabbix ~]# cd /etc/zabbix/
[root@zabbix zabbix]# ls
web  zabbix_agentd.conf  zabbix_agentd.d  zabbix_server.conf
#为了方便我们以后恢复,我们把配置文件备份一下
[root@zabbix zabbix]# cp zabbix_server.conf{,.bak}
[root@zabbix zabbix]# vim zabbix_server.conf
ListenPort=10051            # 默认监听端口
SourceIP=192.168.37.111     # 发采样数据请求的 IP
LogType=file
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0    #日志滚动
DebugLevel=3    #日志级别
DBHost=192.168.49.170  #本机ip
DBName=zabbix  #数据库名称
DBUser=zabbix  #数据库用户
DBPassword=123.com  #数据库密码
DBPort=3306   #数据库端口

Start service

[root@zabbix zabbix]# systemctl start zabbix-server.service

Confirm that the service port is open

Insert picture description here

Four. Configure web GUI

1. Configure the php front end

  • PHP monitor users to add nginx, set time zone
[root@zabbix ~]# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai

2. Start the http service

[[email protected] ~]# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
[[email protected] ~]# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm

3. Browser access and initial settings

  • Browser enter ip/zabbix access
    Insert picture description here
    Insert picture description here
    Insert picture description here
    Insert picture description here
    Insert picture description here
    Insert picture description here
  • The default user name is Admin and the password is zabbix. After logging in, enter the dashboard:
    Insert picture description here

Five. Configure the agent side

  • Install the agent on the monitored host, set up the server, and add it to the server to include it in the monitoring system.

1. Install zabbix installation source

[root@node1 ~]# wget https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
#######yum -y localinstall  zabbix-release-5.0-1.el7.noarch.rpm #本地安装
[root@node1 ~]# rpm -ivh zabbix-release-5.0-1.el7.noarch.rpm
[root@node1 ~]# yum -y install epel-release.noarch
[root@node1 ~]# yum install zabbix-agent zabbix-sender -y

2. Edit the configuration file

  • Make a backup copy first, just in case
[root@node1 ~]# cd /etc/zabbix/
[root@node1 zabbix]# ls
zabbix_agentd.conf  zabbix_agentd.d
[root@node1 zabbix]# cp zabbix_agentd.conf{,.bak}
[root@node1 zabbix]# vim zabbix_agentd.conf

[root@node1 zabbix]# grep -Ev ‘^$|#’ zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid LogType=file
LogFile=/var/log/zabbix/zabbix_agentd.log LogFileSize=0 DebugLevel=3
SourceIP=192.168.49.171 Server=192.168.49.170 ListenPort=10050
ListenIP=192.168.49.171 StartAgents=3 ServerActive=192.168.49.170
Hostname=node1 Include=/etc/zabbix/zabbix_agentd.d/*.conf

  • Start service
[root@node1 zabbix]# systemctl start zabbix-agent.service
  • Check if the port is open
    Insert picture description here

Six. Detailed explanation of the monitoring process

1. Modify the Chinese version

Insert picture description here

2. Create a host group

Insert picture description here

3. Add host

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_49844466/article/details/108718237