CentOS 8/RHEL 8 に Icinga Web 2 をインストールする方法 |
前回の記事では、CentOS 8/RHEL 8 Linux マシンへの Icinga 2 のインストールについて説明しました。これは、Icinga Web 2 を CentOS 8/RHEL 8 にインストールする方法を説明する継続ガイドです。Icinga Web 2 は、簡潔で簡素化された設計で提供される Web アプリケーション用の強力な PHP フレームワークです。高速で応答性が高く、アクセスしやすく、モジュールを使用して簡単に拡張できます。
公式 Icinga2 パッケージ リポジトリで入手可能なパッケージから Icinga Web 2 をインストールします。インストール後、セットアップ ウィザードを使用して、Web インターフェイスからセットアップと構成を実行します。
ステップ 1: CentOS 8/RHEL 8 に Icinga 2 をインストールする
以下のガイドを使用して、Icinga 2 のインストールを開始する必要があります。
- CentOS/RHEL 8 に Icinga 2 をインストールする
Icinga 2 サーバーのインストール後、CentOS 8/RHEL 8 Linux システムへの Icinga Web 2 のインストールに進みます。
ステップ 2: CentOS 8/RHEL 8 Linux に Icinga Web 2 をインストールする
PowerTools リポジトリと EPEL を有効にします。
sudo dnf install -y 'dnf-command(config-manager)'
sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf config-manager --set-enabled powertools
RHEL 8 を実行している場合は、追加のリポジトリを有効にすることを検討してください。
sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo subscription-manager repos --enable=rhel-8-server-optional-rpms --enable=rhel-8-server-extras-rpms次に、Icinga Web 2 のリポジトリ コンテンツをシステムに追加します。
sudo dnf -y install https://packages.icinga.com/epel/icinga-rpm-release-8-latest.noarch.rpm私のインストール出力は次のとおりです。
Last metadata expiration check: 0:02:42 ago on Sat 28 Dec 2019 09:03:06 AM EAT.
icinga-rpm-release-8-4.el8.icinga.noarch.rpm 8.3 kB/s | 9.5 kB 00:01
Dependencies resolved.
========================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================
Installing:
icinga-rpm-release noarch 8-4.el8.icinga @commandline 9.5 k
Transaction Summary
========================================================================================================================================================
Install 1 Package
Total size: 9.5 k
Installed size: 2.6 k
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : icinga-rpm-release-8-4.el8.icinga.noarch 1/1
Verifying : icinga-rpm-release-8-4.el8.icinga.noarch 1/1
Installed:
icinga-rpm-release-8-4.el8.icinga.noarch
Complete!パッケージインデックスを更新します。
sudo dnf makecache次のコマンドを使用して、Apache Web サーバーと Icinga Web 2 を CentOS 8/RHEL 8 Linux にインストールします。
sudo dnf install httpd icingacli icingaweb2 nagios-plugins-allPHP やその他の拡張機能などの依存関係パッケージは、AppStream リポジトリからインストールされます。
PHP と必要なモジュールのインストールも実行します。
sudo dnf module reset php -y
sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
sudo dnf module install php:remi-8.0
sudo dnf -y install php-cli php-pdo php-common php-mysql php-curl php-json php-zip php-gd php-xml php-mbstring php-pecl-mailparse php-imap php-ldap php-imagickhttpd を開始し、サービスを開始し、firewalld を構成する必要があります。
sudo systemctl enable --now httpd
sudo firewall-cmd --add-service={http,https} --permanent
sudo firewall-cmd --reloadまた、PHP-FPM サービスを開始します。
sudo systemctl enable --now php-fpm.serviceIcinga Web 2 設定ファイルは次のとおりです: /etc/httpd/conf.d/icingaweb2.conf
SELinux を許可モードにする
セットアップを簡単にするには、SELinux を無効にするか、許可モードにすることを検討してください。
sudo setenforce 0
sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config
cat /etc/selinux/config | grep SELINUX=次の手順を実行する前に、httpd サービスと php-fpm サービスが実行状態であることを確認してください。
$ systemctl status php-fpm httpd
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2019-12-28 09:14:58 EAT; 9min ago
Main PID: 12132 (php-fpm)
Status: "Processes active: 0, idle: 5, Requests: 0, slow: 0, Traffic: 0req/sec"
Tasks: 6 (limit: 11512)
Memory: 27.6M
CGroup: /system.slice/php-fpm.service
├─12132 php-fpm: master process (/etc/php-fpm.conf)
├─12270 php-fpm: pool www
├─12271 php-fpm: pool www
├─12272 php-fpm: pool www
├─12273 php-fpm: pool www
└─12274 php-fpm: pool www
Dec 28 09:14:58 centos8.novalocal systemd[1]: Starting The PHP FastCGI Process Manager...
Dec 28 09:14:58 centos8.novalocal systemd[1]: Started The PHP FastCGI Process Manager.
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/httpd.service.d
└─php-fpm.conf
Active: active (running) since Sat 2019-12-28 09:14:58 EAT; 9min ago
Docs: man:httpd.service(8)
Main PID: 12131 (httpd)
Status: "Running, listening on: port 80"
Tasks: 213 (limit: 11512)
Memory: 25.1M
CGroup: /system.slice/httpd.service
├─12131 /usr/sbin/httpd -DFOREGROUND
├─12133 /usr/sbin/httpd -DFOREGROUND
├─12134 /usr/sbin/httpd -DFOREGROUND
├─12135 /usr/sbin/httpd -DFOREGROUND
└─12136 /usr/sbin/httpd -DFOREGROUND
Dec 28 09:14:58 centos8.novalocal systemd[1]: Starting The Apache HTTP Server...
Dec 28 09:14:58 centos8.novalocal httpd[12131]: Server configured, listening on: port 80
Dec 28 09:14:58 centos8.novalocal systemd[1]: Started The Apache HTTP Server.ステップ 2: CentOS 8/RHEL 8 で Icinga Web 2 を構成する
CLI でコマンドを実行して構成を開始します。
sudo icingacli setup config webserver apacheWebセットアップに必要な認証トークンを生成します。トークンを生成するには、次のコマンドを使用します。
$ sudo icingacli setup token create
The newly generated setup token is: 89f98cfcccbbeef4Webセットアップの開始
最後にブラウザで Icinga Web 2 にアクセスしてセットアップ ウィザードにアクセスし、インストールを完了します: /icingaweb2/setup。
http://[serverip_or_hostname]/icingaweb2/setup次のようなようこそページが表示されます。
先ほど生成したトークンを貼り付けて、「次へ」をクリックします。トークンを覚えていない場合は、icingacli を使用してトークンを表示できます。
$ sudo icingacli setup token show
The current setup token is: 89f98cfcccbbeef4次のページで、有効にするモジュールを選択します。
要件を確認してから、データベースのセットアップに進みます。
データベース構成を入力して検証します。
- MariaDB データベース インストール ガイド: CentOS/RHEL 8 に MariaDB をインストールする
- PostgreSQL データベースのインストール: CentOS 8 に PostgreSQL をインストールする | RHEL8
Icinga2 用の MariaDB データベース サーバーでのデータベース作成の例:
$ mysql -u root -p
CREATE DATABASE icingaweb2;
GRANT ALL PRIVILEGES ON icingaweb2.* TO 'icingaweb2'@'localhost' IDENTIFIED BY 'StroNgP@ssw0d';
FLUSH PRIVILEGES;
EXIT;データベース接続の詳細を入力し、「次へ」ボタンを押す前に「設定の検証」をクリックします。
バックエンド名を設定します。
最初の管理者ユーザーを作成します。
ロギングを構成します。
モニタリングIDOリソースの構成
モニタリング IDO リソース データベースはガイドで作成されており、Icinga2 サーバー内の次のファイルで確認できます。
$ sudo cat /etc/icinga2/features-available/ido-mysql.conf
/**
* The IdoMysqlConnection type implements MySQL support
* for DB IDO.
*/
object IdoMysqlConnection "ido-mysql" {
user = "icinga"
password = "StroNgP@ss"
host = "localhost"
database = "icinga"
}
入力して接続が成功したかどうかを検証します
コマンドトランスポート
ここでは、監視インスタンス (Icinga2 サーバー) にコマンドを送信する方法を定義します。
コマンドを送信する先の Icinga 2 のホストでAPI セットアップを実行する必要があります。
$ sudo icinga2 api setup
information/cli: Generating new CA.
information/base: Writing private key to '/var/lib/icinga2/ca//ca.key'.
information/base: Writing X509 certificate to '/var/lib/icinga2/ca//ca.crt'.
information/cli: Generating new CSR in '/var/lib/icinga2/certs//frankubuntu20.novalocal.csr'.
information/base: Writing private key to '/var/lib/icinga2/certs//frankubuntu20.novalocal.key'.
information/base: Writing certificate signing request to '/var/lib/icinga2/certs//frankubuntu20.novalocal.csr'.
information/cli: Signing CSR with CA and writing certificate to '/var/lib/icinga2/certs//frankubuntu20.novalocal.crt'.
information/pki: Writing certificate to file '/var/lib/icinga2/certs//frankubuntu20.novalocal.crt'.
information/cli: Copying CA certificate to '/var/lib/icinga2/certs//ca.crt'.
information/cli: Adding new ApiUser 'root' in '/etc/icinga2/conf.d/api-users.conf'.
information/cli: Reading '/etc/icinga2/icinga2.conf'.
information/cli: Enabling the 'api' feature.
Enabling feature api. Make sure to restart Icinga 2 for these changes to take effect.
information/cli: Updating 'NodeName' constant in '/etc/icinga2/constants.conf'.
information/cli: Created backup file '/etc/icinga2/constants.conf.orig'.
information/cli: Updating 'ZoneName' constant in '/etc/icinga2/constants.conf'.
information/cli: Backup file '/etc/icinga2/constants.conf.orig' already exists. Skipping backup.
Done.次に、Icinga 2 デーモンを再起動して、インストールを完了します。
sudo systemctl restart icinga2Icinga 2 API に対する認証用に生成されたデフォルトの ApiUser オブジェクトは、以下のファイルにあります。
$ sudo cat /etc/icinga2/conf.d/api-users.conf
/**
* The ApiUser objects are used for authentication against the API.
*/
object ApiUser "root" {
password = "733313f70d81ed81"
// client_cn = ""
permissions = [ "*" ]
}icinga2 サービスを変更して再起動するか、提供されているものを使用できます。
CentOS 8/RHEL 8 Linux システムへの Icinga Web 2 のインストールを完了し、成功ページに表示されるリンクを使用してログインします。
CentOS 8/RHEL 8 Linux システムに Icinga Web 2 をインストールして構成する方法に関するガイドはこれで終わりです。この記事があなたのお役に立てば幸いです。セットアップ時に問題やエラーが発生した場合は、弊社までご連絡ください。喜んでお手伝いいたします。









