How to Install and Configure Zabbix on Ubuntu 16.04

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: In this tutorial, we will go through step by step installation of Zabbix server and Zabbix client on Ubuntu 16.04 server.

Banners_Banners_Banner_Blog_11_Nov_5_MySQL_InnoDB_

By Hitesh Jethva, Alibaba Cloud Tech Share Author

Introduction

Zabbix is an open source and enterprise-class network monitoring tool that can be used to monitor performance and availability of the server, network devices and other network components. Zabbix uses MySQL, PostgreSQL and Oracle to store its data. Zabbix also provides a user friendly web interface to monitor and track data and settings. Zabbix uses a Zabbix agent to collect the data and send it to the Zabbix server.

In this tutorial, we will go through step by step installation of Zabbix server and Zabbix client on Ubuntu 16.04 server.

Prerequisites

• A fresh Alibaba Cloud ECS instance for Zabbix server with Ubuntu 16.04 installed.
• A fresh Alibaba Cloud ECS instance for Zabbix client with Ubuntu 16.04 installed.
• Non-root user with sudo privileges is configured on both instance.

Install LAMP Server

Before starting, Zabbix requires Apache, MySQL and PHP installed on your system. First, install Apache, PHP7 and other required PHP modules by running the following command:

sudo apt-get update -y
sudo apt-get install apache2 libapache2-mod-php7.0 php7.0 php7.0-xml php7.0-bcmath php7.0-mbstring -y

Once all the components are installed, you will need to install MariaDB. By default, the latest version of the MariaDB is available in Ubuntu 16.04 repository. So you can easily install it by just running the following command.

sudo apt-get install mariadb-server -y

Next, start MariaDB server and enable it to start on boot time:

sudo systemctl start mysql
sudo systemctl enable mysql

Install Zabbix

By default, the latest version of the Zabbix is not available in Ubuntu 16.04 default repository. So you will need to download and install the official Zabbix repository to your system.

First, download the Zabbix repository with the following command:

wget http://repo.zabbix.com/zabbix/3.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.0-2+xenial_all.deb

Next, install the downloaded repository with the following command:

sudo dpkg -i zabbix-release_3.0-2+xenial_all.deb

Next, update the repository and install Zabbix server and web front-end with MySQL database support with the following command:

sudo apt-get update -y
sudo apt-get install zabbix-server-mysql zabbix-frontend-php -y

You will also need to install Zabbix agent to collect the Zabbix server data itself.

sudo apt-get install zabbix-agent -y

Next, start Zabbix agent and enable it to start at boot:

sudo systemctl restart zabbix-agent
sudo systemctl enable zabbix-agent

Configure Database for Zabbix

Before using Zabbix, you will need to create a database and a user to store the Zabbix server data.

First, log in to MariaDB shell with the following command:

mysql -u root -p

Enter your root password when prompt, then create a database for Zabbix.

CREATE DATABASE zabbix_db character set utf8 collate utf8_bin;

Next, create a user for the Zabbix server and grant all the privileges identified by a password:

GRANT ALL PRIVILEGES on zabbix_db.* to zabbix_user@localhost identified by 'zabbix';

We will be using the password zabbix by default.

Next, flush the privileges with the following command:

MariaDB [(none)]>FLUSH PRIVILEGES;

Finally, exit from the MariaDB shell:

MariaDB [(none)]>exit;

Next, import initial schema and data to the newly created Zabbix database:

cd /usr/share/doc/zabbix-server-mysql/
sudo zcat create.sql.gz | mysql -u zabbix_user -p zabbix_db

Enter your zabbix_user password when prompt. (You may have to wait)

Configure Zabbix

Next, you will need to set database, database username and the database password in the Zabbix server configuration file. You can do this by editing zabbix_server.conf file:

sudo nano /etc/zabbix/zabbix_server.conf

Change the following lines:

DBName=zabbix_db
DBUser=zabbix_user
DBPassword=zabbix

Save and close the file when you are finished. Next, you will need to change Timezone settings in /etc/zabbix/apache.conf file:

sudo nano /etc/zabbix/apache.conf

Find the line:

# php_value date.timezone Europe/Riga

Then, replace it with the following line as per your Timezone: http://php.net/manual/en/timezones.php. For this example, I will be using:

php_value date.timezone Asia/Shanghai

Save the file when you are finished.

Finally, start Apache server and Zabbix server and enable them to start on boot time:

sudo systemctl restart apache2
sudo systemctl restart zabbix-server
sudo systemctl enable apache2
sudo systemctl enable zabbix-server

Access Zabbix Web Interface

Your Zabbix server is now set up and connected to the database. It's time to access Zabbix web installation wizard.

Open your favourite web browser and navigate to the URL http://ECS_Internet_IP_Address/zabbix. You can find your ECS Internet IP Address from the management console. You will be redirected to the welcome page as shown below:

01

Click on the Next step button, you should see the pre-requisites page in the following screen:

02

Make sure all the values are ok. Once you have done. Click on the Next step button. You should see the Zabbix database configuration screen:

03

Here, update all the details like, Database name, Database username and the password, then click on the Next step button. You should see the following screen:

04

Here, provide hostname or IP address and port number of the zabbix server and click on the Next step. You should see the following page:

05

Verify the pre-installation summary, then click on the Next step button to start the installation. Once the installation is finished, you should see the following page:

06

Now, click on the Finish button. You will be redirected to the Zabbix server login screen as below:

07

Now, log in with the Zabbix server default username Admin and the password zabbix. You should see the Zabbix server dashboard in the following screen:

08

Install and Configure Zabbix Client

Your Zabbix server is now up and running. Next, you will need to install Zabbix Agent which you want to monitor. First, download and install the Zabbix repository to your Client machine:

wget http://repo.zabbix.com/zabbix/3.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.0-2+xenial_all.deb

Next, install the downloaded repository with the following command:

sudo dpkg -i zabbix-release_3.0-2+xenial_all.deb

Next, update the repository and install Zabbix Agent with the following command:

sudo apt-get update -y
sudo apt-get install zabbix-agent -y

Next, open the Zabbix agent default configuration file located at /etc/zabbix/zabbix_agentd.conf:

sudo nano /etc/zabbix/zabbix_agentd.conf

Change the file as shown below:

##IP address of Zabbix Server
Server=192.168.0.103
ServerActive=192.168.0.103
Hostname=Zabbix-Client

Save and close the file when you are finished, then restart Zabbix Agent to apply these changes:

sudo systemctl restart zabbix-agent

Next, add Zabbix Agent service to start at boot:

sudo systemctl enable zabbix-agent

Add Zabbix Client Machine to Zabbix Server for Monitoring

Now, Zabbix Agent is up and running. Next, move to the Zabbix server web interface and add the Client Machine which run zabbix agents in order to be monitored by the Zabbix server.

On the Zabbix web console, go to Configuration -> Hosts -> Create Host -> Host tab and provide all the required information as shown below:

09

Next, move to Templates tab and click on the select button. A new window with templates should open. Choose Template OS Linux then scroll down and click on the Select button to add it.

10

Next, click on add button to link it to Zabbix server, then click on lower add button again to complete the process:

11
12

You should now see the monitored client machine in below screenshot:

13

After adding the Zabbix client to the Zabbix server make sure that the host Status is set to Enabled. Next, wait for the few seconds for Zabbix server to contact the agent, then move to the Monitoring tab on Zabbix web console and then click on the Latest data to see the data from your agent.

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
Ubuntu
【Ubuntu】apt-get install 报错 无法获得锁 /var/lib/dpkg/lock-frontend - open (11: 资源暂时不可用)
【Ubuntu】apt-get install 报错 无法获得锁 /var/lib/dpkg/lock-frontend - open (11: 资源暂时不可用)
132 0
|
Ubuntu 关系型数据库 MySQL
How to Install and Configure Icinga2 Monitoring Tool on Ubuntu 16.04
In this tutorial, we will explore how to install Docker on Alibaba Cloud and learn some important Docker commands to help you deploy and manage your container services.
3004 0
How to Install and Configure Icinga2 Monitoring Tool on Ubuntu 16.04
|
Web App开发 关系型数据库 应用服务中间件
|
关系型数据库 应用服务中间件 PHP