0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AlmaLinux 8.8 に Zabbix 4.0 LTS (4.0.50) をインストールする

Last updated at Posted at 2025-01-26

Zabbix 4.0 LTS最新版をインストールしてみます。

環境

image.png

OS: almalinux-release-8.8-1.el8.x86_64
Zabbix Server: zabbix-server-pgsql-4.0.50-1.el8.x86_64
Zabbix Client: zabbix-agent-4.0.50-1.el8.x86_64
Database: postgresql-server-15.10-1.module_el8.10.0+3929+38258aa5.x86_64

databaseはpostgresqlを使用し、バージョンは後方互換(Zabbix 7.0)を考慮しversion15を導入します。

1.Zabbix Serverインストール

1.1 事前準備

OSインストールのほか、以下を実施しておきます。
・SELinuxの停止
・Firewalldの停止

また、AlmaLinux8ではGPG Keyの更新が必要になっているため、以下についても実施しておきます。

# rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux

1.2 Zabbixパッケージインストール

リポジトリをダウンロードし、インストールを実施します。

# rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/8/x86_64/zabbix-release-4.0-2.el8.noarch.rpm

# dnf install -y zabbix-server-pgsql zabbix-web-pgsql zabbix-agent

インストール済み:
  OpenIPMI-libs-2.0.31-3.el8.x86_64
  almalinux-logos-httpd-84.5-1.el8.noarch
  apr-1.6.3-12.el8.x86_64
  apr-util-1.6.1-9.el8.x86_64
  apr-util-bdb-1.6.1-9.el8.x86_64
  apr-util-openssl-1.6.1-9.el8.x86_64
  dejavu-fonts-common-2.35-7.el8.noarch
  dejavu-sans-fonts-2.35-7.el8.noarch
  fontconfig-2.13.1-4.el8.x86_64
  fontpackages-filesystem-1.44-22.el8.noarch
  fping-5.1-1.el8.x86_64
  gd-2.2.5-7.el8.x86_64
  httpd-2.4.37-65.module_el8.10.0+3874+c2064c23.2.x86_64
  httpd-filesystem-2.4.37-65.module_el8.10.0+3874+c2064c23.2.noarch
  httpd-tools-2.4.37-65.module_el8.10.0+3874+c2064c23.2.x86_64
  jbigkit-libs-2.1-14.el8.x86_64
  libX11-1.6.8-9.el8_10.x86_64
  libX11-common-1.6.8-9.el8_10.noarch
  libXau-1.0.9-3.el8.x86_64
  libXpm-3.5.12-11.el8.x86_64
  libjpeg-turbo-1.5.3-12.el8.x86_64
  libpq-13.11-1.el8.alma.1.x86_64
  libtiff-4.0.9-33.el8_10.x86_64
  libwebp-1.0.0-9.el8_9.1.x86_64
  libxcb-1.13.1-1.el8.x86_64
  mailcap-2.1.48-3.el8.noarch
  mod_http2-1.15.7-10.module_el8.10.0+3904+caabc2d4.1.x86_64
  net-snmp-libs-1:5.8-30.el8.x86_64
  nginx-filesystem-1:1.14.1-9.module_el8.3.0+2165+af250afe.alma.noarch
  php-7.2.24-1.module_el8.3.0+2010+7c76a223.x86_64
  php-bcmath-7.2.24-1.module_el8.3.0+2010+7c76a223.x86_64
  php-cli-7.2.24-1.module_el8.3.0+2010+7c76a223.x86_64
  php-common-7.2.24-1.module_el8.3.0+2010+7c76a223.x86_64
  php-fpm-7.2.24-1.module_el8.3.0+2010+7c76a223.x86_64
  php-gd-7.2.24-1.module_el8.3.0+2010+7c76a223.x86_64
  php-json-7.2.24-1.module_el8.3.0+2010+7c76a223.x86_64
  php-ldap-7.2.24-1.module_el8.3.0+2010+7c76a223.x86_64
  php-mbstring-7.2.24-1.module_el8.3.0+2010+7c76a223.x86_64
  php-pdo-7.2.24-1.module_el8.3.0+2010+7c76a223.x86_64
  php-pgsql-7.2.24-1.module_el8.3.0+2010+7c76a223.x86_64
  php-xml-7.2.24-1.module_el8.3.0+2010+7c76a223.x86_64
  unixODBC-2.3.7-1.el8.x86_64
  zabbix-agent-4.0.50-1.el8.x86_64
  zabbix-server-pgsql-4.0.50-1.el8.x86_64
  zabbix-web-4.0.50-1.el8.noarch
  zabbix-web-pgsql-4.0.50-1.el8.noarch

完了しました!

1.3 postgresqlパッケージインストール

postgresqlはzabbix後方互換性のため、OS標準のversion10でなくversion15をインストールします。

適用可能バージョンを確認します。

# dnf module list postgresql

メタデータの期限切れの最終確認: 0:00:48 前の 2025年01月25日 22時46分07秒 に実施しました。
AlmaLinux 8 - AppStream
Name             Stream       Profiles                 Summary                            
postgresql       9.6          client, server [d]       PostgreSQL server and client module
postgresql       10 [d]       client, server [d]       PostgreSQL server and client module
postgresql       12           client, server [d]       PostgreSQL server and client module
postgresql       13           client, server [d]       PostgreSQL server and client module
postgresql       15           client, server [d]       PostgreSQL server and client module
postgresql       16           client, server [d]       PostgreSQL server and client module

ヒント: [d]efault, [e]nabled, [x]disabled, [i]nstalled 

適用バージョンを15に設定します。

# dnf module enable postgresql:15 -y

postgresqlをインストールします。

# dnf install -y postgresql postgresql-server

インストール済み:
  libicu-60.3-2.el8_1.x86_64
  postgresql-15.10-1.module_el8.10.0+3929+38258aa5.x86_64
  postgresql-private-libs-15.10-1.module_el8.10.0+3929+38258aa5.x86_64
  postgresql-server-15.10-1.module_el8.10.0+3929+38258aa5.x86_64

完了しました!

postgresqlはpostgresqlクライアント、postgresql-serverはpostgresqlサーバ用途でインストールします。

1.4 postgresql設定

initdbによる初期化、createuserによるユーザ作成、createdbによるデータベース作成を実施します。
また、以下ファイル(zabbix-serverインストール時に作成)によるテーブル作成も実施します。
/usr/share/doc/zabbix-server-pgsql*/create.sql.gz

# postgresql-setup initdb

# systemctl enable postgresql
# systemctl start postgresql
# systemctl status postgresql

# sudo -u postgres createuser --pwprompt zabbix 
# sudo -u postgres createdb -O zabbix zabbix

# zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | sudo -u zabbix psql zabbix

/var/lib/pgsql/data/postgresql.confについて、リッスンポート設定をワイルドカード指定します。

# vi /var/lib/pgsql/data/postgresql.conf
--------------------------------------------
listen_addresses = 'localhost'

↓↓↓

listen_addresses = '*'
#listen_addresses = 'localhost'

/var/lib/pgsql/data/pg_hba.confについて、認証設定をmd5認証に修正します。
#postgresqlへlocalhost接続時、内部的にIPv6を利用して接続することもあるのでIPv6接続も変更しておくことを推奨します。

# vi /var/lib/pgsql/data/pg_hba.conf
--------------------------------------------
local   all             all                                     peer
host    all             all             127.0.0.1/32            ident
host    all             all             ::1/128                 ident

↓↓↓

local   all             all                                     md5
host    all             all             127.0.0.1/32            md5
host    all             all             ::1/128                 md5

pg_hba.confの認証設定は以下になります。
trust: 必ず認証。パスワード不要
reject: 接続を無条件に拒否
md5: 認証時にMD5暗号化パスワードを要求
password: 認証時に平文のパスワードを要求
ident: OSユーザ名を取得し、 データベースユーザ名と一致するか検査
peer: ローカル接続時のみ使用可能なident認証
https://www.postgresql.jp/docs/9.0/auth-pg-hba-conf.html


各設定ファイル編集後、サービスを再起動します。

# systemctl restart postgresql
# systemctl status postgresql

1.5 hosts編集

hostsファイルに自身の接続先を記載しておきます。

# vi /etc/hosts
--------------------------------------------
192.168.142.71  alma88-vzs1

1.6 Zabbix Server設定

Zabbix Serverの各種設定ファイルを編集し、起動します。

# vi /etc/zabbix/zabbix_server.conf
--------------------------------------------
DBPassword=[postgresql-password]
ListenIP=192.168.142.71
Timeout=10

DBPassword: postgresqlのzabbixユーザのパスワードを指定
ListenIP: ZabbixAgentやブラウザで接続するリッスンIPアドレスを指定
Timeout: 通信タイムアウト時間(デフォルト3秒だとたまに通信エラーとなる)

1.7 PHP設定

PHPのタイムゾーン設定を行います。

# vi /etc/php-fpm.d/zabbix.conf
--------------------------------------------
php_value date.timezone Asia/Tokyo

1.8 各種サービス自動起動・再起動

# systemctl enable zabbix-server httpd php-fpm
# systemctl restart zabbix-server httpd php-fpm

# systemctl status zabbix-server
# systemctl status httpd
# systemctl status php-fpm

1.9 web接続

webブラウザを起動し、以下URLに接続します。
http://<リッスンIP>/zabbix/setup.php

Next Stepを押下します。
image.png

requisitesが全てokであることを確認し、Next Stepを押下します。
image.png

passwordを入力し、Next Stepを押下します。
Database schemaは特に入力不要です。
image.png

HostNameを入力し、Next Stepを押下します。
image.png

Hostは名前解決に使用するため、/etc/hostsやDNS等で名前解決できるようにしておくことを推奨します。

Next Stepを押下します。
image.png

インストールが完了しました。Finishを押下します。
image.png

ログイン画面が表示されました。初期アカウントを利用してログインします。
image.png

初期アカウントは ユーザ:Admin、パスワード:zabbixの特権管理ユーザになります。


ログインに成功しました。
image.png

以下のようにZabbix Server is not runningとなっている場合、下記2点を確認してください。
①Zabbixサーバへの名前解決(名前解決設定およびfirewall/selinux等NW制限設定)
②zabbix-server.conf内のDB接続設定(DBPassword等)
image.png
image.png

2.Zabbix Agentインストール

2.1 事前準備

OSインストールのほか、以下を実施しておきます。
・SELinuxの停止
・Firewalldの停止

また、AlmaLinuxではGPG Keyの更新が必要になっているため、以下についても実施しておきます。

# rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux

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

# rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/8/x86_64/zabbix-release-4.0-2.el8.noarch.rpm

# dnf install -y zabbix-agent

2.3 Zabbix Agent設定

Zabbix Agentの各種設定ファイルを編集し、起動します。

# vi /etc/zabbix/zabbix_agentd.conf
--------------------------------------------
Server=192.168.142.71
ServerActive=192.168.142.71
HostnameItem=system.hostname
AllowRoot=1

Server: zabbixサーバの接続先を指定(Zabbixエージェント用)
ServerActive: zabbixサーバの接続先を指定(Zabbixエージェントアクティブ用)
HostnameItem: Zabbixサーバに指定するホスト名の表記
AllowRoot: Zabbixをroot権限で動作させる
Timeout: 通信タイムアウト時間(デフォルト3秒だとたまに通信エラーとなる)


また、Zabbixをルート権限で動作させる(/var/log/messages等へアクセスさせる)ために、サービス起動権限についてrootに変更を実行します。

zabbix-agent.service
# vi /usr/lib/systemd/system/zabbix-agent.service
--------------------------------------------
User=root
Group=root

サービスを再起動します。

restart_services
# systemctl daemon-reload
# systemctl restart zabbix-agent
# systemctl status zabbix-agent

3.Server/Agent接続

3.1 ホスト登録

設定 - ホスト - ホストの作成を押下します。
image.png



*がついている必須入力、およびエージェントのインターフェース等を入力し、追加を押下します。

ホスト名はクライアントマシンでhostnameコマンドを実行した結果と完全一致させる必要があります。

image.png



ホストが追加され、エージェントの状態もグリーンとなりました。

エージェントの状態が更新/反映されるまで5分程度かかる場合があります。

image.png

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?