About Zabbix
Zabbix is a free and open source network monitoring Software tool which is used to monitor and track the availability and performance of your IT infrastracture: servers, network devices and other IT assets.
In this article we will install Zabbix 3.2 on CentOS 7 and RHEL 7, in order to use Zabbix we required a Web Server (Apache), database server(Mysql, Mariadb, Postgresql …) and PHP to work.
If you want to install the new version of Zabbix 3.4 on CentOS 7 or RHEL 7 you can visit this article :
– How To Install Zabbix 3.4 Server On CentOS 7 / RHEL 7
Environment:
- Hostname = zabbix.yallalabs.com
- IP Address = 192.168.1.201
- OS = CentOS 7 / RHEL 7
Before we begin, note that I have installed lamp stack in my server:
[root@zabbix ~]# yum update [root@zabbix ~]# yum install httpd -y [root@zabbix ~]# yum install php php-cli php-common php-devel php-pear php-gd php-mbstring php-mysql php-xml -y [root@zabbix ~]# yum install mariadb-server -y [root@zabbix ~]# systemctl enable httpd && systemctl start httpd [root@zabbix ~]# systemctl enable mariadb && systemctl start mariadb
– Don’t forget to set a password for the root using mysql_secure_installtion, take a look to this tutorial: Securing MySQL server / Mariadb with mysql_secure_installation
Step 1 – Install Zabbix Server with MySQL
Before starting the installation we need to enable the zabbix repository using this commands:
[root@zabbix ~]# rpm --import http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX [root@zabbix ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
Now use the below command to install Zabbix and necessary packages
[root@zabbix ~]# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-get zabbix-sender zabbix-java-gateway -y
Step 2 – Edit PHP timezone
Open the file /etc/httpd/conf.d/zabbix.conf created by Zabbix with your favourite editer
[root@zabbix ~]# vi /etc/httpd/conf.d/zabbix.conf
It’s necessary to uncomment the “date.timezone” setting and set the right timezone for you.
php_value date.timezone Europe/Rome
Save the file and don’t forget to reload httpd service using the below command
[root@zabbix ~]# systemctl reload httpd
Step 3 – Edit create and import initial zabbix database and user
First we need to create zabbix database (zabbixdb) and create a zabbix user (zabbixuser).
[root@zabbix ~]# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 10 Server version: 5.5.47-MariaDB MariaDB Server Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> CREATE DATABASE zabbixdb CHARACTER SET utf8 COLLATE utf8_bin; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON zabbixdb.* TO zabbixuser@localhost IDENTIFIED BY "Password"; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> exit Bye [root@zabbix ~]#
– After creating the zabbix database and user we need to import the zabbix initial database using the below commands (make sure to change zabbix-server-mysql-3.2.X to the correct version number):
[root@zabbix ~]# zcat /usr/share/doc/zabbix-server-mysql-3.2.x/create.sql.gz | mysql -uroot -p zabbixdb
– Now we need to edit database configuration in the zabbix server configuration file zabbix_server.conf
[root@zabbix ~]# vi /etc/zabbix/zabbix_server.conf
Specify the database name for zabbix , database user name and the password
DBHost=localhost DBName=zabbixdb DBUser=zabbixuser DBPassword=Password
Step 4 – Set SELinux settings and adjust Firewall
[root@zabbix ~]# setsebool -P httpd_can_network_connect=1 [root@zabbix ~]# setsebool -P httpd_can_connect_zabbix=1 [root@zabbix ~]# setsebool -P zabbix_can_network=1
[root@zabbix ~]# firewall-cmd --permanent --add-service=http success [root@zabbix ~]# firewall-cmd --permanent --zone=public --add-port=10051/tcp success [root@zabbix ~]# firewall-cmd --permanent --zone=public --add-port=10050/tcp success [root@zabbix ~]# firewall-cmd --reload success
After adjusting the Selinux settings and the firewall we need to enable and start zabbix service on boot using the bellow commands
[root@zabbix ~]# systemctl enable zabbix-server && systemctl start zabbix-server [root@zabbix ~]# systemctl enable zabbix-agent && systemctl start zabbix-agent
Step 5 – Configure Zabbix via Web console
– Navigate to http://ip_address/zabbix or http://host_name/zabbix
– Now you’ll be redirected to the zabbix web console page. Enter the default username and password Admin/zabbix.
Last thing to do is to enable your server zabbix to be monitored: go to Configuration -> Hosts. Select the host (zabbix server) and click “Disabled”
That’s it, in the next tutorial we going to explain how install zabbix agent and add host in zabbix server.
We hope this tutorial was enough Helpful. If you need more information, or have any questions, just comment below and we will be glad to assist you!
18 comments
Hi,
At this step, I got this error :
[root@CentOS7-QARD1 etc]# mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (111)
[root@CentOS7-QARD1 etc]#
Any idea to fix it ?
Thx for your help.
Regards,
J.P.
Hi,
At this step , I got following error :
[root@CentOS7-QARD1 etc]# mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (111)
[root@CentOS7-QARD1 etc]#
Any idea to fix it ?
Thx for help.
Regards,
J.P.
Hi jribeauv,
You have to start Mysql Server/ Mariadb, using the following command
systemctl enable mariadb-server
systemctl start mariadb-server
I am getting the error :The frontend does not match Zabbix database.” while following step 5 . If i can show u the pic that would be good.
Ehsan
Hi EHSAN, try to Check the name of zabbix database created in the step number 3 .
zcat /usr/share/doc/zabbix-server-mysql-3.2.x/create.sql.gz | mysql -uroot -p zabbixdb
change zabbix-server-mysql-3.2.X to correct version number… e.g zabbix-server-mysql-3.2.6
Hi Lotfi Waderni
my problem is the moment to enable and start service for the zabbix server
systemctl enable zabbix-server && systemctl start zabbix-server
Job for zabbix-server.service failed because a configured resource limit was exceeded. See “systemctl status zabbix-server.service” and “journalctl -xe” for details
First of all, check if SELinux allows Zabbix to connect to the network using the follwing command :
getsebool -a | grep zabbix
The second thing is some kind of bug in the recent packages of ‘gnutls’ on CentOS 7 . Check which version and downgrade it to another version .
Let’ me know if you fixed.
If you are installing zabbix On centos /RHEL 7.3
You have to do this
# yum install policycoreutils-python
SELINUX for Zabbix-server:
# cat /var/log/audit/audit.log | grep zabbix_agentd | grep denied | audit2allow -M zabbix_agent_setrlimit
# semodule -i zabbix_agent_setrlimit.pp
SELINUX for Zabbix-agent:
# cat /var/log/audit/audit.log | grep zabbix_server | grep denied | audit2allow -M zabbix_server_setrlimit
# semodule -i zabbix_server_setrlimit.pp
and finally
# systemctl start zabbix-server
# systemctl start zabbix-agent
Hi LOTFI WADERNI,
My question is when to run these SELINUX commands?
Thanks
Hi LOTFI WADERNI,
I found the answer myself. In centOS 7.3, you will run into the error of “limited resource”, and that is when you run these commands. I also provide some feedback to you :
In your post, you mixed up the to cat command between zabbix server and agent heading.
But I also have another question here:
In this link, https://www.zabbix.com/forum/showthread.php?t=57691, I found an interesting about innodb for mysql.
Since I am not a linux/mysql pro, i don’t quite follow it, but understood that it is better to start like that to prevent over-run database files in the future. Could you shed a little light on that.
I understand it might not be the right spot to ask, and forgive me for this but your post is so clear and details that make me believe you are the helpful techie. Thanks
Hi DBui,
Thank you for comming by our website, hope you find our articles very helpful, yes you can make some changes to the database file configuration to improve the good function of zabbix server but it’s not mandatory steps .
HI, my question is, do you realy think that all of this packet are needed? My opinion t you install to many?
Hi, great article!
This helped me a lot I would suggest you would also run:
mysql_secure_installation
So that the root user is not password less.
After that is had to update the:
/etc/selinux/config
and set:
SELINUX=permissive
(this seem to stop me from running the server, also the comment of Lofti seems a great idea)
reboot and done! on the latest and greatest C7
Hopes this helpes!
Hi WILLIAM, Thanks alot for your comment, we have mentioned in the article that you have to run the command mysql_secure_installation after installing mariadb-server.
Regarding to Selinux, it’s not recomanded to disable it . it’s much better to create some exception policy as mentioned in the above comment if your are installing it on centos /RHEL 7.3.
If you like our Tutorials please sharet hem with your friends and subscribe to our youtube channel .
Hi Dear Lotfi,
Firstly this is nice article thank a lot of about this. I hope you Show us more than 🙂
My question is , mariadb and mysql different database program. Why we have to install both of them? What is their duty?
Thank you again.
Amazing post, keep up the good work buddy.
Another comment if i may add: Please check the sestatus and make sure its in the “permissive” mode and not in the “enforcing” mode otherwise Zabbix agent will not run and might give you issues. Please follow the instructions.
vim /etc/selinux/config
SELINUX=permissive (instead of enforcing)
reboot the machine and re-check the sestatus.
This will make your life much easier.
Best regards.