"Zabbix 3.2"-Install @20210227 using source code

brief introduction

This article will introduce how to install Zabbix monitoring using source code (only includes the installation of Zabbix Server and Zabbix Agent services).

Precautions

This article only installs Zabbix Server and Zabbix Agent service, not Zabbix Proxy service.

Create ordinary users and groups

For security reasons, Zabbix is ​​not allowed to run as root. If you use root to run, it will automatically switch to the zabbix user, if the zabbix user does not exist, an error will be reported. The following is the command to create users and groups:

#!/bin/sh

groupadd zabbix
useradd -g zabbix zabbix

Moreover, if Zabbix Agent and Zabbix Server are running on the same server, it is best to use different users. Prevent the Agent from accessing the configuration file of the Server.

Create the database used by Zabbix Server

Because Zabbix Server wants to save data, it is necessary to create a database on the server where Zabbix Server is located. The SQL file is located in the database under the source code directory. The specific database to be used depends on the needs. Take MySQL as an example:

The first step is to log in to MySQL to create a user and authorize:

#!/bin/sh
mysql -uroot -p
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by '<password>';
quit;

The second step is to import the relevant database:

#!/bin/sh 

mysql -uzabbix -p zabbix <schema.sql 

# Zabbix Proxy does not need the following two SQL files. 
mysql -uzabbix -p 
zabbix <images.sql mysql -uzabbix -p zabbix <data.sql

For other databases, refer to the " 1 Database creation scripts " manual.

Install Zabbix Server and Zabbix Agent

In the first case, if Server and Agent are on the same host:

#!/bin/sh 

# If MySQL is no longer a standard path, you need to use --with-mysql=/<path_to_the_file>/mysql_config to 
specify./configure --enable-server \ 
	--enable-agent --with-mysql \ 
	--enable-ipv6 --with-net-snmp \ 
	--with-libcurl --with-libxml2 

make && make install

If they are not on the same host, you need to compile Agent and Server separately:

#!/bin/sh 

# Compile Zabbix Server. 
# If MySQL is no longer a standard path, you need to use --with-mysql=/<path_to_the_file>/mysql_config to specify 
. / configure --enable-server \ 
	--with-mysql \ 
	--enable-ipv6 \ 
	--with-net -snmp \ 
	--with-libcurl \ 
	--with-libxml2 

make && make install
#!/bin/sh 

# Compile Zabbix Agent, which will be compiled on the monitored host. 
# Do not compile it together with Server, and then copy it to the monitored host. Unless you know what you are doing. 
./configure --enable-agent 

make && make install 

# If the --enable-agent option is used, zabbix_get and zabbix_sender tools will be generated at the same time.

View and modify configuration files

The configuration file of Zabbix Agent is located (if you have not modified the compilation options): /usr/local/etc/zabbix_agentd.conf.
Be sure to indicate the IP address of Zabbix Server. Other IP addresses are not allowed to access.

...... 
# IP address of Zabbix Server 
Server=xxx.xxx.xxx.xxx 
......

The Zabbix Server configuration file is located (if you have not modified the compilation options): /usr/local/etc/zabbix_agentd.conf
needs to be in the configuration, indicating the Username and Password of the database

Start Zabbix Server and Zabbix Agent

#!/bin/sh

zabbix_server
#!/bin/sh

zabbix_agent

Install the web interface

Web management is located in the frontend under the source directory, and there is only one PHP folder. Because the web management interface is written in PHP, a basic PHP web runtime environment is required.

This is relatively simple, the PHP source code is placed under the site, and then accessed, it will automatically guide the installation. The specific process will not be repeated here.

List of common errors

#1 unable to find net-snmp-config

checking for xmlReadMemory in -lxml2... yes
checking for net-snmp-config... no
configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config

Reason: libsnmap-dev is not installed.
Solution: If you use Debina and its derivatives, install libsnmap-dev

#2 Zabbix server is not running: the information displayed ......

Reason: There are many reasons for the whole problem, mine is just one example: if MySQL is no longer a standard path, you need to use --with-mysql=/<path_to_the_file>/mysql_config to specify. My MySQL is located in /usr/local/mysql, and the location of myql_config is not specified when compiling.
Solution: Recompile and use --with-mysql=/usr/local/mysql/bin/mysql_config to specify the location of mysql_config.

related articles

"Zabbix"-Installation (CentOS)
"Zabbix"-Debain 8.2 and Zabbix 4.0
"Zabbix"-About version upgrade

Guess you like

Origin blog.csdn.net/u013670453/article/details/114169938