Building zabbix monitoring system

Keywords: Linux Zabbix MariaDB yum MySQL

Building Automation Service Platform--zabbix Monitoring Platform

Preparatory environment

  1. Prepare a Linux host (CentOS 7 example)
  2. LAMP platform has been installed
  3. Close Firewall and SELinux
  4. Setting IP Address
  5. Setting up yum source
  6. Individual symbols in linux instructions will conflict with the text editing language of the blog. I will use spaces to separate them for easy reading, and the actual grammar will prevail.

Experiments begin

Preparing the zabbix Platform Environment

Server Address Settings

Change host name

[root@zabbix-server ~] hostnamectl set-hostname zabbix-server   //Setting Host Name

Configure IP address

[root@ zabbix-server ~] nmcli connection modify ens33 ipv4.addresses 192.168.139.132  //Setting IP Address
[root@ zabbix-server ~] nmcli connection up ens33  //Activate Network Card

Adding Host Mapping

[root@ zabbix-server ~] vim /etc/hosts  

192.168.139.132 zabbix zabbix-server.com   //Write the instruction on a separate line in vim

Check if you can ping the site you set up

[root@ zabbix-server ~] ping zabbix-server.com  //The address that ping just wrote in vim
PING zabbix (192.168.139.132) 56(84) bytes of data.
64 bytes from zabbix (192.168.139.132): icmp_seq=1 ttl=64 time=0.032 ms
64 bytes from zabbix (192.168.139.132): icmp_seq=2 ttl=64 time=0.034 ms

Install and enable LAMP platform

Install LAMP components

[root@ zabbix-server ~] yum -y install httpd mariadb mariadb-server php php-mysql   //Installation package
//Installed:
  httpd.x86_64 0:2.4.6-89.el7.centos         mariadb.x86_64 1:5.5.60-1.el7_5    
  mariadb-server.x86_64 1:5.5.60-1.el7_5     php.x86_64 0:5.4.16-46.el7         
  php-mysql.x86_64 0:5.4.16-46.el7          

Check if the installation is successful

[root@zabbix-server ~]# yum list httpd mariadb mariadb-server php php-mysql
//Loaded plug-ins: fastest mirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: ap.stykers.moe
 * updates: mirrors.aliyun.com
//Installed packages
httpd.x86_64                                                       2.4.6-89.el7.centos                                              @updates
mariadb.x86_64                                                     1:5.5.60-1.el7_5                                                 @base   
mariadb-server.x86_64                                              1:5.5.60-1.el7_5                                                 @base   
php.x86_64                                                         5.4.16-46.el7                                                    @base   
php-mysql.x86_64                                                   5.4.16-46.el7        

Enabling LAMP Service

[root@zabbix-server ~] systemctl restart httpd mariadb  //Restart service
[root@zabbix-server ~] systemctl enable httpd mariadb  //Set up boot-up self-start
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.s

Setting up firewalls and SELinux

Close the firewall

[root@zabbix-server ~] systemctl stop firewalld.service  //Close the firewall
[root@zabbix-server ~] systemctl disable firewalld.service  //Binary boot-up self-start
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

Turn off the SELinux mechanism

[root@zabbix-server ~] setenforce 0  //Failure SELinux
[root@zabbix-server ~] vim /etc/selinux/config  //No Boot Up
// Go into vim editing mode and change the value of the first SELinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
**SELINUX=disabled**
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

Installation and initialization of zabbix

Install zabbix related packages

Confirmation package
You can use XFTP to connect to CentOS 7 to upload the prepared zabbix-server file to the / root directory
Installing zabbix server dependency packages

[root@ zabbix-server ~] ls  /root/zabbix-server/
[root@ zabbix-server ~] yum  -y  install  zabbix-server/ *.rpm
[root@zabbix-server ~] yum list "zabbix*"
//Installed packages
zabbix-agent.x86_64                                                      3.4.15-1.el7                                              @zabbix  
zabbix-release.noarch                                                    3.4-2.el7                                                 installed
zabbix-server-mysql.x86_64                                               3.4.15-1.el7                                              @zabbix  
zabbix-server-pgsql.x86_64                                               3.4.15-1.el7                                              @zabbix  
zabbix-web.noarch                                                        3.4.15-1.el7                                              @zabbix  
zabbix-web-mysql.noarch                                                  3.4.15-1.el7        

Configuration Resolution Environment Change Time Zone

Modifying the web server configuration of zabbix

[root@zabbix-server ~] vim  /etc/httpd/conf.d/zabbix.conf
...
php_value date.timezone Asia/Shanghai   //Delete # and change time zone to Shanghai
...
[root@zabbix-server ~] systemctl  restart  httpd  //Restart web Services

Initialize database connection

New zabbix Library Authorized User zabbix Access Password is pwd@123

[root@zabbix-server ~] mysql  -uroot
MariaDB [(none)]> create  database  zabbix  character  set  utf8  collate   utf8_bin;
MariaDB [(none)]> grant  all  on zabbix.*  to  zabbix@localhost   identified  by   'pwd@123';
MariaDB [(none)]> quit;

Import the initial library provided by the zabbix service

[root@zabbix-server ~] zcat   /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql  -uzabbix  -ppwd@123   zabbix

Setting up database connection

[root@zabbix-server ~] vim  /etc/zabbix/zabbix_server.conf
...
DBName=zabbix    //Database name
DBUser=zabbix     //Database users
DBPassword=pwd@123     //Connection Password

zabbix monitoring interface

Open zabbix related services

Start zabbix-serer, zabbix-agent

[root@zabbix-server ~] systemctl restart zabbix-server zabbix-agent
[root@zabbix-server ~] systemctl enable zabbix-server zabbix-agent

Confirm that the httpd website service is open

[root@zabbix-server ~] systemctl restart httpd

Access web Interface Initialization Settings

Visit the deployed zabbix monitoring system page
Access in Browser http://192.168.139.132/zabbix/
Click the Next Step button

After confirming that the status is correct, click Next Step

Set the library name zabbix, user name zabbix, password pwd@123 and click Next Step

name here and click Next Step again

Next Step Point Finish Again

zabbix Foundation Settings

Go back to the login screen and start landing
Log in using the default administrator's account
Username: Admin
Password: zabbix

Display zabbix monitored pages after successful login

Change the language settings and click on the head logo at the top right of the zabbix monitoring platform
Select Chinese in the langue option

You can change a cool theme and select dark from the options just set in Chinese

Common problem

The following are some of the questions I have personally met in recent days in the hope that you can avoid detours.

Prompt for errors in installing php services

This may be a problem with the yum warehouse setup
Two Solutions

  • Check that the command to set up the yum warehouse is correct

After setting up the yum source, make sure repolist checks to see that the data is not working properly
In Theory -- add without - repo is OK, but I just can't add it or not.

[root@zabbix-server ~] yum-config-manager --add-repo file:///repo/cos7dvd/
  • Maybe it's a software dependency problem.
[root@zabbix-server ~] yum -y remove httpd-tools php-common mariadb-libs
[root@zabbix-server ~] yum -y install httpd mariadb mariadb-server php php-mysql
[root@zabbix-server ~] yum -y install postfix

Error installing zabbix-server package

This may be due to the inconsistency between the version of linux and the version of zabbix-server
CentOS version 7-1804 is nine packages with 16 versions. More packages need to be downloaded.

Error ERROR2002 when mysql-uroot logs in to the database

This error instruction should be that the database is not started
If this is still the case, it may be the same reason for the above problem.
In version 16, if the installation is not a mariadb package, it should be: mysql-community-server.x86_64

Solution:

[root@zabbix-server ~] wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
[root@zabbix-server ~] yum localinstall mysql57-community-release-el7-8.noarch.rpm
[root@zabbix-server ~] yum repolist enabled |grep "mysql.*-community.*"
[root@zabbix-server ~] yum -y install mysql-community-server.x86_64 
[root@zabbix-server ~] systemctl start mysqld
[root@zabbix-server ~] systemctl status mysqld
[root@zabbix-server ~] systemctl enable mysqld

Error ERROR3009 when entering database to set password

Since the database was upgraded, the data structure was not upgraded using mysql_upgrade after the upgrade was completed.

Solution:

[root@zabbix-server ~] mysql_upgrade -uroot

summary

Baidu has been stuck by the above problems for several days, and slowly pondered on them, Baidu only solved these problems, hoping to help you.
It's still necessary to build zabbix. Many companies are using zabbix, which is also a necessary skill for operation and maintenance.
The common mistake is that the source version of yum, which is often a minor problem, is easily overlooked.
If you have any questions or mistakes in the passage, you can comment or tell me by private letter.

Posted by chriskiely on Fri, 07 Jun 2019 16:56:09 -0700