PDA

View Full Version : Zabbix Installation Ubuntu Server


NomenNescio
11-02-2009, 15:37
A clean Zabbix installation 1.6.2 server and agent on Ubuntu Server.
This tutorial assumes you have LAMP (Linux Apache MySql PHP) installed. You can choose to install it while installing Ubuntu Server.
First you will have to install the following packages:

gcc
libmysql++-dev
libcurl4-gnutls-dev
snmp
libsnmp-dev
php5-gd

These can be installed by the following command

sudo apt-get install ‘package name here’

for example:

sudo apt-get install gcc

Do this with all the packages mentioned above.
After you have done this, make a ‘zabbix’ account on linux, and add him to the admin group. You can do that with the following commands:

sudo adduser zabbix

and after you have created this user account, you can add it to the admin group with the this command:

sudo adduser zabbix admin

Then log into your zabbix account. Make sure you are in your home directory. You can check this by typing the command pwd it will show your current location. Your home directory probably is /home/zabbix and if it is not you can get there by typing:

cd ~ or by typing cd /home/zabbix

Now you should download the zabbix binaries. Go to the Zabbix website, “http://zabbix.com” to download the Zabbix binaries. You can download the Zabbix binaries from the command line by typing:

wget ‘direct link here’

Find the link to the Zabbix binaries and use the wget command. When I downloaded zabbix, my direct link was: (yours might be different)

wget http://mesh.dl.sourceforge.net/sourceforge/zabbix/zabbix-1.6.2.tar.gz

after you have downloaded the file, you can extract it by typing:

tar –xvzf zabbix-1.6.2.tar.gz

get in the extracted directory:

cd zabbix-1.6.2

now we must create the zabbix database and tables, you can do that by typing the following commands:

mysql –u’user’ –p’Secret’ (Example: mysql –uroot –pSecret )

create database zabbix; (don’t forget the ; )

verify that you created the database by typing “show databases”, zabbix should be in the list now.
Type quit to exit MySql
Now we must populate the Zabbix database with tables. We can do this with the following commands (assuming you are in the zabbix-1.6.2 directory):

cat create/schema/mysql.sql | mysql –uroot –pToekomst06 zabbix
cat create/data/data.sql | mysql –uroot –pToekomst06 zabbix
cat create/data/images_mysql.sql | mysql –uroot –pToekomst06 zabbix

Now we run configure (assuming you are still in the zabbix-1.6.2 directory), enter the following command:

sudo ./configure --enable-server --enable-agent --with-net-snmp --with-libcurl --with-mysql

(You can choose to install more, look in the manual for more info)

Now type:

sudo make

and then

sudo make install

now we must create a directory to put the zabbix config files in. Issue the following commands:

sudo mkdir /etc/zabbix
sudo cp misc/conf/zabbix_* /etc/zabbix/

We will edit those config files later, first we must place the php frontend somewhere.

sudo mkdir /home/zabbix/web
sudo cp -R frontends/php/* /home/zabbix/web
sudo chown –R zabbix /home/zabbix/web

now, you must edit the file /etc/apache2/sites-enabled/000-default, first go to that directory:

cd /etc/apache2/sites-enables

Then edit the file with your editor of choice, mine’s vim so I’ll use vim for the rest of the tutorial.

sudo vim 000-default

change the line:
DocumentRoot /var/www/
To
DocumentRoot /home/zabbix/web/
and change the line :
<Directory /var/www/>
To
<Directory /home/zabbix/web/>
now open the file services in /etc

sudo vim /etc/services

and add the following lines:
zabbix-agent 10050/tcp
zabbix-agent 10050/udp
zabbix-trap 10051/tcp
zabbix-trap 10051/tcp

now we must set the timezone and php execution time in php.ini
php.ini is located in /etc/php5/apache2/php.ini

open it with your editor

sudo vim /etc/php5/apache2/php.ini

change the line:
max_execution_time = 30
to
max_execution_time = 300

and
change the line:
;date.timezone =
to
date.timezone = ‘your time zone here’, for example, I changed the mine to
date.timezone = Europe/Amsterdam
Supported timezone values can be found here:
http://www.php.net/manual/en/timezones.php
And don’t forget to remove the ;

save the file and exit.
restart apache by typing:

sudo apache2ctl -k graceful

(you have to restart apache every time you make a change to 000-default or php.ini to apply the changes)

now go to the zabbix config files we moved to /etc/zabbix, type

cd /etc/zabbix

Edit the zabbix_server.conf file and
change
#ListenPort=10051
to
ListenPort=10051

change the line
DBUser=root
to
DBUser=(user that has the rights to the zabbix database, this could also be root)

change the line

#DBPassword=<password>
to
DBpassword=(password for the database user)

Save the changes and open zabbix_agentd.conf file which is in the same directory as zabbix_server.conf.

The line Server=127.0.0.1 does not have to be changed because zabbix server is running on the same machine. If you had installed zabbix agent on a different computer, you would have to set the IP to the machine where zabbix server is running.

change the line
#ServerPort=10051
to
ServerPort=10051

The line
Hostname= You may change this to a name you would like to give your host.

Change the line
#ListenPort=10050
to
ListenPort=10050

Save and exit.

Start up a web browser and type the server’s IP in the address bar. Insert all data, make sure it works, then save the resulting file in the specified linux directory.

Zabbix is now installed, you can now log into zabbix, the default zabbix admin login is:

Username: Admin
Password: Zabbix

bbrendon
12-02-2009, 07:28
Why not install the packages?

NomenNescio
12-02-2009, 14:38
Doesn't that usually install an older version?

bbrendon
16-02-2009, 02:57
No. Both Ubuntu and debian have current packages.

NomenNescio
16-02-2009, 09:03
Ah whatever, it might help someone who wants to do it the difficult way :D

tchjts1
16-02-2009, 23:54
Those directions also exist on the Zabbix Wiki - http://www.zabbix.com/wiki/doku.php?id=howto:ubuntuinstall

Community involvement is always good though!

bbrendon
18-02-2009, 02:58
Ah whatever, it might help someone who wants to do it the difficult way :D
LOL. Yes, there are scripts for that too :)

There was a long thread once upon a time about how hard it was to install zabbix...blah blah complain complain.

So I wrote this to silence them :)
http://blog.brendon.com/tag/zabbix/

elg
26-02-2009, 15:45
For ubuntu, the packages available are 1.4.2, not the latest released.

root@zabbixsrv:~# apt-cache show zabbix-server-mysql
Package: zabbix-server-mysql
Priority: optional
Section: universe/net
Installed-Size: 2456
Maintainer: Ubuntu MOTU Developers <ubuntu-motu@lists.ubuntu.com>
Original-Maintainer: Zabbix Maintainers <kobold-zabbix@debian.org>
Architecture: i386
Source: zabbix
Version: 1:1.4.2-4ubuntu3

bbrendon
26-02-2009, 19:28
Are you sure about that?
http://packages.debian.org/source/sid/zabbix

Tenzer
27-02-2009, 10:13
Are you sure about that?
http://packages.debian.org/source/sid/zabbix

Who are going to run a Debian server with the 'testing' or 'unstable' repositories?
The fact is that neither Ubuntu or Debian has a current version of Zabbix in their stable releases:
http://packages.ubuntu.com/search?keywords=zabbix-agent
http://packages.debian.org/search?keywords=zabbix-agent

bbrendon
02-03-2009, 21:11
Who are going to run a Debian server with the 'testing' or 'unstable' repositories?
Hopefully no one.
The fact is that neither Ubuntu or Debian has a current version of Zabbix in their stable releases:
I'm not sure how that is relevant. The source packages are available.

troffasky
04-03-2009, 13:52
The fact is that neither Ubuntu or Debian has a current version of Zabbix in their stable releases:

There's usually a reason for that.

DSon
05-10-2009, 12:53
Thanks for the instructions thus far in this thread. I'm having a problem with each of our Zabbix servers, namely that the zabbix_server service doesn't auto start.

The zabbix_server.log file states an error "creating mutex for log file". If I restart the server service it (mostly) won't work, stating "error connecting to mysql socket". If I then restart the server service for the 2rd time, it comes up okay.

Has anyone else had this behaviour?

I think it may be something to do with the startup sequence / timing - maybe that zabbix is trying to start before mysql / something else?

If anyone has any thoughts I'd be very greatful.

:D

Thanks,
DSon.

tchjts1
05-10-2009, 19:34
It would be helpful if you told us the version of Zabbix and Ubuntu that you have.

if the service is not auto starting, did you complete this step of the install?


Set the correct permissions and set ZABBIX to start when the machine boots:
sudo chmod 755 /etc/init.d/zabbix-server
sudo update-rc.d zabbix-server defaults
sudo chmod 755 /etc/init.d/zabbix-agent
sudo update-rc.d zabbix-agent defaults

DSon
06-10-2009, 10:13
Ok, thanks for the help- my version of Ubuntu is 8.10 and Zabbix is version 1.6.4.

I've also checked a couple of things and found out the following:

- there may be a permissions issue

If I try and run zabbix-server (start|restart|stop) it tells me "access denied" when trying to remove the .PID file (nor does it create a .PID file if one doesn't exist). I've verified the owner of the /var/run/zabbix-server directory is "zabbix", as well as the /etc/init.d/zabbix-server (also "zabbix"). Maybe there is something wrong with the zabbix user? It is a member of both the "zabbix" and "admin" groups - is this not sufficient to allow the zabbix user to create a .PID file? The only way I can run zabbix-server is by putting "sudo" before it. As explained previously, even using sudo still requires me to run zabbix-server (with -restart) TWICE before it runs without an error in the log file (first the "unable to connect through mysql.sock error, second the ""mutex" error).

- the zabbix-server daemon is definitely trying to start too early

When I watch the server boot up sequence I can see zabbix_server starting (well trying to start) before MySQL. The zabbix_server log file also shows the message "unable to connect through mysql.sock" - presumably because MySQL wasn't running when zabbix_server tried to connect to the dbase. I have tried using "update-rc.d" to specifiy a higher priority (e.g. 30 - 99) but this makes only a slight difference. Maybe there is a way of telling the zabbix_server to "pause" until it sees the MySQL .PID file appear?

I think if I can get the zabbix_server process to start AFTER MySQL, instead of the "unable to connect through mysql.sock"

Please help!
:confused:
DSon.

DSon
06-10-2009, 10:49
.. following on from the previous information, what I tried doing was switching to the zabbix user ("su - zabbix") and then running zabbix-server (again, with the stop|start|restart switches) and it still says permission denied creating the .PID file. There is also no new entry in the zabbix_server.log file when doing this.

The zabbix user seems to have some sort of permissions problem - however it is confusing since during the server start up it is definitely getting further. What I mean is it seems to me that although the zabbix user account can't create the .PID (or a log file entry) when I use "su", at server start up when the zabbix_server process tries to start it definitely DOES creates a .PID file (therefore removing the previous one) AND it writes a log entry "unable to connect through myqsld.sock").

Where do I check to find out what user the zabbix_server process is trying to run under (i.e. at server boot up)?

DSon.

SRH
11-10-2009, 21:12
Hi.

First, thanks a lot for the installation instruction.

So, i have the problem, that in the /etc/init.d/... is no zabbix File also i can't start the zabbix_service (/etc/zabbix/) manualy with sudo zabbix_server start. sudo agentd_agent start - it will work but when i check the services with ps -aef | grep zabbix, i can see 4 or 5 agentd services. Strange, isn't it?

The Webfrontend works fine...
I use Ubuntu Server LTS 8.04 with Zabbix-1.6.6

Someone a idea? ( I follow exactly the installation instruction)

By Roger

tchjts1
11-10-2009, 22:48
Hi.

First, thanks a lot for the installation instruction.

So, i have the problem, that in the /etc/init.d/... is no zabbix File also i can't start the zabbix_service (/etc/zabbix/) manualy with sudo zabbix_server start. sudo agentd_agent start - it will work but when i check the services with ps -aef | grep zabbix, i can see 4 or 5 agentd services. Strange, isn't it?

The Webfrontend works fine...
I use Ubuntu Server LTS 8.04 with Zabbix-1.6.6

Someone a idea? ( I follow exactly the installation instruction)

By Roger

Sounds like you skipped copying the files into /etc/init.d/ below are the steps for doing that. By the way, when you get the agent started, you are going to see multiple instances of zabbix_agentd running. By default, I believe it is 5. Same with zabbix_server

Anyway, follow these steps and you should be good to go:

Copy the init.d scripts to the right spot:

sudo cp misc/init.d/debian/zabbix-server /etc/init.d
sudo cp misc/init.d/debian/zabbix-agent /etc/init.d


You may need to edit these script files as the compiled versions of the zabbix files is placed under /usr/sbin (/usr/bin in older versions).


sudo nano /etc/init.d/zabbix-server
Look for the following line:
DAEMON=/home/zabbix/bin/${NAME}
and replace it with:
DAEMON=/usr/sbin/${NAME} (old versions use /usr/bin/${NAME})


Save and exit.


sudo nano /etc/init.d/zabbix-agent
Look for the following line:
DAEMON=/home/zabbix/bin/${NAME}
and replace it with:
DAEMON=/usr/sbin/${NAME} (old versions use /usr/bin/${NAME})


Save and exit.
Now set the correct permissions and set ZABBIX to start when the machine boots:


sudo chmod 755 /etc/init.d/zabbix-server
sudo update-rc.d zabbix-server defaults
sudo chmod 755 /etc/init.d/zabbix-agent
sudo update-rc.d zabbix-agent defaults


When those steps are done, you should be able to start the server and agent with these commands:

sudo /etc/init.d/zabbix-server start
sudo /etc/init.d/zabbix-agent start

and they should also auto-start on boot-up

SRH
12-10-2009, 19:24
Hi tchjts1

Thanks for your answear.

So these steps are done. I made one mistake in the zabbix-server and zabbix-agent file - Wrong path and i execute update.

When i try with the right path in both files and try to update again:
System startup links for /etc/init.d/zabbix-server already exist.
System startup links for /etc/init.d/zabbix-agent already exist.

???I think that is not importante when i execute the update syntax with the false path value in both file. Or I'm wrong? (i have no idea, how i can delete the startup link)???

zabbix_server will not start when the server reboots.

manualy sudo zabbix_server start - that works. By checking the log, zabbix_server had a problem to connect to the mysql. Now i fixed this problem and zabbix_server runs.

sudo zabbix_agentd start works, too (but not after a reboot)

By Roger

troffasky
01-11-2009, 21:22
I suggest you read the MySQL tuning thread and then post a new question if that thread doesn't answer your questions.

gospodin.horoshiy
15-11-2009, 15:06
Just a little extra: I suggest you add your zabbix user to adm group to:
sudo adduser zabbix adm

so you have priviligies to monitor log files on the server. (like /var/log/syslog)