Step 1
Step 1
Step 1
This way, SELinux will not block anything, but the audit log will fill up with what
would have been denied. And later in step 12, we can create an SELinux policy based
on that.
OR
You can find more information about Zabbix’s life cycle and release policies on the
official website.
mariadb-secure-installation
Enter current password for root (enter for none): Press Enter
Switch to unix_socket authentication [Y/n] y
Change the root password? [Y/n] y
New password: <Enter root DB password>
Re-enter new password: <Repeat root DB password>
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y
c. Create database
Create a database for Zabbix directly from the terminal using these two commands:
Open zabbix_server.conf file with command (use “vi” if you don’t have “nano” installed”):
DBPassword=zabbixDBpass
NOTE: If you get an error saying that the minimum required version of php is 7.4, upgrade
your PHP using these commands:
Basically, in this wizard you only need to enter a password for Zabbix DB user and for
everything else just click “Next step“. In this guide, I have used a zabbixDBpass as a database
password, but if you set something else, be sure to enter the correct password when prompted by
the wizard.
1. Installation step: Welcome screen
2. Installation step: Pre-requisites check
3. Installation step: Configure DB connection
4. Installation step: Configure Zabbix server
5. Installation step: Pre-installation summary
6. Installation step: Finish
CONGRATULATIONS!
You have successfully installed Zabbix 6 on CentOS / RHEL and now you can
monitor anything!
No need to change anything else as other steps are optional.
That problem can be easily solved with the database partitioning. Partitioning creates tables for
each hour or day and drops them when they are not needed anymore. SQL DROP is way more
efficient than the DELETE statement.
You can partition MySQL tables in 5 minutes using this simple guide.
StartPollers=100
StartPollersUnreachable=50
StartPingers=50
StartTrappers=10
StartDiscoverers=15
StartPreprocessors=15
StartHTTPPollers=5
StartAlerters=5
StartTimers=2
StartEscalators=2
CacheSize=128M
HistoryCacheSize=64M
HistoryIndexCacheSize=32M
TrendCacheSize=32M
ValueCacheSize=256M
This is not a perfect configuration, keep in mind that you can optimize it even more. Let’s say if
you don’t use ICMP checks then set the “StartPingers” parameter to 1 or if you don’t use
active agents then set “StartTrappers” to 1 and so on. You can find out more about the
parameters supported in a Zabbix server configuration file in the official documentation.
If you try to start the Zabbix server you may receive an error “[Z3001] connection to
database 'Zabbix' failed: [1040] Too many connections” in the log
“/var/log/zabbix/zabbix_server.log” because we are using more Zabbix server processes
than MySQL can handle. We need to increase the maximum permitted number of simultaneous
client connections and optimize MySQL – so move to the next step.
Step 10: Optimizing MySQL/MariaDB database (optional)
a. Create custom MySQL configuration file
[mysqld]
max_connections = 404
innodb_buffer_pool_size = 800M
innodb-log-file-size = 128M
innodb-log-buffer-size = 128M
innodb-file-per-table = 1
innodb_buffer_pool_instances = 8
innodb_old_blocks_time = 1000
innodb_stats_on_metadata = off
innodb-flush-method = O_DIRECT
innodb-log-files-in-group = 2
innodb-flush-log-at-trx-commit = 2
tmp-table-size = 96M
max-heap-table-size = 96M
open_files_limit = 65535
max_connect_errors = 1000000
connect_timeout = 60
wait_timeout = 28800
Save and exit the file (ctrl+x, followed by y and enter) and set the correct file permission:
The second most important parameter is innodb_buffer_pool_size, which determines how much
memory can MySQL get for caching InnoDB tables and index data. You should set that
parameter to 70% of system memory if only database is installed on server.
However, in this case, we are sharing a server with Zabbix and Apache processes so you should
set innodb_buffer_pool_size to 40% of total system memory. That would be 800 MB because
my CentOS server has 2 GB RAM.
I didn’t have any problems with memory, but if your Zabbix proxy crashes because of lack of
memory, reduce “innodb_buffer_pool_size” and restart MySQL server.
Note that if you follow this configuration, you will receive “Too many processes on the
Zabbix server” alarm in Zabbix frontend due to the new Zabbix configuration. It is safe to
increase the trigger threshold or turn off that alarm (select “Problems” tab → left click on the
alarm → select “Configuration” → remove the check from “Enabled” → hit the “Update”
button)
Zabbix Server
systemctl <status/restart/start/stop> zabbix-server
MySQL/MariaDB Server
systemctl <status/restart/start/stop> mysql
Apache Server
systemctl <status/restart/start/stop> httpd
Zabbix Agent
systemctl <status/restart/start/stop> zabbix-agent
At the beginning of this guide, we did not turn off SELinux completely but configure it to work
in the permissive mode which means it will log all the security errors but will not block anything.
If you accidentally left it in enforcing mode then you will receive the “Zabbix server is not
running: the information displayed may not be current” warning on the Zabbix
frontend and “cannot set resource limit: [13] Permission denied” in the log file.
Don’t worry, this can be easily fixed, so without further delay, let’s configure SELinux for
Zabbix!
setsebool -P httpd_can_connect_zabbix 1
Enable SELinux boolean “zabbix_can_network” that will allow Zabbix to connect to all TCP
ports :
setsebool -P zabbix_can_network on
And to avoid error “cannot start HA manager: timeout while waiting for HA manager
registration” enable daemons_enable_cluster_mode with this command:
setsebool -P daemons_enable_cluster_mode on
# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Memory protection checking: actual (secure)
Max kernel policy version: 31
semodule -i zabbix_policy.pp
Also, to avoid “Database error on login” on CentOS 9 please run these command
sealert -a /var/log/audit/audit.log
There is no need for backups when doing a minor upgrade, they are completely safe. With this
command you can easily upgrade minor versions of 6.0.x (for example, from 6.0.1 to 6.0.5):