Zabbix Server

Ricardo Martin | Apr 19, 2024 min read

Primary Zabbix Server Setup

As I mentioned on my previous post, I’ll be using Ubuntu 24.04 as the base operating system.

This guide assumes that you are capable of deploying a ubuntu server on your own. If not, please follow this guide before proceeding.

1. Install Zabbix Repository

The first step is to add the zabbix repository to the server. We’ll be using version 6.4 for this installation.

Check out the zabbix documentation for the current version.

Download the package from zabbix

We’ll use wget to download the package for our Operating System, Ubuntu 24.04

wget https://repo.zabbix.com/zabbix/6.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu24.04_all.deb
Install the package

We’ll use dpkg to to install the package we downloaded

sudo dpkg -i zabbix-release_6.4-1+ubuntu24.04_all.deb
Update the packages

Update the repository to make the packages available

sudo apt update -y

2. Install zabbix server

We’ll install the following components:

  • zabbix-server-pgsql
  • zabbix-sql-scripts
  • zabbix-agent
sudo apt install zabbix-server-pgsql zabbix-sql-scripts zabbix-agent
Edit the config file

We need to edit the config file located at /etc/zabbix/zabbix_server.conf and configure DBHost,DBName,DBUser,and DBPassword. Towards the bottom of the same config file we need to configure HANodeName and NodeAddress to enable HA. The values in my config file look like this:

The value of HANodeName must be unique across all Zabbix Servers

# database server IP
DBHost=10.0.0.20

# Database name
DBName=zabbix

# database user
DBUser=zabbix

#database passwor
DBPassword=zabbix
--------------- snip -------------------
####### High availability cluster parameters #######
# hostname of zabbix server. This value must be unique
HANodeName=zabbix01

# IP:Port of the server
NodeAddress=10.0.0.21:10051

3. Import DB Schema

Copy Schema to ZabbixDB server

Now that we have the zabbix server setup, we need to import the initial database schema into the database. Right now, we only have the server configured with a blank database. We’ll copy the file located at /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz to the zabbix database server 10.0.0.20 using scp:

scp /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz [email protected]:/home/administrator
Import Database Schema

Now we need to connect to the zabbixDB 10.0.0.20 and import the schema into PostgrSQL. We’ll use zcat to decompress the file and create the tables using the zabbix user we created during the zabbix database setup. On the Zabbix Database server, run:

This will take a few minutes to complete

zcat /home/administrator/server.sql.gz | sudo -u zabbix psql zabbix 
Enable and restart the service

To start the zabbix server, we need to restart the zabbix-server service, but before restarting the service, let’s enable it so it automatically restarts on reboot.

Enable service
sudo systemctl enable zabbix-server
Restart service
sudo systemctl restart zabbix-server

Backup Server setup

To setup the backup server, just follow the steps 1-3 and modify the configuration files to reflect the new configuration.

Make sure your servers have a static IP address. Below is the /etc/netplan/*.yaml config I’m using

  • 10.0.0.21: Zabbix server address (Primary)
  • 10.0.0.22: Zabbix server address (Backup)
  • 10.0.0.1: Gateway
  • 10.0.0.200: Internal DNS server
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
        - 10.0.0.21/24
      routes:
        - to: default
          via: 10.0.0.1
      nameservers:
        addresses: [10.0.0.200]
        search: [ns01.rcfmartin.com]

Next Steps

On the next post of this series, I will be covering the zabbix fronted setup. We’ll be covering how to install the frontend using the official Zabbix Alpine Image docker image and on the server itself, in our case Ubuntu 24.04

I’ll see you on the next one!