Skip to content

Installing Zabbix

Status: verified

Four installations, really: the database, the schema inside it, the server, and the agent — then a web page to stand in front of them. The project ships all of it as ordinary packages from its own repository for the usual Linux distributions; this chapter follows that path and marks where the lab, sealed inside a sandbox, had to walk the same packages in by a side door.

Version first, because Zabbix keeps two kinds of releases: short-lived feature releases and long-term support ones. Install the LTS. The lab ran 7.0.32 — a late patch of the 7.0 LTS line — throughout, server, agent and tools all the same number, which is how a real installation should look too.

The database

Zabbix needs PostgreSQL (this guide's choice) or MySQL, running before anything else, because the server stores everything there. On a real machine you install PostgreSQL from your distribution, start it, and make three things: a user, a database, and room for the server's connections:

CREATE USER zabbix WITH PASSWORD 'choose-a-real-one';
CREATE DATABASE zabbix OWNER zabbix;

Two lessons from the lab belong here, because both are sizing, not software. The lab ran PostgreSQL from a data directory in scratch space, on port 55432 so it could never collide with a real database, with deliberately small memory settings — and its first Zabbix start failed with the database complaining, in so many words, that its connection slots were reserved: the server is a crowd of worker processes and every family wants connections. The lab's tiny max_connections of 30 was exhausted on sight; 100 — PostgreSQL's own default — ran the same server happily. Size the database for the server, not for the one administrator you can see.

Then the schema: the packages ship the whole database layout as one compressed SQL file, and importing it is a single command, as the zabbix user:

zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | psql -h localhost zabbix

In the lab that created 203 tables, and the proof belongs in the transcript (zabbix-lab/transcripts/t02-database-and-schema.txt): the dbversion table afterwards holds the schema's mandatory version (7000000 for the 7.0 line), which is exactly what the server checks on its first start.

The server

Add the project's repository (the release package for your distribution is on repo.zabbix.com), then install zabbix-server-pgsql, zabbix-agent2, zabbix-frontend-php, the SQL scripts, and the small tools zabbix-get and zabbix-sender. The server's whole configuration is /etc/zabbix/zabbix_server.conf; the lines a first install actually touches are few:

DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=choose-a-real-one

Start it, and read its log before believing anything else. The lab's server announced itself:

Starting Zabbix Server. Zabbix 7.0.32 (revision 0d6fa36d0a0).
current database version (mandatory/optional): 07000000/07000030

That second line is the handshake: the server found its database and the schema matches its expectations. The server listens on port 10051 — that is where agents on active checks and proxies report in, and where the frontend asks it to do things.

A confession the lab owes, because it shapes one claim in this guide: the sandbox this lab ran in must not be modified, so the official packages were downloaded and unpacked into scratch space rather than installed, and the programs ran from there. Same packages, same versions, same binaries — but the repository steps above (adding repo.zabbix.com, letting apt resolve the libraries) are the documented path, walked on real machines every day, and were not themselves the thing under test. What was under test — the database, the schema, the server, the agent, the frontend, the API — is identical either way, and criteria.md says so in its ledger.

The agent

Agent 2's configuration lives in /etc/zabbix/zabbix_agent2.conf. Three lines earn their place at once:

Server=127.0.0.1          # who may ask this agent questions
ServerActive=127.0.0.1    # where the agent reports for active checks
Hostname=lab-server       # the name the server will know it by

The Hostname must match, letter for letter, the host name you create in chapter 5 for active checks to line up. And a trap the lab sprang so you don't have to: there is no AllowRoot setting for agent 2 — that switch belongs to the old agent and the server. Paste it in from an elderly tutorial and agent 2 refuses to start, politely and completely:

ERROR: Cannot assign configuration: invalid parameter AllowRoot at line 5: unknown parameter.

The first direct proof that the whole lower half works needs no web page at all. zabbix_get asks one agent one question:

$ zabbix_get -s 127.0.0.1 -p 10050 -k agent.ping
1
$ zabbix_get -s 127.0.0.1 -p 10050 -k system.cpu.load[all,avg1]
1.98

The 1 means alive and answering; the second answer is the machine's real load average at that moment, changing every time you ask. Chapter 6 stays down at this level deliberately: everything the web pages later display begins life as an answer like these.

The check. Installed means: the database answers on its port and holds 203 tables with the right dbversion row; the server's log shows its version and that same database version; the agent answers agent.ping with 1 from zabbix_get. All three are in the lab's transcripts (t01 to t03) — and until all three hold on your machine, the web page in the next chapter has nothing to stand on.