Thursday, June 16, 2011

Zabbix 1.8.5 installation on CentOS 5.6

Zabbix, the open source distributed monitoring solution, has been released as version 1.8.5 and I am here to show you how to install it in a server running CentOS 5.6.

Note: This is not the absolute guide and you should read the installation guide found in www.zabbix.com.

What you need:

  • CentOS 5.6 Operating System media (DVD, CDs, ISO file) | can be downloaded here
  • Zabbix 1.8.5 sources | can downloaded here
  • XML parser library for jabber | can be downloaded here (please use version 1.4.1 and devel 1.4.1)
  • Something to install all of this (PC, server, virtual machine, etc.)

After you got all the above you are ready to install zabbix. The network configuration is something up to you.

Zabbix pre-requisites and binaries installation
  1. Install CentOS with nothing more than the "Development Tools" installation group, set this with your IP, DNS, gateway, hostname, time zone.
  2. Connect to the server directly or using ssh.
  3. Install the zabbix server requirements. Use the following command to install Apache, MySql server, MySql client, php, mysql module for php (php-mysql), GD for php (php-gd), Binary Calculator for php (php-bcmath), Multibyte String for php (php-mbstring) and XML module for php (php-xml):
    yum install httpd mysql mysql-server mysql-devel php53 php53-mysql php53-gd php53-bcmath php53-mbstring php53-xml
  4. Continue the installation of zabbix requirements. Use the following command to install curl-devel net-snmp net-snmp-devel: 
  5. yum install curl-devel net-snmp net-snmp-devel
  6. Install iksemel packages, change to the download directory where you placed the two (2) rpm packages, then run the following command:
  7. rpm -ivh iksemel-1.4-1.el5.rf.i386.rpm iksemel-devel-1.4-1.el5.rf.i386.rpm
    Note: if your package version or package name is different, you need to modify this accordingly.
  8. Untar the zabbix source tarball using: 
  9. tar xvfz zabbix-1.8.5.tar.gz
  10. Inside the created zabbix directory, run the "configure" script with the following parameters:
  11. ./configure --prefix=/usr/local/zabbix-1.8.5 --enable-server --enable-agent --with-mysql --with-net-snmp --with-curl --with-jabber
  12. The next step is to install zabbix running "make install", this will install zabbix in "/usr/local/zabbix-1.8.5".
Database preparation
  1. Initialize the MySQL data directory and create the system tables using: 
  2. mysql_install_db
  3. Start "mysqld" service with:
  4. service mysqld start
  5. Change the mysql root user password using mysqladmin command:
  6. mysqladmin -uroot password somepassword
    Note: in this example the new password will be "somepassword", you may change this with something more complex.
  7. Now that we have initialized MySQL, started it and changed its root password, connect to it using the mysql client with:
  8. mysql -uroot -psomepassword
  9. Now create a database called zabbix with charset utf8:
  10. create database zabbix character set utf8;
  11. Quit from mysql client running the "quit" command:
  12. Run the following in the directory where you uncompressed the zabbix source to create the database schema:
  13. cat create/schema/mysql.sql | mysql -uroot -psomepassword zabbix
  14. Run the following to dump default data in the zabbix database tables:
  15. cat create/data/data.sql | mysql -uroot -psomepassword zabbix
  16. Run the following to dump image data into tables:
  17. cat create/data/image_mysql.sql | mysql -uroot -psomepassword zabbix
Zabbix Frontend

  1. Create the zabbix directory in the Apache html directory /var/www/html/zabbix.
  2. Run the following in the directory where you uncompressed the zabbix source to copy the frontend files to the zabbix directory created Apache:
  3. cp -a frontends/php/* /var/www/html/zabbix/
  4. Edit the php.ini file and change the following parameter values as seen here:
    • max_execution_time = 600
    • max_input_time = 600
    • memory_limit = 256M
    • post_max_size = 32M
    • upload_max_filesize = 16M
  5. Uncomment the date.timezone line and add your current zone, the list of time can be found here.
  6. Start the Apache service with:
  7. service httpd start

You may need to change your iptables in order to allow external access to http and zabbix service, you may use this (example only, this may not fit your security needs, please review your iptables policy):
iptables -I RH-Firewall-1-INPUT 8 -m state --state NEW -p tcp --dport 80 -j ACCEPT

Now, you may access your zabbix installation using http://YourZabbixServerIpAddress/zabbix/install.php

Here is a video to install zabbix: