目次

概要

シングル構成のZabbix Server、及びZabbix FrontendをRocky Linux 8.x系にインストールする手順。
基本的なインストールとして、以下のURLの手順を理解した上で行うものとする。

https://www.zabbix.com/jp/download

前提環境

  • OS/MW
    CategoryPackage & VersionArchitectureInstall TypeRepository
    OSRocky Linux release 8.6 (Green Obsidian)x86-64RPMRocky-Stream-AppStream
    MySQLmysql-8.0.26-1el8.x86-64RPMRocky-Stream-AppStream
    PHPphp-7.4.19-3el8.x86-64RPMRocky-Stream-AppStream
    PHP-FPMphp-fpm-7.4.19-3el8.x86-64RPMRocky-Stream-AppStream
    HTTPDhttpd-2.4.37-47el8.x86-64RPMRocky-Stream-AppStream
    SNMPnet-snmp-5.8-25el8.x86-64RPMRocky-Stream-AppStream
  • Zabbix Server
    CategoryPackage & VersionArchitectureInstall TypeRepository
    Zabbixzabbix-release-6.0-2el8.x86-64RPMZabbix
    Zabbixzabbix-server-mysql-6.0.7-1el8.x86-64RPMZabbix
    Zabbixzabbix-sql-scripts-6.0.7-1el8.x86-64RPMZabbix
    Zabbixzabbix-js-6.0.7-1el8.x86-64RPMZabbix
    Zabbixzabbix-selinux-policy-6.0.7-1el8.x86-64RPMZabbix
  • Zabbix Web UI
    CategoryPackage & VersionArchitectureInstall TypeRepository
    Zabbixzabbix-web-6.0.7-1el8.x86-64RPMZabbix
    Zabbixzabbix-web-mysql-6.0.7-1el8.x86-64RPMZabbix
    Zabbixzabbix-web-deps-6.0.7-1el8.x86-64RPMZabbix
    Zabbixzabbix-web-japanese-6.0.7-1el8.x86-64RPMZabbix
    Zabbixzabbix-apache-conf-6.0.7-1el8.x86-64RPMZabbix
  • Zabbix Web Service
    CategoryPackage & VersionArchitectureInstall TypeRepository
    Zabbixzabbix-web-service-6.0.7-1el8.x86-64RPMZabbix
    Chromegoogle-chrome-stablex86-64RPMGoogle
  • Zabbix Agent
    CategoryPackage & VersionArchitectureInstall TypeRepository
    Zabbixzabbix-agent-6.0.7-1el8.x86-64RPMZabbix
    Zabbixzabbix-agent2-6.0.7-1el8.x86-64RPMZabbix
  • Zabbix Commands
    CategoryPackage & VersionArchitectureInstall TypeRepository
    Zabbixzabbix-get-6.0.7-1el8.x86-64RPMZabbix
    Zabbixzabbix-sender-6.0.7-1el8.x86-64RPMZabbix

1. OS設定

インストール

インストールタイプ

インストールタイプは「サーバ(GUI使用)」構成を選択。
このタイプではEL6までとの互換性を確保するためのツール類が初めからインストールされるため、使いやすい構成で始めることができる。

ランレベル

サーバ用途ではGUIは不要のため、CLIモードに変更する。

  • 設定
    systemctl set-default multi-user.target
  • 確認
    # systemctl get-default
    multi-user.target

セキュリティ設定

SELinux

ZabbixのSELinux用ポリシーが提供される様になっているため、SELinuxを有効化した状態で導入することが可能となった。
利用環境に合わせてSELinuxの有効/無効を調整すること。
(RHEL9 / CentOS Stream 9以降はSELinuxの無効化が困難となるため、将来的には有効化した状態での運用が標準になると思われる。)

SSH

/etc/ssh/sshd_configに対して、適宜設定を行う。

  • rootログイン禁止
    PermitRootLogin no
  • パスワード認証禁止(鍵認証のみ許可)
    PasswordAuthentication no
  • 空パスワード禁止
    PermitEmptyPasswords no
  • 設定反映 設定後、sshdを再起動すると設定が反映される。

※注意※
上記の設定反映後、新たにターミナルセッションを開いてSSH接続ができることを確認すること。

Firewallの無効化

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

時刻同期

監視システムにおいて時刻のズレは運用上の支障となるため、必ずサーバの時刻同期を設定する。

  • 設定 国内で使用する場合にはNICTのntpサーバを使うなどの方式となる。(大学私設のNTPサーバは避けること)
    クローズドなNTPが存在する場合には、そのアドレスを設定する。
  • /etc/chrony.conf
    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] +/- 4093us
    MS列で「*」が表示されているサーバと同期が完了している。

システムのアップデート

OS導入段階のパッケージを最新化する。

dnf update

設定の反映

ここまでの設定を一括反映するため、OSの再起動を行う。

reboot

パッケージ導入

Zabbixインストール

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
  • Zabbixのインストール
    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
  • Zabbix Agentの導入
    Zabbix Agentは2種類のバージョンが提供されている。
    新しい機能はAgent2に付加されていくため、これらを使用したい場合にはAgent2を使用する。
    • Zabbix Agent(C言語版)
      dnf install zabbix-agent
    • Zabbix Agent2(Go言語版)
      dnf install zabbix-agent2

ミドルウェアの導入

Zabbixのパッケージインストールだけでは導入されないミドルウェアを先にインストールする。

MariaDB

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

NET-SNMP

SNMPTrapを受信するためにsnmptrapdサービスを導入する。

  • インストール
    dnf install net-snmp net-snmp-utils net-snmp-perl

PHP

PHPのバージョンを7.4へ変更する。
PHPのスクリプトを動作させることを想定し、コマンドラインPHPも導入する。

  • 操作手順
    dnf module switch-to php:7.4

Google Chrome

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

MariaDB設定

動作設定

  • /etc/my.cnf.d/mariadb-server.cnf
    [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 

セキュリティ設定

パスワード設定などのセキュリティ関連の最低限の設定は付属のスクリプトを用いて設定を行う。

  • 設定内容
    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?
  • パスワード設定の可否(yを選択)
    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
    
  • パスワードの複雑性条件の指定(0を選択)
    Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
    Please set the password for root here.
    
  • rootのパスワードを設定
    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.
    
  • anonymous userの削除(yを選択)
    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.
    
  • リモートホストからのrootログイン拒否(yを選択)
    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.
    
  • テスト用アカウントの削除(yを選択)
    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.
    
  • 権限情報の再読み込み(yを選択)
    Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
    Success.
    
    All done! 

Zabbixデータベース作成

  • データベースに接続
    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

Apache設定

動作設定

  • /etc/httpd/conf/httpd.conf
    ServerName [FQDN]:80

URL転送

  • /var/www/html/index.html
    <!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-FPM設定

動作設定

PHPが使用するメモリ上限の初期値は128MBとなっている。
表示内容が増えるとメモリ不足となるため、上限値を上げておく。

  • /etc/php-fpm.d/zabbix.conf
    php_value[memory_limit] = 512M

設定の反映

  • サービス起動
    systemctl enable php-fpm
    systemctl start php-fpm

NET-SNMP設定

ログ出力先の変更

SNMPTrap受信ログを/var/log/snmpd/snmptrap.logへ出力する方式に変更。
SNMPTrap受信時には、zabbix_trap_receiver.plに連携する方式に設定。

  • /etc/sysconfig/snmptrapd
    OPTIONS="-Lsd -Lf /var/log/snmpd/snmptrap.log -p /var/run/snmptrapd.pid udp:162"
  • /etc/rsyslog.conf
    • messagesへのSNMPTrapログを出力させない
      *.info;mail.none;authpriv.none;cron.none;local6.none                /var/log/messages
    • SNMPTrapログはlocal6として別のファイルに出力させる
      # SNMPTrap logs
      local6.*                                                /var/log/snmpd/snmptrap.log
  • ログの出力先を作成
    mkdir /var/log/snmpd/
    touch /var/log/snmpd/snmptrap.log

SNMPTrapの処理方法を変更

Zabbixのソースコードに同梱されている zabbix_trap_receiver.pl を用いてSNMPTrapを処理する方式の実装を行う。

  • Zabbixのソースコードを取得
    wget https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.0.tar.gz
  • zabbix_trap_receiver.plの取得と配置
    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
  • zabbix_trap_receiver.plの設定変更
    vi /usr/local/bin/zabbix_trap_receiver.pl
    • zabbix_trap_receiver.pl
      $SNMPTrapperFile = '/var/log/snmpd/zabbix_traps.log';
  • /etc/snmp/snmptrapd.conf
    • 特定のコミュニティ名のみを受信する場合
      authCommunity log,execute public
      perl do "/usr/local/bin/zabbix_trap_receiver.pl"
    • 全てのコミュニティ名を受信する場合
      disableauthorization yes
      perl do "/usr/local/bin/zabbix_trap_receiver.pl"

MIBの読み込み設定

snmp.confを作成し、MIBの読み込みディレクトリの指定を行う。 ファイルは存在しないため、手動で作成する。

  • /etc/snmp/snmp.conf
    MIBDIRS /usr/share/snmp/mibs
    MIBS all

ログローテーション

SNMP関連のログローテーション設定を作成。

  • /etc/logrotate.d/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

Zabbix設定

以下は最低限の設定。要件に合わせてパラメータを調整する。

Zabbix Server

  • /etc/zabbix/zabbix_server.conf
    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

Zabbix Agent

セキュリティ的な問題が発生する可能性があるため、パラメータの意味を理解した上で適用して下さい。

  • /etc/zabbix/zabbix_agentd.conf
    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

サービス制御

  • Zabbixサービスの起動
    systemctl start zabbix-server
    systemctl start zabbix-web-service
    systemctl enable zabbix-server
    systemctl enable zabbix-web-service
  • 自動起動設定
    • Zabbix Agent(C言語版)
      systemctl start zabbix-agent
      systemctl enable zabbix-agent
  • Zabbix Agent2(Go言語版)
    systemctl start zabbix-agent2
    systemctl enable zabbix-agent2

参考情報


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2023-08-10 (木) 14:58:46 (259d)