How To Install Zabbix Server 5 on Amazon Linux 2

Posted on 255 views

Zabbix is a free to use monitoring solution that can be installed on most Linux distribution servers. Zabbix gives you a powerful monitoring stack for your Server, Network devices, Web and Desktop applications, IoT appliances, various hardware appliances among many other customized use cases. Here we will be performing installation and configuration of Zabbix Server 5 on Amazon Linux 2.

The Zabbix monitoring solution uses a server/client architecture where an agent software is installed on machines to be monitored. This agent will collect and send metrics to the server, which stores the data in a database – MySQL, PostgreSQL, SQLite, Oracle or IBM DB2 database management system.

Install Zabbix 5 on Amazon Linux 2

We will install Zabbix 5 on Amazon Linux 2 using MySQL database as storage backend. We will also be configuring Apache httpd web server as reverse proxy to Zabbix server.

Before starting the installation of Zabbix 5 on Amazon Linux 2 ensure the system is updated,

sudo yum -y update

Once updated perform a system reboot.

sudo systemctl reboot

Step 1: Add EPEL repository

Start an SSH session to your Amazon Linux server.

$ ssh [email protected]
Warning: Permanently added 'serverip' (ECDSA) to the list of known hosts.
Enter passphrase for key '/Users/jkmutai/.ssh/id_rsa':

       __|  __|_  )
       _|  (     /   Amazon Linux 2 AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-2/
10 package(s) needed for security, out of 26 available
Run "sudo yum update" to apply all updates.
[[email protected] ~]$

We’ll add EPEL repository to the server by running the following commands:

sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 

The EPEL repository contains some packages which are dependents in the installation of Zabbix 5 on Amazon Linux 2 server.

Step 2: Install and Configure MariaDB Database

Add MariaDB repository to Amazon Linux 2 server:

sudo tee /etc/yum.repos.d/mariadb.repo<

Before you begin installaton update OS package cache index:

sudo yum makecache 

Install MariaDB Database server on Amazon Linux 2:

sudo yum -y install MariaDB-server MariaDB-client

Enable and start mariadb with the below commands

sudo systemctl enable mariadb
sudo systemctl start mariadb

Secure MariaDB database server by setting a root user account password, removing anonymous users, disallowing root remote logins and removing test databases:

$ sudo mysql_secure_installation
Enter current password for root (enter for none): Just press Enter
Set root password? [Y/n] Y 
New password:  New-root-password
Re-enter new password: Re-enter New-root-password
Remove anonymous users? [Y/n] Y 
Disallow root login remotely? [Y/n] Y 
Remove test database and access to it? [Y/n] Y 
Reload privilege tables now? [Y/n] Y 
Thanks for using MariaDB!

Connect to MariaDB and set up a database and a user

$ mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 10.5.8-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SELECT VERSION ();
+----------------+
| VERSION ()     |
+----------------+
| 10.5.8-MariaDB |
+----------------+
1 row in set (0.000 sec)

MariaDB [(none)]> \q
Bye

Login with the password set above and run the following commands to create a database and a user.

CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin; 
CREATE USER 'zabbix'@'localhost' IDENTIFIED BY '[email protected]'; 
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost'; 
FLUSH PRIVILEGES; 
EXIT

Step 3: Install Httpd Web Server

Run the following command to install httpd web server:

 sudo yum -y install httpd vim bash-completion

Enable and start httpd service

sudo systemctl enable httpd
sudo systemctl start httpd

Confirm httpd service is in running state:

$ systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2021-01-10 07:25:39 UTC; 5s ago
     Docs: man:httpd.service(8)
 Main PID: 2771 (httpd)
   Status: "Processing requests..."
   CGroup: /system.slice/httpd.service
           ├─2771 /usr/sbin/httpd -DFOREGROUND
           ├─2772 /usr/sbin/httpd -DFOREGROUND
           ├─2773 /usr/sbin/httpd -DFOREGROUND
           ├─2774 /usr/sbin/httpd -DFOREGROUND
           ├─2775 /usr/sbin/httpd -DFOREGROUND
           └─2776 /usr/sbin/httpd -DFOREGROUND

Set ServerName:

$ sudo vim /etc/httpd/conf/httpd.conf
ServerName zabbix.example.com

Set Server Admin to receive an email in case of issues.

$ sudo vim /etc/httpd/conf/httpd.conf
ServerAdmin [email protected]

Restart apache web service after making the changes:

sudo systemctl restart httpd

Step 4: Install Zabbix server on Amazon Linux 2

Add Zabbix YUM repository in your Amazon Linux 2 server with the following commands:

sudo yum -y install https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

Also install zabbix packages using the below command:

sudo yum -y install zabbix-server-mysql zabbix-agent zabbix-get

Install Zabbix Frontend:

Add CentOS SCL repository:

sudo tee /etc/yum.repos.d/centos-scl.repo<

Update yum repository list after adding the repository.

$ sudo yum makecache
Loaded plugins: langpacks, priorities, update-motd
amzn2-core                                                                                                                                 | 3.7 kB  00:00:00
amzn2extra-docker                                                                                                                          | 3.0 kB  00:00:00
amzn2extra-php7.4                                                                                                                          | 3.0 kB  00:00:00
centos-sclo-rh                                                                                                                             | 3.0 kB  00:00:00
centos-sclo-sclo                                                                                                                           | 3.0 kB  00:00:00
epel/x86_64/metalink                                                                                                                       |  17 kB  00:00:00
mariadb                                                                                                                                    | 2.9 kB  00:00:00
zabbix                                                                                                                                     | 2.9 kB  00:00:00
zabbix-frontend                                                                                                                            | 2.9 kB  00:00:00
zabbix-non-supported                                                                                                                       |  951 B  00:00:00
(1/6): centos-sclo-rh/primary_db                                                                                                           | 2.9 MB  00:00:00
(2/6): centos-sclo-rh/other_db                                                                                                             | 1.4 MB  00:00:00
(3/6): centos-sclo-rh/filelists_db                                                                                                         |  10 MB  00:00:01
(4/6): centos-sclo-sclo/primary_db                                                                                                         | 300 kB  00:00:00
(5/6): centos-sclo-sclo/other_db                                                                                                           | 185 kB  00:00:00
(6/6): centos-sclo-sclo/filelists_db                                                                                                       | 935 kB  00:00:00
Metadata Cache Created

Enable Frontend Zabbix repository and install packages:

sudo yum-config-manager --enable zabbix-frontend
sudo yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl

Import Zabbix Server database schema

Import initial schema and data for the server with MySQL:

sudo zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p'[email protected]' zabbix

Once the packages are installed proceed to start and enable the service:

sudo systemctl start zabbix-server zabbix-agent
sudo systemctl enable zabbix-server zabbix-agent

Status of the two services should be running:

$ systemctl status zabbix-server zabbix-agent
● zabbix-server.service - Zabbix Server
   Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2021-01-10 06:56:18 UTC; 12s ago
 Main PID: 31843 (zabbix_server)
   CGroup: /system.slice/zabbix-server.service
           └─31843 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf

Jan 10 06:56:18 amazon-linux systemd[1]: Starting Zabbix Server...
Jan 10 06:56:18 amazon-linux systemd[1]: PID file /run/zabbix/zabbix_server.pid not readable (yet?) after start.
Jan 10 06:56:18 amazon-linux systemd[1]: Started Zabbix Server.

● zabbix-agent.service - Zabbix Agent
   Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2021-01-10 06:56:18 UTC; 12s ago
 Main PID: 31836 (zabbix_agentd)
   CGroup: /system.slice/zabbix-agent.service
           ├─31836 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
           ├─31837 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
           ├─31838 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
           ├─31839 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
           ├─31840 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
           └─31841 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

Jan 10 06:56:18 amazon-linux systemd[1]: Starting Zabbix Agent...
Jan 10 06:56:18 amazon-linux systemd[1]: PID file /run/zabbix/zabbix_agentd.pid not readable (yet?) after start.
Jan 10 06:56:18 amazon-linux systemd[1]: Started Zabbix Agent.

By default, Zabbix-server runs on pot 10050 while Zabbix-agent runs on 10051. You can confirm if this is the case by running the following commands:

sudo ss -tlnup | grep 10050
sudo ss -tnlup | grep 10051

Step 5: Configure Zabbix Server on Amazon Linux 2

Edit the zabbix_server.conf configuration file to set Zabbix database credentials:

sudo vim /etc/zabbix/zabbix_server.conf

Add the credentials set when creating Zabbix database

DBHost=localhost 
DBName=zabbix 
DBUser=zabbix 
[email protected]

Set correct PHP timezone:

$ sudo vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Africa/Nairobi

Start and enable services:

sudo systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
sudo systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm

Step 6: Initiate Zabbix 5 Web configuration

Open your web browser and access “http://(Zabbix server’s hostname or IP address)/zabbix/”  to initiate Zabbix server initial setup.

zabbix-5-setup-01

Click on next step to go to the next page where pre-requisites status are shown.

zabbix-5-setup-02

Click Next step to set database connection details – database name, user and password.

How-to-install-zabbix-with-nginx-on-oracle-linux-8-01

In the next page configure server details including server Name.

How-to-install-zabbix-with-nginx-on-oracle-linux-8-02

Confirm installation summary and hit “Next Step” to complete installation.

How-to-install-zabbix-with-nginx-on-oracle-linux-8-03

If the installation was successful you should get the message shown below.

How-to-install-zabbix-with-nginx-on-oracle-linux-8-04

Click finish to be directed to the Zabbix login page. The default login details:

Username: "Admin"
Password: "zabbix"

Login with user Admin and password zabbix. Once you login, you should see a page as shown below:

Step 7: Change Admin Password

You’ll need to change the default Admin user password by navigating to:

Administration > Users > Admin > Password > Change Password

Enter the new password and confirm.

How-to-install-zabbix-with-nginx-on-oracle-linux-8-05

You now have a running instance of Zabbix server on Amazon Linux 2 system. The next steps will be to setup your agents to be monitored and create graphs, alerts and much more.

coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.