目次
シングル構成のZabbix Server、及びZabbix FrontendをRocky Linux 8.x系にインストールする手順。
基本的なインストールとして、以下のURLの手順を理解した上で行うものとする。
https://www.zabbix.com/jp/download
Category | Package & Version | Architecture | Install Type | Repository |
OS | Rocky Linux release 8.6 (Green Obsidian) | x86-64 | RPM | Rocky-Stream-AppStream |
MySQL | mysql-8.0.26-1 | el8.x86-64 | RPM | Rocky-Stream-AppStream |
PHP | php-7.4.19-3 | el8.x86-64 | RPM | Rocky-Stream-AppStream |
PHP-FPM | php-fpm-7.4.19-3 | el8.x86-64 | RPM | Rocky-Stream-AppStream |
HTTPD | httpd-2.4.37-47 | el8.x86-64 | RPM | Rocky-Stream-AppStream |
SNMP | net-snmp-5.8-25 | el8.x86-64 | RPM | Rocky-Stream-AppStream |
Category | Package & Version | Architecture | Install Type | Repository |
Zabbix | zabbix-release-6.0-2 | el8.x86-64 | RPM | Zabbix |
Zabbix | zabbix-server-mysql-6.0.7-1 | el8.x86-64 | RPM | Zabbix |
Zabbix | zabbix-sql-scripts-6.0.7-1 | el8.x86-64 | RPM | Zabbix |
Zabbix | zabbix-js-6.0.7-1 | el8.x86-64 | RPM | Zabbix |
Zabbix | zabbix-selinux-policy-6.0.7-1 | el8.x86-64 | RPM | Zabbix |
Category | Package & Version | Architecture | Install Type | Repository |
Zabbix | zabbix-web-6.0.7-1 | el8.x86-64 | RPM | Zabbix |
Zabbix | zabbix-web-mysql-6.0.7-1 | el8.x86-64 | RPM | Zabbix |
Zabbix | zabbix-web-deps-6.0.7-1 | el8.x86-64 | RPM | Zabbix |
Zabbix | zabbix-web-japanese-6.0.7-1 | el8.x86-64 | RPM | Zabbix |
Zabbix | zabbix-apache-conf-6.0.7-1 | el8.x86-64 | RPM | Zabbix |
Category | Package & Version | Architecture | Install Type | Repository |
Zabbix | zabbix-web-service-6.0.7-1 | el8.x86-64 | RPM | Zabbix |
Chrome | google-chrome-stable | x86-64 | RPM |
Category | Package & Version | Architecture | Install Type | Repository |
Zabbix | zabbix-agent-6.0.7-1 | el8.x86-64 | RPM | Zabbix |
Zabbix | zabbix-agent2-6.0.7-1 | el8.x86-64 | RPM | Zabbix |
Category | Package & Version | Architecture | Install Type | Repository |
Zabbix | zabbix-get-6.0.7-1 | el8.x86-64 | RPM | Zabbix |
Zabbix | zabbix-sender-6.0.7-1 | el8.x86-64 | RPM | Zabbix |
インストールタイプは「サーバ(GUI使用)」構成を選択。
このタイプではEL6までとの互換性を確保するためのツール類が初めからインストールされるため、使いやすい構成で始めることができる。
サーバ用途ではGUIは不要のため、CLIモードに変更する。
systemctl set-default multi-user.target
# systemctl get-default multi-user.target
ZabbixのSELinux用ポリシーが提供される様になっているため、SELinuxを有効化した状態で導入することが可能となった。
利用環境に合わせてSELinuxの有効/無効を調整すること。
(RHEL9 / CentOS Stream 9以降はSELinuxの無効化が困難となるため、将来的には有効化した状態での運用が標準になると思われる。)
/etc/ssh/sshd_configに対して、適宜設定を行う。
PermitRootLogin no
PasswordAuthentication no
PermitEmptyPasswords no
※注意※
上記の設定反映後、新たにターミナルセッションを開いてSSH接続ができることを確認すること。
Firewallが不要な場合にはサービスを停止する。
systemctl stop firewalld systemctl disable firewalld
システムの動作上、不要となるサービスは停止する。
# systemctl disable [Service Name]
何が不要なサービスであるかは用途・環境により差異があるため個別に検討が必要。
ss -tulpn
systemctl list-units --type service
systemctl disable avahi-daemon.service systemctl disable cups.service systemctl disable gssproxy.service systemctl disable import-state.service systemctl disable iscsi-shutdown.service systemctl disable kdump.service systemctl disable nis-domainname.service systemctl disable selinux-autorelabel-mark.service systemctl disable sssd.service systemctl disable unbound-anchor.timer
監視システムにおいて時刻のズレは運用上の支障となるため、必ずサーバの時刻同期を設定する。
pool ntp.nict.jp iburst
systemctl restart chronyd.service
chronyc sources MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^* ntp-b2.nict.go.jp 1 6 37 9 -49us[-1008us] +/- 3416us ^- ntp-k1.nict.jp 1 6 37 9 +972us[ +972us] +/- 9645us ^- ntp-a2.nict.go.jp 1 6 37 9 +1330us[+1330us] +/- 4894us ^- ntp-b3.nict.go.jp 1 6 37 10 +21us[ +21us] +/- 4093usMS列で「*」が表示されているサーバと同期が完了している。
OS導入段階のパッケージを最新化する。
dnf update
ここまでの設定を一括反映するため、OSの再起動を行う。
reboot
Zabbixリポジトリをインストールする。
rpm -ivh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm dnf clean all
dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-web-service zabbix-js zabbix-get zabbix-sender
dnf install zabbix-agent
dnf install zabbix-agent2
Zabbixのパッケージインストールだけでは導入されないミドルウェアを先にインストールする。
DBMSとして使用するMariaDBのサーバサービスを導入する。
Zabbix6.0では、MariaDB 10.5以降がサポート対象となるため、モジュールの変更が必要となる。
yum module enable mariadb:10.5
メタデータの期限切れの最終確認: 0:02:02 時間前の 2023年02月04日 16時54分29秒 に実施しました。 依存関係が解決しました。 ==================================================================================================================================== パッケージ アーキテクチャー バージョン リポジトリー サイズ ==================================================================================================================================== モジュールストリームの有効化中: mariadb 10.5 トランザクションの概要 ==================================================================================================================================== これでよろしいですか? [y/N]: y 完了しました!
dnf install mariadb-server
SNMPTrapを受信するためにsnmptrapdサービスを導入する。
dnf install net-snmp net-snmp-utils net-snmp-perl
PHPのバージョンを7.4へ変更する。
PHPのスクリプトを動作させることを想定し、コマンドラインPHPも導入する。
dnf module switch-to php:7.4
dnf install php php-cli
zabbix-web-service(定期レポートの生成に使用)が使用するGoogle Chromeのパッケージを導入する。
リポジトリから自動的に取得することが出来ないため、手動でパッケージを入手して導入する。
dnf install ./google-chrome-stable_current_x86_64.rpm
操作面での互換性維持、並びにZabbixを運用する上で必要となるツールを導入する。
net-tools bind-utils nmap wget telnet※インストールタイプを「サーバ(GUI使用)」にしていた場合、一部のツールはすでに導入されている。
dnf install net-tools bind-utils nmap wget telnet
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock log-error=/var/log/mariadb/mariadb.log pid-file=/run/mariadb/mariadb.pid
systemctl start mariadb.service systemctl enable mariadb.service
パスワード設定などのセキュリティ関連の最低限の設定は付属のスクリプトを用いて設定を行う。
mysql_secure_installation
Securing the MySQL server deployment. Connecting to MySQL using a blank password. VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: y There are three levels of password validation policy: LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0 Please set the password for root here.
New password: Re-enter new password: Estimated strength of the password: 50 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y Success. By default, MySQL 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y Success. All done!
mysql -uroot -p
create database zabbix character set utf8mb4 collate utf8mb4_bin; create user zabbix@localhost identified by 'zabbix-server'; grant all privileges on zabbix.* to zabbix@localhost; set global log_bin_trust_function_creators = 1; quit;
zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
ServerName [FQDN]:80
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="uft-8"> <script> setTimeout("location.href='/zabbix/'",0); </script> <title>redirect</title> </head> <body> </body> </html>
# service httpd configtest Syntax OK
systemctl enable httpd systemctl start httpd
PHPが使用するメモリ上限の初期値は128MBとなっている。
表示内容が増えるとメモリ不足となるため、上限値を上げておく。
php_value[memory_limit] = 512M
systemctl enable php-fpm systemctl start php-fpm
SNMPTrap受信ログを/var/log/snmpd/snmptrap.logへ出力する方式に変更。
SNMPTrap受信時には、zabbix_trap_receiver.plに連携する方式に設定。
OPTIONS="-Lsd -Lf /var/log/snmpd/snmptrap.log -p /var/run/snmptrapd.pid udp:162"
*.info;mail.none;authpriv.none;cron.none;local6.none /var/log/messages
# SNMPTrap logs local6.* /var/log/snmpd/snmptrap.log
mkdir /var/log/snmpd/ touch /var/log/snmpd/snmptrap.log
Zabbixのソースコードに同梱されている zabbix_trap_receiver.pl を用いてSNMPTrapを処理する方式の実装を行う。
wget https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.0.tar.gz
tar xfvz zabbix-6.0.0.tar.gz ln -s zabbix-6.0.0 zabbix
cp ./zabbix/misc/snmptrap/zabbix_trap_receiver.pl /usr/local/bin/ chmod 755 /usr/local/bin/zabbix_trap_receiver.pl mkdir /var/log/snmpd/ touch /var/log/snmpd/zabbix_traps.log
vi /usr/local/bin/zabbix_trap_receiver.pl
$SNMPTrapperFile = '/var/log/snmpd/zabbix_traps.log';
authCommunity log,execute public perl do "/usr/local/bin/zabbix_trap_receiver.pl"
disableauthorization yes perl do "/usr/local/bin/zabbix_trap_receiver.pl"
snmp.confを作成し、MIBの読み込みディレクトリの指定を行う。
ファイルは存在しないため、手動で作成する。
MIBDIRS /usr/share/snmp/mibs MIBS all
SNMP関連のログローテーション設定を作成。
/var/log/snmpd/*.log { weekly rotate 4 compress delaycompress missingok notifempty create 0664 root root }
systemctl restart rsyslog
systemctl enable snmptrapd systemctl start snmptrapd
以下は最低限の設定。要件に合わせてパラメータを調整する。
LogFile=/var/log/zabbix/zabbix_server.log LogFileSize=0 PidFile=/run/zabbix/zabbix_server.pid SocketDir=/run/zabbix DBName=zabbix DBUser=zabbix DBPassword=zabbix AllowUnsupportedDBVersions=1 StartPollers=5 StartIPMIPollers=1 StartPreprocessors=3 StartPollersUnreachable=5 StartHistoryPollers=5 StartTrappers=5 StartPingers=5 StartDiscoverers=1 StartHTTPPollers=1 StartVMwareCollectors=2 VMwareCacheSize=32M SNMPTrapperFile=/var/log/snmpd/zabbix_traps.log StartSNMPTrapper=1 CacheSize=64M Timeout=4 LogSlowQueries=3000 StatsAllowedIP=127.0.0.1
セキュリティ的な問題が発生する可能性があるため、パラメータの意味を理解した上で適用して下さい。
PidFile=/run/zabbix/zabbix_agent2.pid LogFile=/var/log/zabbix/zabbix_agent2.log LogFileSize=0 Server=127.0.0.1 ServerActive=127.0.0.1 # Hostname=Zabbix server HostnameItem=system.hostname Include=/etc/zabbix/zabbix_agent2.d/*.conf ControlSocket=/tmp/agent.sock AllowKey=system.run[*] Include=./zabbix_agent2.d/plugins.d/*.conf
systemctl start zabbix-server systemctl start zabbix-web-service systemctl enable zabbix-server systemctl enable zabbix-web-service
systemctl start zabbix-agent systemctl enable zabbix-agent
systemctl start zabbix-agent2 systemctl enable zabbix-agent2