Installing Zabbix on a CentOS/RedHat system

By jbayer - Last updated: Friday, December 17, 2010 - Save & Share - 14 Comments

One of the core tasks of a good system administrator is monitoring systems, and responding to problems as quickly as possible.

Zabbix is an open source monitoring system which offers advanced monitoring, alerting and visualisation features today which are missing in other monitoring systems, even some of the best commercial ones.

Installing Zabbix, while not difficult, has a number of steps and requirements.  To simplify the installation process, there are a number of HowTo’s on the web, as well as a few scripts.  One of the better scripts on the web, which I have used, is a bit outdated.  I’ve taken the script, updated it to CentOS 5.5 and Zabbix 1.8.3.

The attached script was originally written by Brendon Baumgartner, the URL for the original posting is:

http://blog.brendon.com/?s=zabbix

This is an updated script to install Zabbix 1.8.3 on CentOS/Red Hat 5. I have tested it on CentOS 5.5. The script was made for Zabbix 1.8.3, but if you modify the ZBX_VER variable in the script, it should work on any version in the 1.8 series.

Basically, the script tries to do a few things and assumes some things:

This is a reworked script.  I’ve made the following changes:

The assumptions are that the server is a minimal install; no options at all are installed
during the OS install. All necessary packages will be installed by this script.

Added following:

  1. Changed 20 second sleep at beginning to a query
  2. Installation of the mysql-server package, if necessary
  3. Installation of the checkinstall script
  4. Installs php 5.3
  5. Installion of the yum-priorities plugin
  6. Addition of webtatic to the package dir (for PHP5.3)
  7. Added install of php-mbstring
  8. Added update of php.ini to recommended values
  9. Install latest version of libxml2, getting code from xmlsoft.org
  10. Addition of priority lines to the CentOS-Base.repo, CentOS-Media.repo files
  11. Installation of Dag’s GPG key (needed for rpmforge)
  12. Calls the checkinstall script to make binary RPMS
  13. Installs the binary RPM
  14. Install selected configuration file for mySql, only if the script installs mysql-server
  15. Moved all minor functionality into seperate functions, useful for future expandability

When the script is done, there will be at least two RPMs in /usr/src/redhat/RPMS/$arch/zabbix…..

You can use these RPMs to install Zabbix on other identical systems, as well as use the rpm manager to remove  Zabbix from the system if you so desire.

I’ll be updating this in a few days with the ability to build either a server, agent or both.  Right now it automatically builds both the server and the agent.

If you are installing on a RHEL 6 system (or CentOS 6, SL 6), use this link instead for an updated version

Posted in Administration, Open Source, Zabbix • Tags: , Top Of Page
4,427 views

14 Responses to “Installing Zabbix on a CentOS/RedHat system”

Comment from wilfred nwakpu
Time June 29, 2011 at 1:59 pm

you did a good work

Comment from wilfred nwakpu
Time June 29, 2011 at 2:00 pm

Can you please send me the updated script for zabbix 1.9.4.

i am new to linux and i love zabbix so much. i am using centos 5.5

Comment from jbayer
Time June 29, 2011 at 3:11 pm

The latest released version of Zabbix is 1.8.5, while I haven’t tested with the 1.9.4 beta I wouldn’t expect too many changes. you simply need to update a single line in the script to this version. The line you need to update is line # 78.

If you do try the 1.9.4, and it works, I’d like to hear about it.

Good luck!

Comment from wilfred
Time June 30, 2011 at 9:21 am

Thank you very much for having time to reply.

I tried but its not working.

i am using cetos 5.6 and it does complete installation.

Comment from jbayer
Time July 7, 2011 at 11:05 am

I found a bug in the script, just updated it. Try it again.

If you are installing on the same system, uninstall the Zabbix rpms and delete the database.

Comment from wilfred
Time July 15, 2011 at 1:22 am

THE PROBLEM I AM HAVING NOW IS THAT THE ZABBIX SERVER WILL RUN FOR FEW DAYS AND THEN DISPLY THIS ERROR.Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (111)

I WILL WORK AGAIN IF I RESTART THE MACHINE

WHAT CAN I DO TO FIX THIS PROBLEM.

THANK YOU SO MUCH.

Comment from jbayer
Time July 15, 2011 at 6:25 pm

It sounds like you are having a problem with your mysql server. You need to look at your mysql log file to see what is going on.

Comment from wilfred
Time July 15, 2011 at 2:13 am

Sir,

can you send me the setting on my DB and zabbix config to solve this problem.

Comment from wilfred
Time July 16, 2011 at 2:20 pm

hi Jbayer,
I sincerely appreciate your making time to help solve this problem.

i have just installed new centos and installed zabbix with the script you made.

i am monitoring it and the moment the error pops up again, i will give you the setting of the zabbix config.

thank you sir.

Comment from wilfred
Time July 18, 2011 at 3:03 pm

Dear Jbayer,

Like i told earlier, the error has poped up again and i dont know how to solve this problem.

below is the error:

mysql_connect() [function.mysql-connect]: Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (111)[/usr/local/share/zabbix/include/db.inc.php:58]

is there anything i can do to solve this problem.

Comment from jbayer
Time July 25, 2011 at 3:13 pm

You need to look into your MySql log file. It appears that MySql is not running. This could be any number of reasons, but the log file is the first place you should look at.

also, make sure that you have enough memory to run this (a gig should be enough)

A quick fix would be to add the following to your root crontab to simply restart mysql every day:

0 * * * * /etc/init.d/mysqld restart

Comment from cby
Time November 27, 2011 at 11:10 am

Just a note to say that your script was faultless in installing zabbix 1.8.6 on a RHEL5.7 VM running under Virtualbox. Many thanks.

The creation of the zabbix RPMs is a nice touch.

If the ZBX_VER version (e.g. 1.8.9) in the script was changed, could it be re-run to update the installed version from 1.8.6 to 1.8.9?

Thanks again.

Comment from jbayer
Time November 29, 2011 at 8:27 am

Glad it worked for you.

Keep you eye on this blog, I’ll be uploaded a new install script for Zabbix that, among other things, will do an upgrade for you as you requested. I’m just doing some final testing on it right now.

Comment from cby
Time November 30, 2011 at 7:43 am

Great, look forward to testing and deploying it.

Write a comment

asd