Zabbix actual battle-1.zabbix server program deployment

Experimental environment

Environment introduction
Operating system: RHEL 7.2
Server IP: 192.168.1.45
Software version: zabbix-3.4.15
Software storage location / opt/soft
Software installation location / apps/zabbix
Database type: mysql
Database IP:192.168.1.45

Required software download address
Links: https://pan.baidu.com/s/1nrDbe02L1ei0HE9gR5fIAw
Extraction code: 1tu6

Accidental egg
Zabbix Server is deployed based on LAMP platform. In this experiment, we learned how to deploy Zabbix Server, and also consolidated our understanding of LAMP architecture and principle.

Configure YUM source

Mount system image

[]# mount /dev/cdrom /media/
[]# mkdir /opt/soft

Copy the software required by httpd

[]# cp /media/Packages/httpd-2.4.6-40.el7.x86_64.rpm /opt/soft/
[]# cp /media/Packages/httpd-tools-2.4.6-40.el7.x86_64.rpm /opt/soft/
[]# cp /media/Packages/mailcap-2.1.41-2.el7.noarch.rpm /opt/soft/

Install httpd service

[]# rpm -ivh httpd-tools-2.4.6-40.el7.x86_64.rpm
[]# rpm -ivh mailcap-2.1.41-2.el7.noarch.rpm
[]# rpm -ivh httpd-2.4.6-40.el7.x86_64.rpm
[]# systemctl enable httpd
[]# systemctl start httpd

Copy and install the software needed for software warehouse

[]# cp /media/Packages/createrepo-0.9.9-23.el7.noarch.rpm /opt/soft/
[]# cp /media/Packages/python-deltarpm-3.6-3.el7.x86_64.rpm /opt/soft/
[]# cp /media/Packages/deltarpm-3.6-3.el7.x86_64.rpm /opt/soft
[]# rpm -ivh createrepo-0.9.9-23.el7.noarch.rpm
[]# rpm -ivh python-deltarpm-3.6-3.el7.x86_64.rpm
[]# rpm -ivh deltarpm-3.6-3.el7.x86_64.rpm

Prepare the dependent software package for this experiment
1. Upload myrepo folder to / var/www/html / directory of the server
2. Copy all software packages in the system image to / var/www/html/myrepo /

[]# cp -r /media/Packages /var/www/html/myrepo/
[]# pwd
/var/www/html/myrepo
[]# ls

fping-2.4b2-10.el6.x86_64.rpm            Packages                               php-devel-5.4.16-36.el7_1.x86_64.rpm
OpenIPMI-devel-2.0.19-11.el7.x86_64.rpm  php-bcmath-5.4.16-36.el7_1.x86_64.rpm  php-mbstring-5.4.16-36.el7_1.x86_64.rpm

Build local repository

[]# cd /var/www/html/myrepo
[]# createrepo. / note that there is a space in the middle

Configure yum source

[]# vim /etc/yum.repos.d/yum.repo

[zabbix]
name=zabbix
baseurl=http://192.168.1.45/myrepo/
enable=1
gpgcheck=0

Install web Services

Install httpd devel package

[]# yum install httpd-devel
[]# systemctl restart httpd

Install PHP package

[]# yum install php*

Configure PHP
Edit / etc/httpd/conf/httpd.conf, and add the following content in the latest line:

[]# vim /etc/httpd/conf/httpd.conf
AddHandler application/x-httpd-php .php
[]# systemctl restart httpd

Install Zabbix Server

Creating zabbix users

[]# groupadd zabbix
[]# useradd -g zabbix zabbix -s /sbin/nologin

Install libevent package
Copy libevent-release-1.4.15-stable.tar.gz to / opt/soft and extract

[]# tar zxvf libevent-release-1.4.15-stable.tar.gz
[]# cd libevent-release-1.4.15-stable/
[]# ./autogen.sh
[]# ./configure --prefix=/usr
[]# make
[]# make install
[]# ln -s /usr/lib/libevent-1.4.so.2 /usr/lib64/libevent-1.4.so.2

Install zabbix server dependency package

[]# yum -y install unixODBC-devel curl-devel net-snmp-devel OpenIPMI-devel mysql-devel libxml2-devel

Compile and install zabbix server

[]# cd /opt/soft/zabbix-3.4.15/
[]# tar zxvf zabbix-3.4.15.tar.gz
[]# ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi --with-unixodbc --prefix=/apps/zabbix
[]# make install

Configure Zabbix server

Modify zabbix configuration file

[]# vim /apps/zabbix/etc/zabbix_server.conf

SourceIP=192.168.1.45           //Native IP
DBHost=192.168.1.45             //Database IP
DBName= zabbix                      //Database name
DBUser= root                              //Database user name
DBPassword=1qaz3edc         //Database user password
DBPort=3306                             //Database port
StartPollers=50                          //During initialization, the more number of start-up sub processes, the stronger the server throughput, and the greater the consumption of system resources.
StartPreprocessors=10               
StartTrappers=10                       //It is used to set the number of receiving processes for data submitted by scenarios such as SNMP stripper. If the client SNMP stripper has many technologies, it is recommended to increase this data.
StartPingers=5                          //It is used to set the number of monitoring processes using ICMP Protocol to ping the host. If a single agent monitors more than 500 machines, it is recommended to increase this number.
StartDiscoverers=5              //It is used to set the number of processes of the autodiscover host. If more than 500 machines are monitored by a single agent, it is recommended to increase this number.
CacheSize=128M
TrendCacheSize=32M
ValueCacheSize=32M

Copy the ZABBIX? Server startup file

[]# cp /opt/soft/zabbix-3.4.15/misc/init.d/tru64/zabbix_server /etc/init.d/
[]# chmod 775 /etc/init.d/zabbix_server

Configure the ZABBIX? Server startup file

[]# vim /etc/init.d/zabbix_server

#/etc/rc.d/init.d/zabbix_server
# chkconfig: - 95 5
# processname: zabbix_server        //These three lines need to be added, pay attention to the "×" sign
DAEMON=/apps/zabbix/sbin/zabbix_server    //This line needs to be modified to its own installation directory

Add ZABBIX? Server service and set it to power on automatically

[]# chkconfig --add zabbix_server
[]# systemctl enable zabbix_server

DB installation and configuration

Install MySQL database
It is recommended to install MariaDB (MySQL, renamed) which comes with Linux 7.2.

[]# yum install mariadb-server mariadb-devel

Start MySQL database

[]# systemctl enable mariadb
[]# systemctl start mariadb

Configure DB
1. Create an account that can be accessed from outside
The default installation of mysql will create the root user, and the password for local login is empty. Log in as root:

[]# mysql
GRANT ALL PRIVILEGES ON *.* to 'root'@'%' IDENTIFIED BY '1qaz3edc';
(. Indicates all tables of all databases, and% indicates any ip. If the user can only log in as root from 192.168.1.45, it is: 'root'@'192.168.1.45', and '1qaz3edc' is the password.)

2. Create zabbix database

[]# mysql

create database zabbix character set utf8 collate utf8_bin;
quit;

[]# cd /opt/soft/zabbix-3.4.15/database/mysql/
[]# mysql zabbix < schema.sql
[]# mysql zabbix < images.sql
[]# mysql zabbix < data.sql

Configuring zabbix through the web

[]# cp -r /opt/soft/zabbix-3.4.15/frontends/php/ /var/www/html/
[]# setfacl -R -m u:zabbix:rwx /var/www/html/php/
[]# vim /etc/php.ini

post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai

[]# systemctl restart httpd
[]# systemctl restart zabbix_server

Visit http://192.168.1.45/php/setup.php configuration database ip and port number through browser.

Check if the configuration is correct

Configure database connection

Configure zabbix server

Download the configuration file and save it to the corresponding directory of the server

Verification

Visit: http://192.168.1.45/php/index.php
Since users in zabbix have not been created yet, you can use gust login to verify whether the installation is successful.

Everything is normal and no error is reported.

Tags: Linux Zabbix RPM PHP MySQL

Posted on Mon, 23 Mar 2020 21:40:28 -0700 by Scottmandoo