This is a translation of the original English documentation page. Help us make it better.

3 Инсталација из изворног кода

Најновију верзију Zabbix-а можете добити компајлирањем из изворног кода.

Корак-по-корак водич за инсталирање Zabbix-а из изворног кода је дат овде.

1 Инсталирање Zabbix демона

1 Преузмите архиву изворног кода

Идите на страницу за преузимање Zabbix-а и преузмите архиву изворног кода. Након преузимања, распакујте изворни код, покретањем:

tar -zxvf zabbix-7.2.0.tar.gz

Унесите исправну верзију Zabbix-а у команду. Мора да се подудара са именом преузете архиве.

2 Креирање корисничког налога

Сви процеси Zabbix демона се покрећу под непривилегованим корисницима система. Ако се Zabbix демон покрене са непривилегованог корисничког налога, наставиће да се покреће под тим корисником.

У подразумеваној конфигурацији, ако се демон покрене као root, пребациће се на zabbix кориснички налог, који мора бити присутан. Да бисте креирали zabbix системског корисника и групу, покрените команде наведене у наставку.

Систем базиран на RedHat-у:

groupadd --system zabbix useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix систем за праћење" zabbix

Систем базиран на Debian-у:

addgroup --system --quiet zabbix adduser --quiet --system --disabled-login --ingroup zabbix --home /var/lib/zabbix --no-create-home zabbix

Нема потребе за креирањем посебног корисничког налога за Zabbix фронтенд.

Безбедносна препорука

Ако Zabbix сервер и агент раде на истој машини, препоручује се да их покренете под одвојеним корисничким налозима. Покретање оба као истог корисника омогућава агенту приступ конфигурационој датотеци сервера, што би могло да открије осетљиве информације - као што је лозинка базе података - било ком кориснику са администраторским нивоом у Zabbix-у.

Покретање Zabbix-а као root, bin или било који други налог са посебним правима представља безбедносни ризик.

Кућни директоријум (опционо)

Zabbix процеси не захтевају кућни директоријум, тако да се његово креирање генерално не препоручује. Међутим, ако вам је потребна функционалност која захтева кућни директоријум (на пример, чување MySQL акредитива у $HOME/.my.cnf), можете га креирати помоћу команди наведених у наставку.

На системима заснованим на RedHat-у, покрените:

mkdir -m u=rwx,g=rwx,o= -p /usr/lib/zabbix chown zabbix:zabbix /usr/lib/zabbix

На системима заснованим на Debian-у, покрените:

mkdir -m u=rwx,g=rwx,o= -p /var/lib/zabbix chown zabbix:zabbix /var/lib/zabbix

3 Креирање Zabbix базе података

За Zabbix сервер и прокси демоне, као и Zabbix кориснички интерфејс, а потребна је база података. Није потребно покренути Zabbix агента.

SQL обезбеђене скрипте за креирање шеме базе података и уметање скупа података. Zabbix прокси бази података треба само шема док база података Zabbix сервера захтева такође скуп података на врху шеме.

Након што сте креирали Zabbix базу података, пређите на следеће кораке компајлирање Zabbix-а.

4 Configure the sources

C99 with GNU extensions is required for building Zabbix server, Zabbix proxy or Zabbix agent. This version can be explicitly specified by setting CFLAGS="-std=gnu99":

export CFLAGS="-std=gnu99"

If installing from Zabbix Git repository, it is required to run first:

./bootstrap.sh

When configuring the sources for a Zabbix server or proxy, you must specify the database type to be used. Only one database type can be compiled with a server or proxy process at a time.

To see all of the supported configuration options, inside the extracted Zabbix source directory run:

./configure --help

To configure the sources for a Zabbix server and agent, you may run something like:

./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi

To configure the sources for a Zabbix server (with PostgreSQL etc.), you may run:

./configure --enable-server --with-postgresql --with-net-snmp

To configure the sources for a Zabbix proxy (with SQLite etc.), you may run:

./configure --prefix=/usr --enable-proxy --with-net-snmp --with-sqlite3 --with-ssh2

To configure the sources for a Zabbix agent, you may run:

./configure --enable-agent

or, for Zabbix agent 2:

./configure --enable-agent2

A configured Go environment with a currently supported Go version is required for building Zabbix agent 2. See go.dev for installation instructions.

Notes on compilation options:

  • Command-line utilities zabbix_get and zabbix_sender are compiled if --enable-agent option is used.
  • --with-libcurl and --with-libxml2 configuration options are required for virtual machine monitoring; --with-libcurl is also required for SMTP authentication and web.page.* Zabbix agent items. Note that cURL 7.20.0 or higher is required with the --with-libcurl configuration option.
  • Zabbix always compiles with the PCRE library; installing it is not optional. --with-libpcre=[DIR] only allows pointing to a specific base install directory, instead of searching through a number of common places for the libpcre files.
  • You may use the --enable-static flag to statically link libraries. If you plan to distribute compiled binaries among different servers, you must use this flag to make these binaries work without required libraries. Note that --enable-static does not work in Solaris.
  • Using --enable-static option is not recommended when building server. In order to build the server statically, you must have a static version of every external library needed. There is no strict check for that in configure script.
  • Add optional path to the MySQL configuration file --with-mysql=/<path_to_the_file>/mysql_config to select the desired MySQL client library when there is a need to use one that is not located in the default location. It is useful when there are several versions of MySQL installed or MariaDB installed alongside MySQL on the same system.
  • Use --with-oracle flag to specify location of the OCI API.

If ./configure fails due to missing libraries or some other circumstance, please see the config.log file for more details on the error. For example, if libssl is missing, the immediate error message may be misleading:

checking for main in -lmysqlclient... no
       configure: error: Not found mysqlclient library

While config.log has a more detailed description:

/usr/bin/ld: cannot find -lssl
       /usr/bin/ld: cannot find -lcrypto

See also:

5 Make and install everything

If installing from Zabbix Git repository, it is required to run first:

$ make dbschema

make install

This step should be run as a user with sufficient permissions (commonly 'root', or by using sudo).

Running make install will by default install the daemon binaries (zabbix_server, zabbix_agentd, zabbix_proxy) in /usr/local/sbin and the client binaries (zabbix_get, zabbix_sender) in /usr/local/bin.

To specify a different location than /usr/local, use a --prefix key in the previous step of configuring sources, for example --prefix=/home/zabbix. In this case daemon binaries will be installed under <prefix>/sbin, while utilities under <prefix>/bin. Man pages will be installed under <prefix>/share.

6 Review and edit configuration files
  • edit the Zabbix agent configuration file /usr/local/etc/zabbix_agentd.conf

You need to configure this file for every host with zabbix_agentd installed.

You must specify the Zabbix server IP address in the file. Connections from other hosts will be denied.

  • edit the Zabbix server configuration file /usr/local/etc/zabbix_server.conf

You must specify the database name, user and password (if using any).

The rest of the parameters will suit you with their defaults if you have a small installation (up to ten monitored hosts). You should change the default parameters if you want to maximize the performance of Zabbix server (or proxy) though.

  • if you have installed a Zabbix proxy, edit the proxy configuration file /usr/local/etc/zabbix_proxy.conf

You must specify the server IP address and proxy hostname (must be known to the server), as well as the database name, user and password (if using any).

With SQLite the full path to database file must be specified; DB user and password are not required.

7 Start up the daemons

Run zabbix_server on the server side.

zabbix_server

Make sure that your system allows allocation of 36MB (or a bit more) of shared memory, otherwise the server may not start and you will see "Cannot allocate shared memory for <type of cache>." in the server log file. This may happen on FreeBSD, Solaris 8.

Run zabbix_agentd on all the monitored machines.

zabbix_agentd

Make sure that your system allows allocation of 2MB of shared memory, otherwise the agent may not start and you will see "Cannot allocate shared memory for collector." in the agent log file. This may happen on Solaris 8.

If you have installed Zabbix proxy, run zabbix_proxy.

zabbix_proxy

2 Installing Zabbix web interface

Copying PHP files

Zabbix frontend is written in PHP, so to run it a PHP supported webserver is needed. Installation is done by simply copying the PHP files from the ui directory to the webserver HTML documents directory.

Common locations of HTML documents directories for Apache web servers include:

  • /usr/local/apache2/htdocs (default directory when installing Apache from source)
  • /srv/www/htdocs (OpenSUSE, SLES)
  • /var/www/html (Debian, Ubuntu, Fedora, RHEL)

It is suggested to use a subdirectory instead of the HTML root. To create a subdirectory and copy Zabbix frontend files into it, execute the following commands, replacing the actual directory:

mkdir <htdocs>/zabbix
       cd ui
       cp -a . <htdocs>/zabbix

If planning to use any other language than English, see Installation of additional frontend languages for instructions.

Installing frontend

Please see Web interface installation page for information about Zabbix frontend installation wizard.

3 Installing Java gateway

It is required to install Java gateway only if you want to monitor JMX applications. Java gateway is lightweight and does not require a database.

To install from sources, first download and extract the source archive.

To compile Java gateway, run the ./configure script with --enable-java option. It is advisable that you specify the --prefix option to request installation path other than the default /usr/local, because installing Java gateway will create a whole directory tree, not just a single executable.

./configure --enable-java --prefix=$PREFIX

To compile and package Java gateway into a JAR file, run make. Note that for this step you will need javac and jar executables in your path.

make

Now you have a zabbix-java-gateway-$VERSION.jar file in src/zabbix_java/bin. If you are comfortable with running Java gateway from src/zabbix_java in the distribution directory, then you can proceed to instructions for configuring and running Java gateway. Otherwise, make sure you have enough privileges and run make install.

make install

Proceed to setup for more details on configuring and running Java gateway.

4 Installing Zabbix web service

Installing Zabbix web service is only required if you want to use scheduled reports.

To install from sources, first download and extract the source archive.

To compile Zabbix web service, run the ./configure script with --enable-webservice option.

A configured Go version 1.13+ environment is required for building Zabbix web service.

Run zabbix_web_service on the machine, where the web service is installed:

zabbix_web_service

Proceed to setup for more details on configuring Scheduled reports generation.