Zabbix sur Rocky Linux 9
Installation de Zabbix pour le monitoring enterprise.
| Composant |
Version |
| Rocky Linux |
9.x |
| Zabbix |
6.4+ |
| MariaDB |
10.5+ |
| Apache/Nginx |
Latest |
Durée estimée : 45 minutes
Architecture
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Zabbix Agent │────►│ Zabbix Server │◄────│ Zabbix Proxy │
│ (hosts) │ │ (central) │ │ (remote sites) │
└─────────────────┘ └────────┬────────┘ └─────────────────┘
│
┌──────────┼──────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ MariaDB │ │ Frontend │ │ Alerting │
└──────────┘ └──────────┘ └──────────┘
1. Prérequis
Base de données
dnf install -y mariadb-server
systemctl enable --now mariadb
mysql_secure_installation
Apache et PHP
dnf install -y httpd php php-mysqlnd php-gd php-bcmath php-mbstring php-xml php-ldap
2. Installation Zabbix
Ajouter le repository
rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/9/x86_64/zabbix-release-6.4-1.el9.noarch.rpm
dnf clean all
Installer les composants
dnf install -y zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent
3. Configuration base de données
CREATE DATABASE zabbix CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'zabbix_password';
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';
SET GLOBAL log_bin_trust_function_creators = 1;
FLUSH PRIVILEGES;
EXIT;
Importer le schéma
zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
Désactiver log_bin_trust_function_creators
mysql -u root -p -e "SET GLOBAL log_bin_trust_function_creators = 0;"
4. Configuration Zabbix Server
vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix_password
# Performance
StartPollers=10
StartPollersUnreachable=5
StartTrappers=5
StartPingers=5
StartDiscoverers=3
# Cache
CacheSize=128M
HistoryCacheSize=64M
TrendCacheSize=32M
ValueCacheSize=64M
# Alerting
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
5. Configuration PHP
vim /etc/php-fpm.d/zabbix.conf
php_value[date.timezone] = Europe/Paris
php_value[max_execution_time] = 300
php_value[memory_limit] = 128M
php_value[post_max_size] = 16M
php_value[upload_max_filesize] = 2M
php_value[max_input_time] = 300
php_value[max_input_vars] = 10000
6. SELinux
setsebool -P httpd_can_connect_zabbix on
setsebool -P httpd_can_network_connect_db on
setsebool -P zabbix_can_network on
7. Démarrer les services
systemctl enable --now zabbix-server zabbix-agent httpd php-fpm
systemctl restart zabbix-server zabbix-agent httpd php-fpm
8. Firewall
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-port=10051/tcp # Server
firewall-cmd --permanent --add-port=10050/tcp # Agent
firewall-cmd --reload
9. Configuration Frontend
- Ouvrir
http://IP/zabbix
- Suivre l'assistant d'installation
- Credentials par défaut :
Admin / zabbix
10. Zabbix Agent (sur les hôtes)
Installation
rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/9/x86_64/zabbix-release-6.4-1.el9.noarch.rpm
dnf install -y zabbix-agent
Configuration
vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.1.10
ServerActive=192.168.1.10
Hostname=client-hostname
EnableRemoteCommands=1
LogFileSize=10
Démarrer
systemctl enable --now zabbix-agent
firewall-cmd --permanent --add-port=10050/tcp
firewall-cmd --reload
11. Zabbix Agent 2 (moderne)
dnf install -y zabbix-agent2 zabbix-agent2-plugin-*
vim /etc/zabbix/zabbix_agent2.conf
Server=192.168.1.10
ServerActive=192.168.1.10
Hostname=client-hostname
systemctl enable --now zabbix-agent2
12. Templates et découverte
Ajouter un hôte
- Configuration → Hosts → Create host
- Hostname, Groups, Interface (Agent)
- Templates : Linux by Zabbix agent
Auto-découverte
- Configuration → Discovery
- IP range, checks (Zabbix agent, SNMP, etc.)
Auto-registration
# Sur l'agent
HostMetadata=Linux
13. Alerting
Email
- Administration → Media types → Email
- SMTP server, port, credentials
- Users → Media → Add email
Webhook (Slack/Teams)
- Administration → Media types → Slack/MS Teams
- Configurer le webhook URL
14. Monitoring avancé
SNMP
dnf install -y net-snmp net-snmp-utils
JMX (Java)
dnf install -y zabbix-java-gateway
systemctl enable --now zabbix-java-gateway
# zabbix_server.conf
JavaGateway=127.0.0.1
JavaGatewayPort=10052
StartJavaPollers=5
15. Proxy (sites distants)
dnf install -y zabbix-proxy-mysql
# zabbix_proxy.conf
Server=zabbix-server-ip
Hostname=proxy-name
DBName=zabbix_proxy
ProxyMode=0 # Active
Maintenance
# Housekeeping
# Dans zabbix_server.conf
HousekeepingFrequency=1
MaxHousekeeperDelete=5000
# Purge historique (SQL)
DELETE FROM history WHERE clock < UNIX_TIMESTAMP(NOW() - INTERVAL 30 DAY);
DELETE FROM trends WHERE clock < UNIX_TIMESTAMP(NOW() - INTERVAL 365 DAY);
Commandes utiles
# Status serveur
zabbix_server -R config_cache_reload
zabbix_server -R housekeeper_execute
# Test agent
zabbix_get -s 192.168.1.20 -k system.hostname
zabbix_get -s 192.168.1.20 -k agent.ping
# Logs
tail -f /var/log/zabbix/zabbix_server.log
tail -f /var/log/zabbix/zabbix_agentd.log
Dépannage
| Problème |
Solution |
| Agent unreachable |
Vérifier firewall, port 10050 |
| Permission denied |
SELinux, vérifier booleans |
| DB connection |
Vérifier credentials |
| Frontend lent |
Augmenter cache PHP |
# Debug
zabbix_server -c /etc/zabbix/zabbix_server.conf -f
journalctl -u zabbix-server -f
Changelog
| Date |
Modification |
| 2024-12 |
Création initiale |