Zabbix is a free, open-source, and high-performance monitoring tool for servers, applications, and network devices. It uses agents to collect system metrics. It also monitors standard services such as SMTP or HTTP services and supports host monitoring via SNMP, TCP, and ICMP checks. It is designed for real-time monitoring of thousands of servers, VMs, and network devices. It uses MySQL/MariaDB database to store its data and also supports encrypted communication between the server and connected clients.
In this tutorial, we will explain how to install the Zabbix monitoring server on Ubuntu 20.04.
Prerequisites:
- A fresh Cloud instance with Ubuntu 20.04 installed.
- A root password is set up to your instance.
- Create a new instance and connect to your instance as the root user.
Once you are logged into your Ubuntu 18.04 instance, run the following command to update your base system with the latest available packages.
apt-get update -y
Step 1 – Install LAMP Server
First, install the Apache, MariaDB, PHP and other required extensions with the following command:
apt-get install apache2 libapache2-mod-php mariadb-server php php-mbstring php-gd php-xml php-bcmath php-ldap php-mysql unzip curl gnupg2 -y
Once all the packages are installed, edit the php.ini file and make some changes:
nano /etc/php/7.4/apache2/php.ini
Change the following settings:
memory_limit 256M upload_max_filesize 16M post_max_size 16M max_execution_time 300 max_input_time 300 max_input_vars 10000 date.timezone = Asia/Dhaka
Save and close the file then restart the Apache service to apply the changes:
systemctl restart apache2
Step 2 – Create a Database for Zabbix
Next, you will need to create a database and user for Zabbix. First, log into the MariaDB shell with the following command:
mysql
Once login, create a database and user with the following command:
CREATE DATABASE zabbixdb character set utf8 collate utf8_bin; CREATE USER 'zabbixuser'@'localhost' IDENTIFIED BY 'password';
Next, grant all the privileges to the zabbixdb with the following command:
GRANT ALL PRIVILEGES ON zabbixdb.* TO 'zabbixuser'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES; EXIT;
Step 3 – Install and Configure Zabbix
By default, Zabbix is not available in the Ubuntu 20.04 standard repository. So you will need to install Zabbix repository in your system. You can install it with the following command:
wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+focal_all.deb dpkg -i zabbix-release_5.0-1+focal_all.deb
Next, update the repository and install the Zabbix server with the following command:
apt-get update -y apt-get install zabbix-server-mysql zabbix-frontend-php zabbix-agent zabbix-apache-conf -y
Once all the packages are installed, start the Zabbix service and enable it to start at system reboot with the following command:
systemctl start zabbix-server systemctl enable zabbix-server
Next, you will need to import the Zabbix database schema. You can import it with the following command, please note you will be prompted for the MySQL password created earlier.
cd /usr/share/doc/zabbix-server-mysql zcat create.sql.gz | mysql -u zabbixuser -p zabbixdb
Note: The zcat command can take several minutes to complete. Next, edit the Zabbix default configuration file and define the database settings:
nano /etc/zabbix/zabbix_server.conf
Change the following lines:
DBHost=localhost DBName=zabbixdb DBUser=zabbixuser DBPassword=password
Note: You will need to uncomment # DBHost and DBPassword
Save and close the file then restart the Zabbix and Apache service with the following command:
systemctl restart zabbix-server systemctl restart apache2
Step 4 – Configure Zabbix Agent
Next, you will also need to configure Zabbix agent in your system. You can configure it by editing the file zabbix_agentd.conf:
nano /etc/zabbix/zabbix_agentd.conf
Change the following lines:
Server = 127.0.0.1 ServerActive = 127.0.0.1 Hostname = Zabbix Server
Save and close the file then start the Zabbix agent service and enable it to start at boot with the following command:
systemctl start zabbix-agent systemctl enable zabbix-agent
Step 5 – Access Zabbix Dashboard
Now, open your web browser and access the Zabbix dashboard using the URL http://your-server-ip/zabbix. You will be redirected to the Zabbix welcome page:
Click on the Next step button. You should get the following page:
Make sure all the required PHP extensions are installed then click on the Next step button. You should see the following page:
Provide your database details and click on the Next step button. You should see the following page:
Provide your Zabbix server details and click on the Next step button.
Next, confirm all configurations and click on the Next step button. Once the installation has been completed, you should see the following page:
Click on the Finish button. You will be redirected to the Zabbix login page:
Provide the default username as Admin and password as Zabbix then click on the Sign-in button. You should see the Zabbix dashboard in the following page:
Conclusion
Congratulations! you have successfully installed and configured the Zabbix monitoring server on Ubuntu 20.04. You can now install Zabbix agents on more client systems and start monitoring them from the Zabbix dashboard.
Ref:
https://www.alibabacloud.com/blog/how-to-install-zabbix-monitoring-server-on-ubuntu-20-04_597802