目次
シングル構成のZabbix Server、及びZabbix FrontendをRocky Linux .x系にインストールする手順。
基本的なインストールとして、以下のURLの手順を理解した上で行うものとする。
https://www.zabbix.com/jp/download
| Category | Package & Version | Architecture | Install Type | Repository |
| OS | Rocky Linux release 9.2 (Blue Onyx) | x86-64 | RPM | Rocky-Stream-AppStream |
| MySQL | mysql-8.0.36 | el9.x86-64 | RPM | Rocky-Stream-AppStream |
| PHP | php-8.0.30-1 | el9.x86-64 | RPM | Rocky-Stream-AppStream |
| PHP-FPM | php-fpm-8.0.30-1 | el9.x86-64 | RPM | Rocky-Stream-AppStream |
| HTTPD | httpd-2.4.57-11 | el9.x86-64 | RPM | Rocky-Stream-AppStream |
| SNMP | net-snmp-5.9.1-13 | el9.x86-64 | RPM | Rocky-Stream-AppStream |
| Category | Package & Version | Architecture | Install Type | Repository |
| Zabbix | zabbix-release-7.0-5 | el9.x86-64 | RPM | Zabbix |
| Zabbix | zabbix-server-mysql-7.0.5 | el9.x86-64 | RPM | Zabbix |
| Zabbix | zabbix-sql-scripts-7.0.5 | el9.x86-64 | RPM | Zabbix |
| Zabbix | zabbix-js-7.0.5 | el9.x86-64 | RPM | Zabbix |
| Zabbix | zabbix-selinux-policy-7.0.5 | el9.x86-64 | RPM | Zabbix |
| Category | Package & Version | Architecture | Install Type | Repository |
| Zabbix | zabbix-release-7.0-5 | el9.x86-64 | RPM | Zabbix |
| Zabbix | zabbix-web-7.0.5 | el9.x86-64 | RPM | Zabbix |
| Zabbix | zabbix-web-mysql-7.0.5 | el9.x86-64 | RPM | Zabbix |
| Zabbix | zabbix-web-deps-7.0.5 | el9.x86-64 | RPM | Zabbix |
| Zabbix | zabbix-web-japanese-7.0.5 | el9.x86-64 | RPM | Zabbix |
| Zabbix | zabbix-apache-conf-7.0.5 | el9.x86-64 | RPM | Zabbix |
| Category | Package & Version | Architecture | Install Type | Repository |
| Zabbix | zabbix-web-service-7.0.5 | el9.x86-64 | RPM | Zabbix |
| Chrome | google-chrome-stable | x86-64 | RPM |
| Category | Package & Version | Architecture | Install Type | Repository |
| Zabbix | zabbix-agent-7.0.5 | el9.x86-64 | RPM | Zabbix |
| Zabbix | zabbix-agent2-7.0.5 | el9.x86-64 | RPM | Zabbix |
| Category | Package & Version | Architecture | Install Type | Repository |
| Zabbix | zabbix-get-7.0.5 | el9.x86-64 | RPM | Zabbix |
| Zabbix | zabbix-sender-7.0.5 | el9.x86-64 | RPM | Zabbix |
インストールタイプは「サーバ」構成を選択。
ZabbixのSELinux用ポリシーが提供される様になっているため、SELinuxを有効化した状態で導入することが可能となった。
利用環境に合わせてSELinuxの有効/無効を調整すること。
RHEL9系より、初期状態からrootログイン禁止、空パスワード禁止が有効化されたため、特に設定は不要。
Firewallが不要な場合にはサービスを停止する。
systemctl stop firewalld systemctl disable firewalld
システムの動作上、不要となるサービスは停止する。
# systemctl disable [Service Name]
何が不要なサービスであるかは用途・環境により差異があるため個別に検討が必要。
ss -tulpn
systemctl list-units --type service
監視システムにおいて時刻のズレは運用上の支障となるため、必ずサーバの時刻同期を設定する。
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 -Uvh https://repo.zabbix.com/zabbix/7.0/rocky/9/x86_64/zabbix-release-latest.el9.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-web-japanese zabbix-get zabbix-sender
dnf install zabbix-agent
dnf install zabbix-agent2
Zabbixのパッケージインストールだけでは導入されないミドルウェアを先にインストールする。
DBMSとして使用するMySQLのサーバサービスを導入する。
dnf install mysql-server
SNMPTrapを受信するためにsnmptrapdサービスを導入する。
dnf install net-snmp net-snmp-utils net-snmp-perl
PHPのスクリプトを動作させることを想定し、コマンドラインPHPも導入する。
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/mysql/mysqld.log pid-file=/run/mysqld/mysqld.pid
systemctl start mysqld.service systemctl enable mysqld.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 -On -p /var/run/snmptrapd.pid udp:162"
OPTIONS="-Ls6 -n -On -p /var/run/snmpd.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/7.0/zabbix-7.0.0.tar.gz
tar xfvz zabbix-7.0.0.tar.gz ln -s zabbix-7.0.0 zabbix
cp ./zabbix/misc/snmptrap/zabbix_trap_receiver.pl /usr/local/bin/ chmod 755 /usr/local/bin/zabbix_trap_receiver.pl 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-server 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