Installation and configuration of Zabbix monitoring. Centos7
In this post, we install and configure a server-zabbix 4.0 LTS and add him to one agent. Zabbix configuration is one of the basic things that a good admin should be able to.
Zabbix is a solution (do not be afraid to say) enterprise-class monitoring service problems. Is used to collect, analysis and data visualization. The software is also able to detect any anomalies in our infrastructure and to notify the user accordingly.
Installing zabbix
Install repositories EPEL, webtatic i zabbix:
1 2 3 | yum -y install epel-release rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm rpm -i https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm |
Install php version 7.2
1 | yum -y install mod_php72w php72w-cli php72w-common php72w-devel php72w-pear php72w-gd php72w-mbstring php72w-mysql php72w-xml php72w-bcmath |
Install httpd server:
1 | yum install httpd |
Clean the iptables rules
1 | iptables -F |
Edit the php.ini file and change the configuration as follows:
1 | nano /etc/php.ini |
1 2 3 4 5 6 | max_execution_time = 600 max_input_time = 600 memory_limit = 256M post_max_size = 32M upload_max_filesize = 16M date.timezone = Europe/Warsaw |
Instaujemy MariaDB and configure the root password:
1 2 3 | yum -y install mariadb-server mariadb service mariadb start mysql_secure_installation |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | [root@zabbix /]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB! |
Zabbix create a database and user zabbix ( alternatively add access to a server mysql from outside; password change on their own , difficult password dictionary):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | m# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 14 Server version: 5.5.56-MariaDB MariaDB Server Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> create database zabbix; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@'localhost' identified by 'mojetajnehaslo'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@'%' identified by 'mojetajnehaslo'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> MariaDB [(none)]> quit Bye |
Install the server and its agent zabbix:
1 | yum -y install zabbix-get zabbix-server-mysql zabbix-web-mysql zabbix-agent |
We import a database Zabbix:
1 2 3 | cd /usr/share/doc/zabbix-server-mysql-4.0.0/ gunzip < create.sql.gz |mysql -u root -p zabbix Enter password: |
We configure the server zabbix giving the details in our database created:
Edit your /etc/zabbix/zabbix_server.conf
1 | nano /etc/zabbix/zabbix_server.conf |
I give the following data:
1 2 3 4 | DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=haslo |
Start the server zabbix, We add to startup and check if it works:
1 2 3 | systemctl start zabbix-server systemctl enable zabbix-server systemctl status zabbix-server |
1 2 3 4 5 6 7 8 9 10 11 12 | ● zabbix-server.service - Zabbix Server Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; disabled; vendor preset: disabled) Active: active (running) since Fri 2018-10-05 09:47:06 UTC; 14s ago Process: 1789 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS) Main PID: 1791 (zabbix_server) CGroup: /system.slice/zabbix-server.service └─1791 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf Oct 05 09:47:06 zabbix systemd[1]: Starting Zabbix Server... Oct 05 09:47:06 zabbix systemd[1]: zabbix-server.service: Supervising proce...s. Oct 05 09:47:06 zabbix systemd[1]: Started Zabbix Server. Hint: Some lines were ellipsized, use -l to show in full |
We run the agent in a similar manner.
1 2 3 | systemctl start zabbix-agent systemctl enable zabbix-agent systemctl status zabbix-agent |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | zabbix-agent.service - Zabbix Agent Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2018-10-05 09:48:43 UTC; 30s ago Main PID: 1821 (zabbix_agentd) CGroup: /system.slice/zabbix-agent.service ├─1821 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf ├─1822 /usr/sbin/zabbix_agentd: collector [idle 1 sec] ├─1823 /usr/sbin/zabbix_agentd: listener #1 [waiting for connectio... ├─1824 /usr/sbin/zabbix_agentd: listener #2 [waiting for connectio... ├─1825 /usr/sbin/zabbix_agentd: listener #3 [waiting for connectio... └─1826 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec] Oct 05 09:48:43 zabbix systemd[1]: Starting Zabbix Agent... Oct 05 09:48:43 zabbix systemd[1]: PID file /run/zabbix/zabbix_agentd.pid n...t. Oct 05 09:48:43 zabbix systemd[1]: Started Zabbix Agent. Hint: Some lines were ellipsized, use -l to show in full. |
We do restart httpd command:
1 | service httpd restart |
We go to the browser and enter the address:
1 | http://IP_SERWERA/zabbix/ |
If instead we have a window installer bug 500 , and in the error log the error "Can not start session" must be empowered to Session Directory:
1 | chmod 777 /var/lib/php/session |
We start the installer window.
go further, where they should be satisfied all requirements.
In the next step, we enter data into our database.
Data and configure the server name zabbix
we receive confirmation:
Congratulations! You have successfully installed Zabbix frontend.
Configuration file “/etc/zabbix/web/zabbix.conf.php” created.
We are directed to the panel zabbix - The default username is admin and the password is zabbix
After logging in, we can change the language to Polish that we were comfortable in it to operate - in this order on the right side at the top, select the icon, and then change the human language.
Ready - now we monitor our server!
For testing, we can install such a stress load and perform artificial:
1 2 3 4 | yum install stress -y # stress --cpu 3 --timeout 70 stress: info: [3497] dispatching hogs: 3 cpu, 0 io, 0 vm, 0 hdd stress: info: [3497] successful run completed in 70s |
To verify that the server monitors the load properly go to Monitorowanie-> Charts , and the Chart choose "CPU Utilization":
There is already Zabbix 5. I recommend you test the new version. A lot of simplifying changes and a changed interface.
Maybe you are willing to write a guide about it? 🙂
When I got acquainted with Zabbix, I installed MySQL and Apache helped me with this article: https://blog.askomputer.pl/instalacja-mysql-i-apache-pod-zabbix/