takashi kono's blog

コーヒーとキーボードと共に何かを記録していくブログ

Rocky Linux 9.6 に Zabbix Server, Zabbix Agent を入れる備忘録2

本記事の目的

備忘録

参考資料

OS インストール系

takashikono.hatenadiary.jp

Zabbix インストール系

環境

  • Rocky Linux 9.6
  • Zabbix 7.0 LTS
    • Server
    • Agent
    • Frontend
  • MariaDB 11.8 (LTS: 2028-06-04 Community Support Limit)
  • Nginx 1.20

on VirtualBox

Rocky Linux install

省略

ssh 接続

して作業してね

(本筋とは関係ないがメモしておくコマンド)

# IPv6 Disable
sudo nmcli c mod enp0s3 ipv6.method disable

# bash-completion (タブ補完)
sudo dnf update
sudo dnf install bash-completion 
# グローバルに設定を反映させる
cat << 'EOL' | sudo tee /etc/profile.d/bash_completion.sh > /dev/null
# Enable bash-completion for all users
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi
EOL
sudo chmod +x /etc/profile.d/bash_completion.sh

# 即時反映
source /etc/profile.d/bash_completion.sh

# Vim install
sudo dnf install vim

SELinux を Permissive へ

sestatus

# 元ファイルのバックアップ
sudo cp -ivp /etc/selinux/config{,.$(date -I)}

# 編集
sudo sed -i 's/^SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config

# 確認
sestatus

# reboot
sudo reboot

# 確認
sestatus

locale の確認

locale
localectl

sample

[takashi@sample ~]$ locale
LANG=ja_JP.UTF-8
LC_CTYPE="ja_JP.UTF-8"
LC_NUMERIC="ja_JP.UTF-8"
LC_TIME="ja_JP.UTF-8"
LC_COLLATE="ja_JP.UTF-8"
LC_MONETARY="ja_JP.UTF-8"
LC_MESSAGES="ja_JP.UTF-8"
LC_PAPER="ja_JP.UTF-8"
LC_NAME="ja_JP.UTF-8"
LC_ADDRESS="ja_JP.UTF-8"
LC_TELEPHONE="ja_JP.UTF-8"
LC_MEASUREMENT="ja_JP.UTF-8"
LC_IDENTIFICATION="ja_JP.UTF-8"
LC_ALL=
[takashi@sample ~]$
[takashi@sample ~]$ localectl
System Locale: LANG=ja_JP.UTF-8
    VC Keymap: us
   X11 Layout: us,jp
  X11 Variant: ,
[takashi@sample ~]$

この辺が前回との違い
LANG=ja_JP.UTF-8 の現在、どのようになるか確認する

時刻同期状況を見る

chronyc sources

もし、NTP サーバーを ntp.nict.jp に変えるなら?

# backup
sudo cp -iv /etc/chrony.conf{,.$(date -I)}

# ntp.nict.jp を追加(ファイルの先頭付近に挿入)
sudo sed -i '/^# Use public servers/a \
server ntp.nict.jp iburst' /etc/chrony.conf

# OS install 時の設定を削除する
head /etc/chrony.conf
# 何行目を削除するかを確認する
cat -n /etc/chrony.conf | head -n 5
# 2行目を削除
sudo sed -i '2d' /etc/chrony.conf
# 2行目と5行目を削除
sudo sed -i '2d;5d' /etc/chrony.conf
# 2行目から4行目まで削除
sudo sed -i '2,4d' /etc/chrony.conf

# サービスリスタート
sudo systemctl restart chronyd
sudo systemctl status chronyd

# 確認
chronyc sources -v
chronyc tracking

EPEL をインストール

sudo dnf config-manager --set-enabled crb
sudo dnf install epel-release

NGINX をインストールする

sudo dnf install nginx

sample

[takashi@sample ~]$ sudo dnf info nginx
メタデータの期限切れの最終確認: 0:00:39 前の 20251026214229秒 に実施しました。
利用可能なパッケージ
名前         : nginx
エポック     : 2
バージョン   : 1.20.1
リリース     : 22.el9_6.3
Arch         : x86_64
サイズ       : 36 k
ソース       : nginx-1.20.1-22.el9_6.3.src.rpm
リポジトリー : appstream
概要         : A high performance web server and reverse proxy server
URL          : https://nginx.org
ライセンス   : BSD
説明         : Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and
             : IMAP protocols, with a strong focus on high concurrency, performance and low
             : memory usage.

[takashi@sample ~]$
[takashi@sample ~]$ sudo dnf install nginx
メタデータの期限切れの最終確認: 0:01:12 前の 20251026214229秒 に実施しました。
依存関係が解決しました。
========================================================================================================
 パッケージ                  アーキテクチャー バージョン                      リポジトリー        サイズ
========================================================================================================
インストール:
 nginx                       x86_64           2:1.20.1-22.el9_6.3             appstream            36 k
依存関係のインストール:
 nginx-core                  x86_64           2:1.20.1-22.el9_6.3             appstream           566 k
 nginx-filesystem            noarch           2:1.20.1-22.el9_6.3             appstream           9.6 k
 rocky-logos-httpd           noarch           90.16-1.el9                     appstream            24 k

トランザクションの概要
========================================================================================================
インストール  4 パッケージ

ダウンロードサイズの合計: 636 k
インストール後のサイズ: 1.8 M
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
(1/4): nginx-filesystem-1.20.1-22.el9_6.3.noarch.rpm                     53 kB/s | 9.6 kB     00:00
(2/4): rocky-logos-httpd-90.16-1.el9.noarch.rpm                         129 kB/s |  24 kB     00:00
(3/4): nginx-1.20.1-22.el9_6.3.x86_64.rpm                               179 kB/s |  36 kB     00:00
(4/4): nginx-core-1.20.1-22.el9_6.3.x86_64.rpm                          6.3 MB/s | 566 kB     00:00
--------------------------------------------------------------------------------------------------------
合計                                                                    855 kB/s | 636 kB     00:00
トランザクションを確認しています
トランザクションの確認に成功しました。
トランザクションをテストしています
トランザクションのテストに成功しました。
トランザクションを実行しています
  準備中           :                                                                                1/1
  scriptletの実行中: nginx-filesystem-2:1.20.1-22.el9_6.3.noarch                                    1/4
  インストール中   : nginx-filesystem-2:1.20.1-22.el9_6.3.noarch                                    1/4
  インストール中   : nginx-core-2:1.20.1-22.el9_6.3.x86_64                                          2/4
  インストール中   : rocky-logos-httpd-90.16-1.el9.noarch                                           3/4
  インストール中   : nginx-2:1.20.1-22.el9_6.3.x86_64                                               4/4
  scriptletの実行中: nginx-2:1.20.1-22.el9_6.3.x86_64                                               4/4
  検証中           : nginx-filesystem-2:1.20.1-22.el9_6.3.noarch                                    1/4
  検証中           : rocky-logos-httpd-90.16-1.el9.noarch                                           2/4
  検証中           : nginx-2:1.20.1-22.el9_6.3.x86_64                                               3/4
  検証中           : nginx-core-2:1.20.1-22.el9_6.3.x86_64                                          4/4

インストール済み:
  nginx-2:1.20.1-22.el9_6.3.x86_64                      nginx-core-2:1.20.1-22.el9_6.3.x86_64
  nginx-filesystem-2:1.20.1-22.el9_6.3.noarch           rocky-logos-httpd-90.16-1.el9.noarch

完了しました!
[takashi@sample ~]$

MariaDB について

MariaDB をインストールする

今回は 11.8 を選ぶので、 11.8 用のコマンド

# 専用リポジトリを作る
cat << 'EOL' | sudo tee /etc/yum.repos.d/MariaDB.repo > /dev/null
# MariaDB 11.8 RedHatEnterpriseLinux repository list - created 2025-09-11 11:10 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
# rpm.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# baseurl = https://rpm.mariadb.org/11.8/rhel/$releasever/$basearch
baseurl = https://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/yum/11.8/rhel/$releasever/$basearch
# gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgkey = https://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1
EOL

sudo dnf install MariaDB-{server,client}

sample

[takashi@sample ~]$ cat << 'EOL' | sudo tee /etc/yum.repos.d/MariaDB.repo > /dev/null
# MariaDB 11.8 RedHatEnterpriseLinux repository list - created 2025-09-11 11:10 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
# rpm.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# baseurl = https://rpm.mariadb.org/11.8/rhel/$releasever/$basearch
baseurl = https://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/yum/11.8/rhel/$releasever/$basearch
# gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgkey = https://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1
EOL
[takashi@sample ~]$
[takashi@sample ~]$
[takashi@sample ~]$ sudo dnf install MariaDB-{server,client}
MariaDB                                                                 1.2 MB/s | 766 kB     00:00
依存関係が解決しました。
========================================================================================================
 パッケージ                     Arch            バージョン                     リポジトリー       サイズ
========================================================================================================
インストール:
 MariaDB-client                 x86_64          11.8.3-1.el9                   mariadb            9.6 M
 MariaDB-server                 x86_64          11.8.3-1.el9                   mariadb             18 M
依存関係のインストール:
 MariaDB-common                 x86_64          11.8.3-1.el9                   mariadb             92 k
 MariaDB-shared                 x86_64          11.8.3-1.el9                   mariadb            130 k
 boost-program-options          x86_64          1.75.0-10.el9                  appstream          104 k
 galera-4                       x86_64          26.4.23-1.el9                  mariadb            1.2 M
 liburing                       x86_64          2.5-1.el9                      appstream           38 k
 perl-DBI                       x86_64          1.643-9.el9                    appstream          700 k
 perl-DynaLoader                x86_64          1.47-481.1.el9_6               appstream           24 k
 perl-File-Copy                 noarch          2.34-481.1.el9_6               appstream           19 k
 perl-Math-BigInt               noarch          1:1.9998.18-460.el9            appstream          188 k
 perl-Math-Complex              noarch          1.59-481.1.el9_6               appstream           45 k
 perl-Sys-Hostname              x86_64          1.23-481.1.el9_6               appstream           15 k
弱い依存関係のインストール:
 MariaDB-client-compat          noarch          11.8.3-1.el9                   mariadb             11 k
 MariaDB-server-compat          noarch          11.8.3-1.el9                   mariadb            9.0 k
 pv                             x86_64          1.6.20-1.el9                   epel                65 k
 socat                          x86_64          1.7.4.1-6.el9_6.1              appstream          299 k

トランザクションの概要
========================================================================================================
インストール  17 パッケージ

ダウンロードサイズの合計: 31 M
インストール後のサイズ: 241 M
これでよろしいですか? [y/N]: y
...
インストール済み:
  MariaDB-client-11.8.3-1.el9.x86_64                  MariaDB-client-compat-11.8.3-1.el9.noarch
  MariaDB-common-11.8.3-1.el9.x86_64                  MariaDB-server-11.8.3-1.el9.x86_64
  MariaDB-server-compat-11.8.3-1.el9.noarch           MariaDB-shared-11.8.3-1.el9.x86_64
  boost-program-options-1.75.0-10.el9.x86_64          galera-4-26.4.23-1.el9.x86_64
  liburing-2.5-1.el9.x86_64                           perl-DBI-1.643-9.el9.x86_64
  perl-DynaLoader-1.47-481.1.el9_6.x86_64             perl-File-Copy-2.34-481.1.el9_6.noarch
  perl-Math-BigInt-1:1.9998.18-460.el9.noarch         perl-Math-Complex-1.59-481.1.el9_6.noarch
  perl-Sys-Hostname-1.23-481.1.el9_6.x86_64           pv-1.6.20-1.el9.x86_64
  socat-1.7.4.1-6.el9_6.1.x86_64

完了しました!
[takashi@sample ~]$

MariaDB の初期セットアップする

# 起動
sudo systemctl start mariadb
# 自動起動していなければ設定
sudo systemctl enable mariadb
# 確認
systemctl status mariadb

# 初期セットアップ
sudo mariadb-secure-installation

なんでもいいけど、お試しなので MariaDB の root パスワードは、 5BJPYhoshii とする

[takashi@sample ~]$ sudo mariadb-secure-installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

## unix_socket 認証に切り替える? y
Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..
 ... Success!


You already have your root account protected, so you can safely answer 'n'.

## root password を変更しますか? y
Change the root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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 ユーザーを削除しますか? y
Remove anonymous users? [Y/n] 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? [Y/n] y
 ... Success!

By default, MariaDB 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.

## test データベースを削除しますか? y
Remove test database and access to it? [Y/n] 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.

## privilege tables をリロードしますか? y
Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[takashi@sample ~]$

unix_socket 認証について

mariadb.com

zabbix をインストールしていく

資料

www.zabbix.com

EPELリポジトリ設定の中に、 excludepkgs=zabbix* を追記する

cat -n /etc/yum.repos.d/epel.repo

# 11行目に追記する
sudo sed '10a excludepkgs=zabbix*' /etc/yum.repos.d/epel.repo -i

sample

[takashi@sample ~]$ cat -n /etc/yum.repos.d/epel.repo
     1  [epel]
     2  name=Extra Packages for Enterprise Linux $releasever - $basearch
     3  # It is much more secure to use the metalink, but if you wish to use a local mirror
     4  # place its address here.
     5  #baseurl=https://download.example/pub/epel/$releasever/Everything/$basearch/
     6  metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch&infra=$infra&content=$contentdir
     7  enabled=1
     8  gpgcheck=1
     9  countme=1
    10  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever
    11
    12  [epel-debuginfo]
...
[takashi@sample ~]$ sudo sed '10a excludepkgs=zabbix*' /etc/yum.repos.d/epel.repo -i
[sudo] takashi のパスワード:
[takashi@sample ~]$
[takashi@sample ~]$ cat -n /etc/yum.repos.d/epel.repo |head -n 11
     1  [epel]
     2  name=Extra Packages for Enterprise Linux $releasever - $basearch
     3  # It is much more secure to use the metalink, but if you wish to use a local mirror
     4  # place its address here.
     5  #baseurl=https://download.example/pub/epel/$releasever/Everything/$basearch/
     6  metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch&infra=$infra&content=$contentdir
     7  enabled=1
     8  gpgcheck=1
     9  countme=1
    10  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever
    11  excludepkgs=zabbix*
[takashi@sample ~]$

Zabbix リポジトリをインストール

sudo rpm -Uvh https://repo.zabbix.com/zabbix/7.0/rocky/9/x86_64/zabbix-release-latest-7.0.el9.noarch.rpm
sudo dnf clean all

sample

[takashi@sample ~]$ sudo rpm -Uvh https://repo.zabbix.com/zabbix/7.0/rocky/9/x86_64/zabbix-release-latest-7.0.el9.noarch.rpm
https://repo.zabbix.com/zabbix/7.0/rocky/9/x86_64/zabbix-release-latest-7.0.el9.noarch.rpm を取得中
警告: /var/tmp/rpm-tmp.c2UyXA: ヘッダー V4 RSA/SHA512 Signature、鍵 ID b5333005: NOKEY
Verifying...                          ################################# [100%]
準備しています...              ################################# [100%]
更新中 / インストール中...
   1:zabbix-release-7.0-5.el9         ################################# [100%]
[takashi@sample ~]$
[takashi@sample ~]$ sudo dnf clean all
58 ファイルが削除されました
[takashi@sample ~]$

Zabbix の必要パッケージインストール
いよいよここ。日本語パッケージが入るか見てみる

sudo dnf install zabbix-server-mysql \
  zabbix-web-mysql \
  zabbix-nginx-conf \
  zabbix-sql-scripts \
  zabbix-selinux-policy \
  zabbix-agent

sample

[takashi@sample ~]$ sudo dnf install zabbix-server-mysql \
  zabbix-web-mysql \
  zabbix-nginx-conf \
  zabbix-sql-scripts \
  zabbix-selinux-policy \
  zabbix-agent
MariaDB                                                                 1.0 MB/s | 766 kB     00:00
Extra Packages for Enterprise Linux 9 - x86_64                          3.9 MB/s |  20 MB     00:05
Extra Packages for Enterprise Linux 9 openh264 (From Cisco) - x86_64    1.5 kB/s | 2.5 kB     00:01
Rocky Linux 9 - BaseOS                                                  1.8 MB/s | 2.5 MB     00:01
Rocky Linux 9 - AppStream                                               8.0 MB/s | 9.5 MB     00:01
Rocky Linux 9 - CRB                                                     4.2 MB/s | 2.8 MB     00:00
Rocky Linux 9 - Extras                                                   31 kB/s |  17 kB     00:00
Zabbix Official Repository - x86_64                                     156 kB/s | 371 kB     00:02
Zabbix Official Repository (non-supported) - x86_64                     1.1 kB/s | 1.1 kB     00:01
Zabbix Official Repository (tools) - x86_64                             2.1 kB/s | 2.2 kB     00:01
依存関係が解決しました。
========================================================================================================
 パッケージ                  Arch         バージョン                   リポジトリー               サイズ
========================================================================================================
インストール:
 zabbix-agent                x86_64       7.0.19-release1.el9          zabbix                     628 k
 zabbix-nginx-conf           noarch       7.0.19-release1.el9          zabbix                      13 k
 zabbix-selinux-policy       x86_64       7.0.19-release1.el9          zabbix                     306 k
 zabbix-server-mysql         x86_64       7.0.19-release1.el9          zabbix                     2.3 M
 zabbix-sql-scripts          noarch       7.0.19-release1.el9          zabbix                     7.9 M
 zabbix-web-mysql            noarch       7.0.19-release1.el9          zabbix                      12 k
依存関係のインストール:
 OpenIPMI-libs               x86_64       2.0.36-1.el9                 appstream                  509 k
 fping                       x86_64       5.1-1.el9                    zabbix-non-supported        35 k
 gd                          x86_64       2.3.2-3.el9                  appstream                  131 k
 httpd-filesystem            noarch       2.4.62-4.el9_6.4             appstream                   11 k
 jbigkit-libs                x86_64       2.1-23.el9                   appstream                   52 k
 libXpm                      x86_64       3.5.13-10.el9                appstream                   58 k
 libtiff                     x86_64       4.4.0-13.el9                 appstream                  197 k
 libwebp                     x86_64       1.2.0-8.el9                  appstream                  276 k
 libxslt                     x86_64       1.1.34-13.el9_6              appstream                  239 k
 net-snmp-libs               x86_64       1:5.9.1-17.el9               appstream                  740 k
 php-bcmath                  x86_64       8.0.30-3.el9_6               appstream                   33 k
 php-common                  x86_64       8.0.30-3.el9_6               appstream                  666 k
 php-fpm                     x86_64       8.0.30-3.el9_6               appstream                  1.6 M
 php-gd                      x86_64       8.0.30-3.el9_6               appstream                   39 k
 php-ldap                    x86_64       8.0.30-3.el9_6               appstream                   39 k
 php-mbstring                x86_64       8.0.30-3.el9_6               appstream                  466 k
 php-mysqlnd                 x86_64       8.0.30-3.el9_6               appstream                  150 k
 php-pdo                     x86_64       8.0.30-3.el9_6               appstream                   81 k
 php-xml                     x86_64       8.0.30-3.el9_6               appstream                  132 k
 unixODBC                    x86_64       2.3.9-4.el9                  appstream                  458 k
 zabbix-web                  noarch       7.0.19-release1.el9          zabbix                     8.4 M
 zabbix-web-deps             noarch       7.0.19-release1.el9          zabbix                      13 k

トランザクションの概要
========================================================================================================
インストール  28 パッケージ

ダウンロードサイズの合計: 25 M
インストール後のサイズ: 94 M
これでよろしいですか? [y/N]: n
操作が中断されました。
[takashi@sample ~]$

入っていないね
セットで入れる

sudo dnf install zabbix-server-mysql \
  zabbix-web-mysql \
  zabbix-nginx-conf \
  zabbix-sql-scripts \
  zabbix-selinux-policy \
  zabbix-agent \
  zabbix-web-japanese

sample

[takashi@sample ~]$ sudo dnf install zabbix-server-mysql \
  zabbix-web-mysql \
  zabbix-nginx-conf \
  zabbix-sql-scripts \
  zabbix-selinux-policy \
  zabbix-agent \
  zabbix-web-japanese
[sudo] takashi のパスワード:
メタデータの期限切れの最終確認: 0:04:53 前の 20251026220804秒 に実施しました。
依存関係が解決しました。
========================================================================================================
 パッケージ                  Arch         バージョン                   リポジトリー               サイズ
========================================================================================================
インストール:
 zabbix-agent                x86_64       7.0.19-release1.el9          zabbix                     628 k
 zabbix-nginx-conf           noarch       7.0.19-release1.el9          zabbix                      13 k
 zabbix-selinux-policy       x86_64       7.0.19-release1.el9          zabbix                     306 k
 zabbix-server-mysql         x86_64       7.0.19-release1.el9          zabbix                     2.3 M
 zabbix-sql-scripts          noarch       7.0.19-release1.el9          zabbix                     7.9 M
 zabbix-web-japanese         noarch       7.0.19-release1.el9          zabbix                      12 k
 zabbix-web-mysql            noarch       7.0.19-release1.el9          zabbix                      12 k
依存関係のインストール:
 OpenIPMI-libs               x86_64       2.0.36-1.el9                 appstream                  509 k
 fping                       x86_64       5.1-1.el9                    zabbix-non-supported        35 k
 gd                          x86_64       2.3.2-3.el9                  appstream                  131 k
 httpd-filesystem            noarch       2.4.62-4.el9_6.4             appstream                   11 k
 jbigkit-libs                x86_64       2.1-23.el9                   appstream                   52 k
 libXpm                      x86_64       3.5.13-10.el9                appstream                   58 k
 libtiff                     x86_64       4.4.0-13.el9                 appstream                  197 k
 libwebp                     x86_64       1.2.0-8.el9                  appstream                  276 k
 libxslt                     x86_64       1.1.34-13.el9_6              appstream                  239 k
 net-snmp-libs               x86_64       1:5.9.1-17.el9               appstream                  740 k
 php-bcmath                  x86_64       8.0.30-3.el9_6               appstream                   33 k
 php-common                  x86_64       8.0.30-3.el9_6               appstream                  666 k
 php-fpm                     x86_64       8.0.30-3.el9_6               appstream                  1.6 M
 php-gd                      x86_64       8.0.30-3.el9_6               appstream                   39 k
 php-ldap                    x86_64       8.0.30-3.el9_6               appstream                   39 k
 php-mbstring                x86_64       8.0.30-3.el9_6               appstream                  466 k
 php-mysqlnd                 x86_64       8.0.30-3.el9_6               appstream                  150 k
 php-pdo                     x86_64       8.0.30-3.el9_6               appstream                   81 k
 php-xml                     x86_64       8.0.30-3.el9_6               appstream                  132 k
 unixODBC                    x86_64       2.3.9-4.el9                  appstream                  458 k
 zabbix-web                  noarch       7.0.19-release1.el9          zabbix                     8.4 M
 zabbix-web-deps             noarch       7.0.19-release1.el9          zabbix                      13 k

トランザクションの概要
========================================================================================================
インストール  29 パッケージ

ダウンロードサイズの合計: 25 M
インストール後のサイズ: 94 M
これでよろしいですか? [y/N]: y
...
インストール済み:
  OpenIPMI-libs-2.0.36-1.el9.x86_64                   fping-5.1-1.el9.x86_64
  gd-2.3.2-3.el9.x86_64                               httpd-filesystem-2.4.62-4.el9_6.4.noarch
  jbigkit-libs-2.1-23.el9.x86_64                      libXpm-3.5.13-10.el9.x86_64
  libtiff-4.4.0-13.el9.x86_64                         libwebp-1.2.0-8.el9.x86_64
  libxslt-1.1.34-13.el9_6.x86_64                      net-snmp-libs-1:5.9.1-17.el9.x86_64
  php-bcmath-8.0.30-3.el9_6.x86_64                    php-common-8.0.30-3.el9_6.x86_64
  php-fpm-8.0.30-3.el9_6.x86_64                       php-gd-8.0.30-3.el9_6.x86_64
  php-ldap-8.0.30-3.el9_6.x86_64                      php-mbstring-8.0.30-3.el9_6.x86_64
  php-mysqlnd-8.0.30-3.el9_6.x86_64                   php-pdo-8.0.30-3.el9_6.x86_64
  php-xml-8.0.30-3.el9_6.x86_64                       unixODBC-2.3.9-4.el9.x86_64
  zabbix-agent-7.0.19-release1.el9.x86_64             zabbix-nginx-conf-7.0.19-release1.el9.noarch
  zabbix-selinux-policy-7.0.19-release1.el9.x86_64    zabbix-server-mysql-7.0.19-release1.el9.x86_64
  zabbix-sql-scripts-7.0.19-release1.el9.noarch       zabbix-web-7.0.19-release1.el9.noarch
  zabbix-web-deps-7.0.19-release1.el9.noarch          zabbix-web-japanese-7.0.19-release1.el9.noarch
  zabbix-web-mysql-7.0.19-release1.el9.noarch

完了しました!
[takashi@sample ~]$

これで、一発目から日本語版使えそう

初期データベースを作る

# 初期設定でパスワードを設定したが、これでもログインできる仕様らしい
sudo mysql 

今回、zabbix ユーザーのパスワードは zb_password とする

create database zabbix character set utf8mb4 collate utf8mb4_bin;
create user zabbix@localhost identified by 'zb_password';
grant all privileges on zabbix.* to zabbix@localhost;
set global log_bin_trust_function_creators = 1;
quit;

sample

[takashi@sample ~]$ sudo mysql
[sudo] takashi のパスワード:
mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 14
Server version: 11.8.3-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>
MariaDB [(none)]> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> create user zabbix@localhost identified by 'zb_password';
Query OK, 0 rows affected (0.003 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> set global log_bin_trust_function_creators = 1;
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> quit;
Bye
[takashi@sample ~]$

最初のスキーマを設定する

この時一緒に Admin のパスワードを決める

sudo zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | \
  mysql --default-character-set=utf8mb4 \
        --user=zabbix \
        --password \
        --database=zabbix

sample

[takashi@sample ~]$ sudo zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | \
  mysql --default-character-set=utf8mb4 \
        --user=zabbix \
        --password \
        --database=zabbix
mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead
Enter password: # <-- ここは、zabbix@localhost のパスワード
[takashi@sample ~]$

log_bin_trust_function_creators を disable に

sudo mysql
set global log_bin_trust_function_creators = 0;
quit;

データベースのパスワードを config ファイルに設定する

cd /etc/zabbix/
sudo cp -ivp zabbix_server.conf{,.$(date -I)}
sudo sed '/DBPassword=/a DBPassword=zb_password' zabbix_server.conf -i

sample

[takashi@sample ~]$ cd /etc/zabbix/
[takashi@sample zabbix]$ sudo cp -ivp zabbix_server.conf{,.$(date -I)}
'zabbix_server.conf' -> 'zabbix_server.conf.2025-10-26'
[takashi@sample zabbix]$
[takashi@sample zabbix]$ ls -l
合計 84
drwxr-xr-x. 2 apache apache    33 1026 22:16 web
-rw-r--r--. 1 root   root   17323  930 17:48 zabbix_agentd.conf
drwxr-xr-x. 2 root   root       6  930 17:48 zabbix_agentd.d
-rw-------. 1 root   zabbix 30539  930 17:49 zabbix_server.conf
-rw-------. 1 root   zabbix 30539  930 17:49 zabbix_server.conf.2025-10-26
drwxr-xr-x. 2 root   root       6  930 17:49 zabbix_server.d
[takashi@sample zabbix]$
[takashi@sample zabbix]$ sudo sed -n '/DBPassword=/p' zabbix_server.conf
# DBPassword=
[takashi@sample zabbix]$
[takashi@sample zabbix]$
[takashi@sample zabbix]$ sudo sed '/DBPassword=/a DBPassword=zb_password' zabbix_server.conf -i
[takashi@sample zabbix]$
[takashi@sample zabbix]$ sudo sed -n '/DBPassword=/p' zabbix_server.conf
# DBPassword=
DBPassword=zb_password
[takashi@sample zabbix]$

Zabbix フロントエンドの設定

/etc/nginx/conf.d/zabbix.conf の編集

cd /etc/nginx/conf.d/

# 以下のコメントアウト部分を任意に編集
[ope@sample conf.d]$ cat zabbix.conf
server {
#        listen          8080;
#        server_name     example.com;

## サンプル
[ope@sample conf.d]$ head zabbix.conf
server {
        listen          0.0.0.0:8080;
        server_name     god-eye.com;

# config test
sudo nginx -t

Zabbix スタート

sudo systemctl status zabbix-server zabbix-agent nginx php-fpm
sudo systemctl restart zabbix-server zabbix-agent nginx php-fpm
sudo systemctl status zabbix-server zabbix-agent nginx php-fpm

sudo systemctl enable zabbix-server zabbix-agent nginx php-fpm

firewalld で穴あけ

sudo firewall-cmd --list-all
sudo firewall-cmd --add-port=8080/tcp --permanent
sudo firewall-cmd --add-port=10050/tcp --permanent
sudo firewall-cmd --add-port=10051/tcp --permanent

sudo firewall-cmd --reload

UI を開く

自分の設定に従って下さい

開いた直後

Welcome

言語設定

lang

日本語が選べるぞ!
次は、デフォルトでOK

pre-requisites

DB

MariaDBMySQL 互換なのでそのまま Port は 0 がデフォルトなのでそのまま zabbix@localhost のパスワードをパスワード欄に入れる

server settings

server name god-eye
time zone JST
theme はそのまま

summary

next

success

login

login

初期ユーザー情報
Admin / zabbix

dashboard

あれ?日本語じゃない

Language が system default

system default になっている

language

Japanese が選べる

change to japanese

でも、これは個人設定
システム全体で変えるには?

表示設定

ここで、日本語を選択する
すると、 profile 設定で、system default でも日本語になる

自分自身の監視

エージェントを入れたのでやる

cd /etc/zabbix/
cp -iv zabbix_agentd.conf{,.$(date -I)}

いったん中身を見てみる

grep -n -vE '^$|^#' zabbix_agentd.conf


[takashi@sample zabbix]$ grep -n -vE '^$|^#' zabbix_agentd.conf
13:PidFile=/run/zabbix/zabbix_agentd.pid
32:LogFile=/var/log/zabbix/zabbix_agentd.log
43:LogFileSize=0
117:Server=127.0.0.1  # Zabbix Server からの接続を許可する IP アドレス
171:ServerActive=127.0.0.1 # アクティブチェック時に接続する Zabbix Server のアドレス
182:Hostname=Zabbix server # このホストの識別名
552:Include=/etc/zabbix/zabbix_agentd.d/*.conf
[takashi@sample zabbix]$

というわけで、いったんこのまま
やっても Hostname くらいかな?

zabbix agent の起動

sudo systemctl restart zabbix-agent
sudo systemctl status  zabbix-agent

コンソールで確認

self monitoring

ある

snmptrapd について

参考

tech-mmmm.blogspot.com

EPEL インストール

これはすでに済んでいるのでスキップ

パッケージのインストール

sudo dnf install net-snmp net-snmp-utils net-snmp-perl perl-Time-HiRes \
perl-Text-Balanced perl-Sys-Syslog perl-DBI perl-DBD-MySQL perl-DBD-Pg \
perl-threads perl-Digest-MD5 perl-DBD-ODBC perl-Config-IniFiles perl-Net-IP

SNMPTT をダウンロード

公式サイトからダウンロードする
今回は snmptt_1.5.tgz をダウンロード

cd ~
mkdir src
cd src
wget https://github.com/snmptt/snmptt/releases/download/snmptt_1-5/snmptt_1.5.tgz
[takashi@sample zabbix]$ cd
[takashi@sample ~]$
[takashi@sample ~]$ mkdir src
[takashi@sample ~]$ cd src/
[takashi@sample src]$
[takashi@sample src]$ wget https://github.com/snmptt/snmptt/releases/download/snmptt_1-5/snmptt_1.5.tgz
--2025-10-26 23:11:47--  https://github.com/snmptt/snmptt/releases/download/snmptt_1-5/snmptt_1.5.tgz
github.com (github.com) をDNSに問いあわせています... 20.27.177.113
github.com (github.com)|20.27.177.113|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 302 Found
場所: https://release-assets.githubusercontent.com/github-production-release-asset/351748836/e7f1fbe5-919b-48c2-b95d-23691fcb0294?sp=r&sv=2018-11-09&sr=b&spr=https&se=2025-10-26T15%3A07%3A13Z&rscd=attachment%3B+filename%3Dsnmptt_1.5.tgz&rsct=application%2Foctet-stream&skoid=96c2d410-5711-43a1-aedd-ab1947aa7ab0&sktid=398a6654-997b-47e9-b12b-9515b896b4de&skt=2025-10-26T14%3A07%3A05Z&ske=2025-10-26T15%3A07%3A13Z&sks=b&skv=2018-11-09&sig=N3zhDNYRblxfj318lvEzCf4FUF%2BMIasMz9LCx1OO2Oo%3D&jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmVsZWFzZS1hc3NldHMuZ2l0aHVidXNlcmNvbnRlbnQuY29tIiwia2V5Ijoia2V5MSIsImV4cCI6MTc2MTQ4ODIxMiwibmJmIjoxNzYxNDg3OTEyLCJwYXRoIjoicmVsZWFzZWFzc2V0cHJvZHVjdGlvbi5ibG9iLmNvcmUud2luZG93cy5uZXQifQ.nkeLt27AXAzOEQAAvAhJ_qZvNvi_Bcj0-wCl5met7lc&response-content-disposition=attachment%3B%20filename%3Dsnmptt_1.5.tgz&response-content-type=application%2Foctet-stream [続く]
--2025-10-26 23:11:47--  https://release-assets.githubusercontent.com/github-production-release-asset/351748836/e7f1fbe5-919b-48c2-b95d-23691fcb0294?sp=r&sv=2018-11-09&sr=b&spr=https&se=2025-10-26T15%3A07%3A13Z&rscd=attachment%3B+filename%3Dsnmptt_1.5.tgz&rsct=application%2Foctet-stream&skoid=96c2d410-5711-43a1-aedd-ab1947aa7ab0&sktid=398a6654-997b-47e9-b12b-9515b896b4de&skt=2025-10-26T14%3A07%3A05Z&ske=2025-10-26T15%3A07%3A13Z&sks=b&skv=2018-11-09&sig=N3zhDNYRblxfj318lvEzCf4FUF%2BMIasMz9LCx1OO2Oo%3D&jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmVsZWFzZS1hc3NldHMuZ2l0aHVidXNlcmNvbnRlbnQuY29tIiwia2V5Ijoia2V5MSIsImV4cCI6MTc2MTQ4ODIxMiwibmJmIjoxNzYxNDg3OTEyLCJwYXRoIjoicmVsZWFzZWFzc2V0cHJvZHVjdGlvbi5ibG9iLmNvcmUud2luZG93cy5uZXQifQ.nkeLt27AXAzOEQAAvAhJ_qZvNvi_Bcj0-wCl5met7lc&response-content-disposition=attachment%3B%20filename%3Dsnmptt_1.5.tgz&response-content-type=application%2Foctet-stream
release-assets.githubusercontent.com (release-assets.githubusercontent.com) をDNSに問いあわせています... 185.199.108.133, 185.199.109.133, 185.199.110.133, ...
release-assets.githubusercontent.com (release-assets.githubusercontent.com)|185.199.108.133|:443 に接続 しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 633591 (619K) [application/octet-stream]
`snmptt_1.5.tgz' に保存中

snmptt_1.5.tgz            100%[=====================================>] 618.74K  --.-KB/s 時間 0.05s

2025-10-26 23:11:48 (11.0 MB/s) - `snmptt_1.5.tgz' へ保存完了 [633591/633591]

[takashi@sample src]$
[takashi@sample src]$ ls
snmptt_1.5.tgz
[takashi@sample src]$
[takashi@sample src]$

snmptt を手動でインストール

tar xvf snmptt_1.5.tgz

展開したファイルに含まれるSNMPTTとSNMPTT handlerの実行ファイルを /usr/sbin/ に配置する。

cd snmptt_1.5
sudo cp -v snmptt /usr/sbin/
sudo chmod +x /usr/sbin/snmptt
sudo cp -v snmptthandler /usr/sbin/
sudo chmod +x /usr/sbin/snmptthandler

# 
[takashi@sample snmptt_1.5]$ ls -l /usr/sbin/snmp*
-rwxr-xr-x. 1 root root  36256 115  2024 /usr/sbin/snmpd
-rwxr-xr-x. 1 root root  36368 115  2024 /usr/sbin/snmptrapd
-rwxr-xr-x. 1 root root 209091 1026 23:14 /usr/sbin/snmptt
-rwxr-xr-x. 1 root root   7780 1026 23:14 /usr/sbin/snmptthandler
[takashi@sample snmptt_1.5]$

実行ユーザーを作る

adduser -r snmptt

設定ファイルを配置する

sudo mkdir /etc/snmptt
sudo chown -Rv snmptt.snmptt /etc/snmptt
sudo chmod 750 /etc/snmptt
sudo cp -v snmptt.ini /etc/snmptt/

ログ等を保管するディレクトリを作成する。

sudo mkdir /var/log/snmptt
sudo chown -R snmptt.snmptt /var/log/snmptt
sudo chmod -R 755 /var/log/snmptt

sudo mkdir /var/spool/snmptt/
sudo chown -R snmptt.snmptt /var/spool/snmptt
sudo chmod -R 750 /var/spool/snmptt

systemdに起動用設定ファイルを配置する

sudo cp -v snmptt.service /usr/lib/systemd/system/snmptt.service
sudo chmod -x /usr/lib/systemd/system/snmptt.service

ログローテート用の設定ファイルを配置する

sudo cp -v snmptt.logrotate /etc/logrotate.d/snmptt

ログローテートの設定ファイルの記載が一部適切ではないので、★箇所を修正する

# vi /etc/logrotate.d/snmptt

/var/log/snmptt/snmptt*.log /var/log/snmptt/snmptthandler.debug {
    weekly
    notifempty
    missingok
}

/var/log/snmptt/snmptt.debug {
    weekly
    notifempty
    missingok
    postrotate
        /usr/bin/systemctl reload snmptt >/dev/null 2>/dev/null # ←★reloadコマンドを修正
    endscript
}

snmptt 設定

snmptt.ini を修正

sudo cp -iv /etc/snmptt/snmptt.ini{,.$(date -I)}

# 以下の通り修正
net_snmp_perl_enable = 1
log_enable = 1
log_file = /var/log/snmptt/snmptt.log
date_time_format = %Y/%m/%d %H:%M:%S
syslog_enable = 0

trap 受信時の出力内容を定義する snmptt.conf を作成する

cat << 'EOF' | sudo tee -a /etc/snmptt/snmptt.conf > /dev/null
EVENT general .* "General event" Normal
FORMAT ZBXTRAP $aA $*
EOF

起動

‘‘‘sh sudo systemctl start snmptt sudo systemctl enable snmptt sudo systemctl status snmptt

### snmptrapd 設定

sudo cp -iv /etc/sysconfig/snmptrapd{,.$(date -I)} sudo vim /etc/sysconfig/snmptrapd

追記

OPTIONS="-On -Lsd -p /var/run/snmptrapd.pid -M /usr/share/snmp/mibs:/usr/share/snmp/venders -m all"

sudo cp -iv /etc/snmp/snmptrapd.conf{,.$(date -I)} sudo vim /etc/snmp/snmptrapd.conf

追記

authCommunity log,execute,net public traphandle default /usr/sbin/snmptthandler

起動

sudo systemctl start snmptrapd sudo systemctl enable snmptrapd sudo systemctl status snmptrapd

### SNMP trap 受信テスト

Trap テストをしておく

snmptrap -v2c -c public 127.0.0.1 "" .1.3.6.1.6.3.1.1.5.1 coldStart s "Start"

SNMPTTのログにTrapの内容が出力されていれば問題ない

[takashi@sample snmptt_1.5]$ tail /var/log/snmptt/snmptt.log 2025-10-26 23:35:24 .1.3.6.1.6.3.1.1.5.1 Normal "General event" localhost - ZBXTRAP 127.0.0.1 Start [takashi@sample snmptt_1.5]$

## Zabbixサーバーの設定

この設定を追加する

SNMPTrapperFile=/var/log/snmptt/snmptt.log StartSNMPTrapper=1




cd /etc/zabbix sudo vim zabbix_server.conf




[takashi@sample zabbix]$ sudo grep -i snmptrapperfile zabbix_server.conf

Option: SNMPTrapperFile

SNMPTrapperFile=/tmp/zabbix_traps.tmp

SNMPTrapperFile=/var/log/snmptrap/snmptrap.log [takashi@sample zabbix]$ [takashi@sample zabbix]$ sudo grep -i startsnmptrapper= zabbix_server.conf

StartSNMPTrapper=0

[takashi@sample zabbix]$

サービスの再起動

sudo systemctl restart zabbix-server

## zabbix での trap 監視設定

stress コマンド使ってみる

sudo dnf install stress

2コアに30秒負荷

これじゃ、トラップ上がらないかも。調節して

stress --cpu 2 --timeout 30s

とりあえずここまで