Set up Zabbix Server on Amazon Linux 2 ARM EC2 Instance

Zabbix Server on Amazon Linux 2 ARM EC2

Set up Zabbix Server on Amazon Linux 2 ARM EC2 Instance

In this blog, we will be installing Zabbix Server, Zabbix UI in Amazon Linux 2 arm64 instance. As of now there is no Zabbix package(rpm package) available for arm64 RHEL based OS. The only option is to build zabbix from source.

Launch an Amazon Linux 2 arm64 instance. In this case, I’m launching a t4g.small instance.

Depending on the number of hosts and requests, you may modify the instance type, include RDS instance if necessary, etc.

SSH in to the EC2 instance and issue the following commands to create Zabbix user and group.

sudo groupadd --system zabbix
sudo useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix

Create a directory for zabbix source build

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

Download latest available version of Zabbix source from Zabbix's official repository

https://cdn.zabbix.com/zabbix/sources/stable/

In this case we are dowloading Zabbix 6.0 LTS. If you want to setup Zabbix 6.0, run below commands. Else modify the URL.

wget https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.5.tar.gz -O /tmp/zabbix-6.0.5.tar.gz
tar -xvf /tmp/zabbix-6.0.5.tar.gz -C /tmp
sudo mv /tmp/zabbix-6.0.5/* /usr/lib/zabbix

Modify the ownership of the source files copied to /usr/lib/zabbix

sudo chown -R zabbix:zabbix /usr/lib/zabbix

Now we need to install MariaDB Server in the EC2 instance. If you would like to setup an RDS instance instead of this, skip this step.

sudo amazon-linux-extras install mariadb10.5=latest -y

Start and enable MariaDB Server.

sudo systemctl start mariadb
sudo systemctl enable mariadb

Set root password for MariaDB Server by issuing the below command. Provide a secure password and skip all other settings if you are not aware of it.

sudo mysql_secure_installation

Login to MariaDB server.

mysql -uroot -p

Create a database and user for Zabbix Server.

create database zabbix character set utf8mb4 collate utf8mb4_bin;
create user 'zabbix'@'localhost' identified by 'PASSWORD';
grant all privileges on zabbix.* to 'zabbix'@'localhost';

Restore Zabbix Server schema to the database.

mysql -uroot -p zabbix </usr/lib/zabbix/databases/mysql/schema.sql
mysql -uroot -p zabbix </usr/lib/zabbix/databases/mysql/images.sql
mysql -uroot -p zabbix </usr/lib/zabbix/databases/mysql/data.sql

Install the necessary packages to build Zabbix Server.

sudo yum group install "Development Tools" -y
sudo yum install pcre-devel.aarch64 libevent-devel.aarch64 glibc-static.aarch64 zlib-devel.aarch64 OpenIPMI ipmitool libssh2-devel.aarch64 fping libcurl-devel.aarch64 libxml2-devel.aarch64 net-snmp gnutls gcc automake autoconf OpenIPMI-devel mariadb-devel net-snmp-devel 

Install the necessary packages to build Zabbix UI.

sudo amazon-linux-extras install php7.2 -y
sudo yum install php-gd php-bcmath php-ctype php-libXML php-xmlreader php-xmlwriter php-session php-sockets  php-mbstring  php-gettext php-ldap php-openssl php-mysqli php-oci8 php-mbstring go 

Here we are installing Apache as web server for Zabbix UI. Install and enable the service.

sudo yum install httpd
sudo systemctl start httpd && systemctl enable httpd

It's time to build Zabbix from the source. In the following configuration file add DBName, DBUser, DBPassword and save the file.

sudo vim /usr/lib/zabbix/conf/zabbix_server.conf

Build Zabbix by issuing the following commands.

sudo /usr/lib/zabbix/configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi
sudo make install

After the build is successful, create a systemd service for Zabbix server. Add the following lines in /etc/systemd/system/zabbix-server.service.

[Unit]
Description=Zabbix Server
After=syslog.target network.target mariadb.service
 
[Service]
Type=oneshot
User=zabbix
ExecStart=/usr/local/sbin/zabbix_server
ExecReload=/usr/local/sbin/zabbix_server -R config_cache_reload
RemainAfterExit=yes
PIDFile=/var/run/zabbix/zabbix_server.pid

[Install]
WantedBy=multi-user.target

Reload the newly created systemd file.

sudo systemctl daemon-reload

Start and enable Zabbix Service

sudo systemctl start zabbix-server.service && sudo systemctl enable zabbix-server.service

Now deploy Zabbix UI

sudo mkdir /var/www/html/zabbix
sudo cp -r /usr/lib/zabbix/ui/* /var/www/html/zabbix
sudo chown -R apache:apache /var/www/html/zabbix

Restart php-fpm and apache to complete the deployment

sudo systemctl restart php-fpm
sudo systemctl restart httpd

Zabbix server setup is now complete. You can now access your Zabbix UI from http://IP_ADDRESS/zabbix

If you receive connection timeout error from the browser, please check your instance's security group and confirm whether 80 port is open to your IP address or not.