04 October 2013

How To: Install Zabbix on Ubuntu 12.04 - AWS free tier

Install the Zabbix Server


Edit apt source list to add the PPA:
sudo nano /etc/apt/sources.list

Add the following items at the end of the file:
# Zabbix Application PPA
deb http://ppa.launchpad.net/tbfr/zabbix/ubuntu precise main
deb-src http://ppa.launchpad.net/tbfr/zabbix/ubuntu precise main

Press ctrl+x to quit, enter Y to save and close the file.

Next, we need to add the PPA's key so that apt-get trusts the source:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C407E17D5F76A32B

We can now install Zabbix:
sudo apt-get update
sudo apt-get install zabbix-server-mysql zabbix-frontend-php

During the installation, you will be asked to choose a password for the MySQL root account. Note the password so that you won't forget it.


Configure the Zabbix Server

Edit the main Zabbix server configuration file. Open the file as root:
sudo nano /etc/zabbix/zabbix_server.conf

Search for the following properties and set them accordingly. Some may already be set correctly, and some you may have to add. Choose a password as well:

DBName=zabbix
DBUser=zabbix
DBPassword=Your.Password.Here

Save and close the file.

Configure MySQL

Go into the package directory and unzip the SQL files that will define the database environment:
cd /usr/share/zabbix-server-mysql/
sudo gunzip *.gz

Import the SQL files into the database. First create the database and do some initial configuration.

Log into MySQL as root using the password that you set up during installation:
mysql -u root -p

Create a user for Zabbix and use the same information you entered in "/etc/zabbix/zabbix_server.conf":
create user 'zabbix'@'localhost' identified by 'Your.Password.Here';

Create the Zabbix database:
create database zabbix;

Add the new user you created to the database:
grant all privileges on zabbix.* to 'zabbix'@'localhost';

Implement the new permissions:
flush privileges;
exit;

Import the files that Zabbix needs to function. Enter the password for the user "zabbix" that you entered when prompted:
mysql -u zabbix -p zabbix < schema.sql

Import the images file:
mysql -u zabbix -p zabbix < images.sql

Import the data file:
mysql -u zabbix -p zabbix < data.sql

Configure PHP

Adjust some values for the php processing of our monitoring data.

Open the php configuration file:
sudo nano /etc/php5/apache2/php.ini

Search for and adjust the following entries. If they do not exist, add them:
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = UTC

Save and close the file.

Copy the Zabbix-specific php file into the configuration directory:
sudo cp /usr/share/doc/zabbix-frontend-php/examples/zabbix.conf.php.example /etc/zabbix/zabbix.conf.php

Open the file:
sudo nano /etc/zabbix/zabbix.conf.php

Edit the following values. Use the same info as when you set up the database earlier:
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'Your.Password.Here'

Save and close the file.

Configure Additional Files

Move the Zabbix apache file from the package directory:
sudo cp /usr/share/doc/zabbix-frontend-php/examples/apache.conf /etc/apache2/conf.d/zabbix.conf

Ensure that the "alias" mod is enabled within Apache:
sudo a2enmod alias

Restart Apache to use the copied configuration file:
sudo service apache2 restart

Edit the Zabbix init file to ensure that it performs the correct action:
sudo nano /etc/default/zabbix-server

Go to the bottom and adjust the "START" property to read "yes":
START=yes

Save and close the file.

Start Zabbix:
sudo service zabbix-server start

Install and configure the Zabbix Agent

Configure the agent software that reports to the Zabbix server. Install the agent software on the monitoring server and a client server.

Follow the steps below on BOTH servers.

Install the zabbix agent:
sudo apt-get update
sudo apt-get install zabbix-agent

Update the configuration files:
sudo nano /etc/zabbix/zabbix_agentd.conf

Edit the "Server" property to reflect the IP Address of the Zabbix server. For the agent configuration on the Zabbix server, you can use "127.0.0.1":
Server=Zabbix_Server_IP_Address

Adjust the "Hostname" property to reflect the hostname of the machine being monitored.
Hostname=Hostname_Of_Current_Machine

Save and close the file.

Restart the agent software:
sudo service zabbix-agent restart

Log in

In your web browser, navigate to your Zabbix server's IP address followed by "/zabbix":
http://server-ip/zabbix

You will be presented with a login screen. The default credentials are as follows:
Username = admin
Password = zabbix

---------------------------

That's all! Start monitoring your servers!

---------------------------

No comments: