Centos7 installation and deployment of zabbix monitoring software

catalog

Deploy monitoring server

1, Install LNMP environment
The Zabbix monitoring and management console needs to be displayed through Web pages, and MySQL is also needed to store data, so you need to prepare the basic LNMP environment for Zabbix first.

1. wget downloads the official website Nginx

wget http://nginx.org/download/nginx-1.17.10.tar.gz

2. yum install the dependency package required by Nginx

yum -y install gcc pcre-devel  openssl-devel

3. Source compilation and installation of Nginx

]# tar -xf nginx-1.17.10.tar.gz
]# cd nginx-1.17.10/
]# ./configure --with-http_ssl_module(Must be cd reach Nginx In the bag ./configure!!!)
]# make && make install
]# yum -y install php php-mysql php-fpm mariadb mariadb-devel mariadb-server

2, Modify Nginx configuration file
Configure Nginx to support PHP dynamic website. Because there are a lot of PHP scripts to execute, you need to open various fastcgi caches of Nginx to speed up the execution of PHP scripts.

]# vim /usr/local/nginx/conf/nginx.conf
... ...
http{
... ...
    fastcgi_buffers 8 16k;                      //Cache page content generated by php, 8 16k
    fastcgi_buffer_size 32k;                      //Cache php production header information
    fastcgi_connect_timeout 300;                 //Timeout to connect to PHP
    fastcgi_send_timeout 300;                     //Timeout to send request
    fastcgi_read_timeout 300;                        //Timeout for read request
location ~ \.php$ {
                root           html;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                include        fastcgi.conf; (Modify here)
        }
... ...

1. Start service

Start Nginx, PHP FPM and MariaDB services, and permanently shut down SELinux and firewall.
(systemctl is not required to manage Nginx. It can be selected according to your own needs.)

  • Writing Nginx service configuration file is not required
vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx	#Describe the service
After=network.target	#Describe service category
 
	[Service]	#Setting of service running parameters
Type=forking	#Is the form of background operation
ExecStart=/usr/local/nginx/sbin/nginx	#Start command for
ExecReload=/usr/local/nginx/sbin/nginx -s reload #For restart command
ExecStop=/usr/local/nginx/sbin/nginx -s stop	#For stop command
PrivateTmp=true	#Indicates that a service is assigned a separate temporary space
 
	[Install]#Run level setting, which can be set to multi-user, i.e. the system run level is3
WantedBy=multi-user.target

2. Set the power on self start

- systemctl start nginx.service
 - systemctl enable nginx.service
 - systemctl start  mariadb
 - systemctl enable mariadb
 - systemctl start  php-fpm
 - systemctl enable php-fpm

3. Permanently shut down SELinux and firewall

]# vim /etc/selinux/config         close selinux
 ...
 SELINUX=disabled
...

]# firewall-cmd --set-default-zone=trusted    Turn off firewall

Deploy monitoring server Zabbix Server

1, Source installation of Zabbix Server
Most source code packages need dependency packages, as does zabbix, which needs to be installed before source code compilation.

1. Install dependency package

]# yum -y install  net-snmp-devel curl-devel libevent-devel

2. Download zabbix-3.4.4 source package

]# wget https://cdn.zabbix.com/zabbix/sources/oldstable/3.4/zabbix-3.4.4.tar.gz

3. Source compilation and installation of zabbix

]#  tar -xf zabbix-3.4.4.tar.gz
]#  cd zabbix-3.4.4/
]#  ./configure  --enable-server --enable-proxy --enable-agent --with-mysql=/usr/bin/mysql_config  --with-net-snmp  --with-libcurl

***********************************************************
*            Now run 'make install'                       *
*                                                         *
*            Thank you for using Zabbix!                  *
*              <http://www.zabbix.com>                    *
***********************************************************
//Show this zabbix installed successfully!!!

]# make && make install

4. Initialize Zabbix
Create database and launch Web page of Zabbix

]# mysql
 MySQL > create database ZABBIX character set utf8
 MySQL > grant all on ZABBIX. * to ZABBIX @'localhost 'identified by' ZABBIX '; (create an account and password that can access the database)

]# cd zabbix-3.4.4/database/mysql/
]# mysql -uzabbix -pzabbix zabbix < schema.sql
]# mysql -uzabbix -pzabbix zabbix < images.sql
]# mysql -uzabbix -pzabbix zabbix < data.sql

Just created is an empty database. There are data prepared in advance under the zabbix source package directory
 Just use mysql to import the data (pay attention to the import order)

5. Go online to Zabbix's Web page

]# cd zabbix-3.4.4/frontends/php/
]# cp -r * /usr/local/nginx/html/
]# chmod -R 777 /usr/local/nginx/html/*

6. Modify the ZABBIX server configuration file, set database related parameters, and start the ZABBIX server service

]# vim /usr/local/etc/zabbix_server.conf
DBHost=localhost  Database host, the line is annotated by default
DBName=zabbix     Set database name
DBUser=zabbix     Set up database account
DBPassword=zabbix  Set the database password, which is annotated by default
LogFile=/tmp/zabbix_server.log    Set up the log, just view the following

]# useradd -s /sbin/nologin zabbix (Cannot start service without creating user)
]# zabbix_server   (Start service)
]# netstat -nutlp | grep zabbix  (Confirm connection status, port10051)

Tip: if the service cannot be started because the configuration file is wrong, do not execute ZABBIX? Server repeatedly,
Be sure to use the kill ZABBIX? Server to shut down the service before restarting it again.

7. Modify the ZABBIX agent configuration file and start the ZABBIX agent service

]# vim /usr/local/etc/zabbix_agentd.conf
Server=127.0.0.1,Native IP                   		Which hosts are allowed to monitor this machine
ServerActive=127.0.0.1,Native IP             		Which hosts are allowed to monitor this machine through active mode
Hostname=zabbix_server                        	Set local host name
LogFile=/tmp/zabbix_server.log                  Set log file
UnsafeUserParameters=1                        	Allow customization key

]# ZABBIX? Agentd (start monitoring agent)

]# netstat -nutlp | grep zabbix_agentd
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      2147/zabbix_agentd   View port information as10050

Tip: if the service cannot be started because the configuration file is wrong, do not execute ZABBIX ﹣ agentd repeatedly,
Be sure to shut down the service using killall ZABBIX? Agentd and restart it again.

8. The browser accesses the Web page of ZABBIX? Server server

]#http://native ip/index.php

On the first visit, initializing the PHP page will check whether the computer environment meets the requirements, and if it does not meet the requirements, it will give modification suggestions
By default, you will be prompted that the configuration of PHP does not meet the environment requirements, and you need to modify the PHP configuration file

According to the error prompt, modify the PHP configuration file to meet the Web environment requirements of ZABBIX? Server

]# yum -y install  php-gd php-xml
]# yum install php-bcmath-5.4.16-42.el7.x86_64.rpm
]# yum install php-mbstring-5.4.16-42.el7.x86_64.rpm

]# vim /etc/php.ini
date.timezone = Asia/Shanghai                	Set time zone
max_execution_time = 300                    	Maximum execution time, seconds
post_max_size = 32M                        		POST Maximum data capacity
max_input_time = 300                       		Time limit for server to receive data
memory_limit = 128M                        		Memory capacity limit

]# systemctl restart php-fpm

Web page validation settings

1. After modifying the PHP configuration file, use the browser to access the server again, and you will be prompted as shown in figure-1 and figure-2.

Figure 1


Figure 2

Note: there is no problem that there is a PHP LDAP in the warning state! In the initialization database page, fill in the database related parameters, as shown in figure-3.

Figure 3

On the login page, use the user (admin) and password (zabbix) to log in. After logging in, set the language environment to Chinese, as shown in figure-4 and figure-5.

Figure 4


Figure 5

Tags: Zabbix Nginx PHP Database

Posted on Sun, 17 May 2020 00:56:21 -0700 by mol