🤖
箱庭にzabbixを入れてみた(インストール編)
ここまでで作った箱庭はこんな感じ
ここにこんな感じでzabbixを入れてみる
環境
- CentOS Linux release 7.9.2009 (Core)
- Virtualbox 6.1
- windows 10(ホストOS)
- mysql Ver 8.0.31
- zabbix_server (Zabbix) 5.0.28
- zabbix_agentd (daemon) (Zabbix) 5.0.28
zabbixインストール
zabbixユーザーとグループの作成
[root@CoVb ~]# groupadd --system zabbix
[root@covb ~]# useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
[root@covb ~]# cat /etc/group | grep zabbix
zabbix:x:995:
[root@covb ~]# cat /etc/passwd | grep zabbix
zabbix:x:997:995:Zabbix Monitoring System:/usr/lib/zabbix:/sbin/nologin
[root@covb ~]#
MySqLインストール
- 念の為
- --exclude=kernel* でカーネルはアップデートしない
[root@covb ~]# yum -y update --exclude=kernel*
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
・
・
・
- MySqLのリポジトリの登録
[root@covb ~]# ll /etc/yum.repos.d/
合計 40
-rw-r--r--. 1 root root 1664 11月 24 2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 11月 24 2020 CentOS-CR.repo
-rw-r--r--. 1 root root 649 11月 24 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 630 11月 24 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 11月 24 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 11月 24 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root 314 11月 24 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 616 11月 24 2020 CentOS-x86_64-kernel.repo
[root@covb ~]#
[root@covb ~]# yum localinstall https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
読み込んだプラグイン:fastestmirror
mysql80-community-release-el7-3.noarch.rpm | 25 kB 00:00:00
/var/tmp/yum-root-rKD4Wp/mysql80-community-release-el7-3.noarch.rpm を調べています: mysql80-community-release-el7-3.noarch
/var/tmp/yum-root-rKD4Wp/mysql80-community-release-el7-3.noarch.rpm をインストール済みとして設定しています
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ mysql80-community-release.noarch 0:el7-3 を インストール
--> 依存性解決を終了しました。
依存性を解決しました
=======================================================================================================================
Package アーキテクチャー
バージョン リポジトリー 容量
=======================================================================================================================
インストール中:
mysql80-community-release noarch el7-3 /mysql80-community-release-el7-3.noarch 31 k
トランザクションの要約
=======================================================================================================================
インストール 1 パッケージ
合計容量: 31 k
インストール容量: 31 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
インストール中 : mysql80-community-release-el7-3.noarch 1/1
検証中 : mysql80-community-release-el7-3.noarch 1/1
インストール:
mysql80-community-release.noarch 0:el7-3
完了しました!
[root@covb ~]#
[root@covb ~]# ll /etc/yum.repos.d/
合計 48
-rw-r--r--. 1 root root 1664 11月 24 2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 11月 24 2020 CentOS-CR.repo
-rw-r--r--. 1 root root 649 11月 24 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 630 11月 24 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 11月 24 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 11月 24 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root 314 11月 24 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 616 11月 24 2020 CentOS-x86_64-kernel.repo
-rw-r--r--. 1 root root 2108 4月 25 2019 mysql-community-source.repo
-rw-r--r--. 1 root root 2076 4月 25 2019 mysql-community.repo
[root@covb ~]#
- MySqLインストール
- 最初のインストールではGPGキーが古くてインストールがコケたので新しいGPGキー入れた
- 対処はハマった編で
[root@covb ~]# yum install mysql-community-server
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
・
・
・
置換:
mariadb-libs.x86_64 1:5.5.68-1.el7
完了しました!
[root@covb ~]#
MySqL初期設定
- MySqLの実行
[root@covb ~]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
[root@covb ~]#
[root@covb ~]# systemctl start mysqld
[root@covb ~]#
[root@covb ~]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since 金 2022-10-21 16:35:41 JST; 1s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 16747 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 16820 (mysqld)
Status: "Server is operational"
CGroup: /system.slice/mysqld.service
mq16820 /usr/sbin/mysqld
10月 21 16:35:34 covb systemd[1]: Starting MySQL Server...
10月 21 16:35:41 covb systemd[1]: Started MySQL Server.
[root@covb ~]#
- rootのパスワードを変更
[root@covb ~]# cat /var/log/mysqld.log | grep temporary
2022-10-21T07:35:36.707875Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: hogehoge #実際にはゴチャゴチャ書いてある
[root@covb ~]#
[root@covb ~]# mysql -u root -p
Enter password:***** #ここに↑のtemporaryパスワードを入力
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.31
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '******'; #自分でお好きなパスフレーズをベタ打ち
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
- 設定したパスワードが有効か確認
[root@covb ~]# mysql -u root -p
Enter password:***** #ここにパスワードを入力
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.31 MySQL Community Server - GPL
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> exit
Bye
[root@covb ~]#
ちなみにパスフレーズが簡単すぎると怒られる
[root@covb ~]#
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'hogehoge';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
zabbixリポジトリのインストール
[root@covb ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm を取得中
警告: /var/tmp/rpm-tmp.2UOrDZ: ヘッダー V4 RSA/SHA512 Signature、鍵 ID a14fe591: NOKEY
準備しています... ################################# [100%]
更新中 / インストール中...
1:zabbix-release-5.0-1.el7 ################################# [100%]
[root@covb ~]#
[root@covb ~]# ll /etc/yum.repos.d/ | grep zabbix
-rw-r--r--. 1 root root 853 5月 11 2020 zabbix.repo
[root@covb ~]#
zabbix-server、zabbix-agentインストール
[root@covb ~]# yum install zabbix-server-mysql zabbix-agent
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
・
・
・
完了しました!
[root@covb ~]#
zabbixフロントエンドの設定
- Red Hat Software Collectionsインストール
[root@covb ~]# yum install centos-release-scl
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
・
・
・
依存性関連をインストールしました:
centos-release-scl-rh.noarch 0:2-3.el7.centos
完了しました!
[root@covb ~]#
- zabbix-frontendの編集
[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend
enabled=1 #ここを0⇒1に変える
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
- フロントエンドパッケージのインストール
[root@covb ~]# yum install zabbix-web-mysql-scl zabbix-apache-conf-scl
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
・
・
・
完了しました!
[root@covb ~]#
zabbixデータベース作成
- rootでログイン
[root@covb ~]# mysql -u root -p
Enter password:***** #rootのパスワードを入力
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.31 MySQL Community Server - GPL
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
- データベース作成
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected, 2 warnings (0.00 sec)
mysql>
- (mysql内の)zabbixユーザーのパスワード設定
mysql> create user zabbix@localhost identified by '*******'; #実際にはパスワードベタ打ち
Query OK, 0 rows affected (0.02 sec)
mysql>
- zabbixユーザにzabbixデータベースの権限付与
mysql> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.01 sec)
mysql>
- データの流し込み
[root@covb ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password:***** #mysql内のzabbixユーザーのパスワード
[root@covb ~]#
.confの編集
- zabbix_server.confの編集
- MySqLzabbixユーザーのパスワードが反映されないので手入力
[root@covb ~]# vim /etc/zabbix/zabbix_server.conf
### Option: DBUser
# Database user.
#
# Mandatory: no
# Default:
# DBUser=
DBUser=zabbix
### Option: DBPassword
# Database password.
# Comment this line if no password is used.
#
# Mandatory: no
# Default:
DBPassword=******* #コメントアウトを外してzabbixユーザーのパスワードを入力
- zabbix.confの編集
- zabbix使用地域のタイムゾーンを設定
[root@covb ~]# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
[zabbix]
user = apache
group = apache
・
・
・
; php_value[date.timezone] = Asia/Tokyo
各サービスの有効化
- zabbix-server、zabbix-agent、httpd(apache)、phpの起動
[root@covb ~]# systemctl status zabbix-server zabbix-agent httpd rh-php72-php-fpm
● zabbix-server.service - Zabbix Server
Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; disabled; vendor preset: disabled)
Active: inactive (dead)
● zabbix-agent.service - Zabbix Agent
Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; disabled; vendor preset: disabled)
Active: inactive (dead)
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:httpd(8)
man:apachectl(8)
● rh-php72-php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/rh-php72-php-fpm.service; disabled; vendor preset: disabled)
Active: inactive (dead)
[root@covb ~]#
[root@covb ban]# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@covb ban]#
[root@covb ban]# systemctl status zabbix-server zabbix-agent httpd rh-php72-php-fpm
● zabbix-server.service - Zabbix Server
Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; disabled; vendor preset: disabled)
Active: active (running) since 日 2022-10-23 16:09:25 JST; 9s ago
Process: 3761 ExecStop=/bin/kill -SIGTERM $MAINPID (code=exited, status=0/SUCCESS)
Process: 3766 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS)
Main PID: 3776 (zabbix_server)
CGroup: /system.slice/zabbix-server.service
tq3776 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
tq3781 /usr/sbin/zabbix_server: configuration syncer [synced configuration in 0.058638 sec, idle 60 sec]
tq3792 /usr/sbin/zabbix_server: alert manager #1 [sent 0, failed 0 alerts, idle 5.090416 sec during 5.090545 sec]
tq3793 /usr/sbin/zabbix_server: alerter #1 started
tq3794 /usr/sbin/zabbix_server: alerter #2 started
tq3795 /usr/sbin/zabbix_server: alerter #3 started
tq3796 /usr/sbin/zabbix_server: preprocessing manager #1 [queued 0, processed 2 values, idle 5.020689 sec during 5.021533...
tq3797 /usr/sbin/zabbix_server: preprocessing worker #1 started
tq3798 /usr/sbin/zabbix_server: preprocessing worker #2 started
tq3799 /usr/sbin/zabbix_server: preprocessing worker #3 started
tq3800 /usr/sbin/zabbix_server: lld manager #1 [processed 0 LLD rules, idle 5.095438sec during 5.095612 sec]
tq3801 /usr/sbin/zabbix_server: lld worker #1 started
tq3802 /usr/sbin/zabbix_server: lld worker #2 started
tq3803 /usr/sbin/zabbix_server: housekeeper [startup idle for 30 minutes]
tq3804 /usr/sbin/zabbix_server: timer #1 [updated 0 hosts, suppressed 0 events in 0.001156 sec, idle 34 sec]
tq3805 /usr/sbin/zabbix_server: http poller #1 [got 0 values in 0.001274 sec, idle 5 sec]
tq3806 /usr/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.000360 sec, idle 60 sec]
tq3807 /usr/sbin/zabbix_server: history syncer #1 [processed 0 values, 0 triggers in 0.000012 sec, idle 1 sec]
tq3808 /usr/sbin/zabbix_server: history syncer #2 [processed 1 values, 0 triggers in 0.003558 sec, idle 1 sec]
tq3809 /usr/sbin/zabbix_server: history syncer #3 [processed 0 values, 0 triggers in 0.000011 sec, idle 1 sec]
tq3810 /usr/sbin/zabbix_server: history syncer #4 [processed 0 values, 0 triggers in 0.000005 sec, idle 1 sec]
tq3811 /usr/sbin/zabbix_server: escalator #1 [processed 0 escalations in 0.000791 sec, idle 3 sec]
tq3812 /usr/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000059 sec, idle 5 sec]
tq3813 /usr/sbin/zabbix_server: self-monitoring [processed data in 0.000019 sec, idle 1 sec]
tq3814 /usr/sbin/zabbix_server: task manager [processed 0 task(s) in 0.002657 sec, idle 5 sec]
tq3815 /usr/sbin/zabbix_server: poller #1 [got 1 values in 0.000530 sec, idle 1 sec]
tq3816 /usr/sbin/zabbix_server: poller #2 [got 0 values in 0.000007 sec, idle 1 sec]
tq3817 /usr/sbin/zabbix_server: poller #3 [got 0 values in 0.000007 sec, idle 1 sec]
tq3818 /usr/sbin/zabbix_server: poller #4 [got 0 values in 0.000007 sec, idle 1 sec]
tq3819 /usr/sbin/zabbix_server: poller #5 [got 0 values in 0.000012 sec, idle 1 sec]
tq3820 /usr/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000073 sec, idle 5 sec]
tq3821 /usr/sbin/zabbix_server: trapper #1 [processed data in 0.000000 sec, waiting for connection]
tq3822 /usr/sbin/zabbix_server: trapper #2 [processed data in 0.000000 sec, waiting for connection]
tq3823 /usr/sbin/zabbix_server: trapper #3 [processed data in 0.000000 sec, waiting for connection]
tq3824 /usr/sbin/zabbix_server: trapper #4 [processed data in 0.000000 sec, waiting for connection]
tq3825 /usr/sbin/zabbix_server: trapper #5 [processed data in 0.000000 sec, waiting for connection]
tq3826 /usr/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.000106 sec, idle 5 sec]
mq3827 /usr/sbin/zabbix_server: alert syncer [queued 0 alerts(s), flushed 0 result(s) in 0.000472 sec, idle 1 sec]
10月 23 16:09:25 covb systemd[1]: Stopped Zabbix Server.
10月 23 16:09:25 covb systemd[1]: Starting Zabbix Server...
10月 23 16:09:25 covb systemd[1]: Started Zabbix Server.
● zabbix-agent.service - Zabbix Agent
Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; disabled; vendor preset: disabled)
Active: active (running) since 日 2022-10-23 16:09:25 JST; 9s ago
Process: 3762 ExecStop=/bin/kill -SIGTERM $MAINPID (code=exited, status=0/SUCCESS)
Process: 3765 ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE (code=exited, status=0/SUCCESS)
Main PID: 3769 (zabbix_agentd)
CGroup: /system.slice/zabbix-agent.service
tq3769 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
tq3771 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
tq3772 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
tq3773 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
tq3774 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
mq3775 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
10月 23 16:09:25 covb systemd[1]: Stopped Zabbix Agent.
10月 23 16:09:25 covb systemd[1]: Starting Zabbix Agent...
10月 23 16:09:25 covb systemd[1]: Started Zabbix Agent.
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since 日 2022-10-23 16:09:26 JST; 8s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 3763 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
Process: 27128 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited, status=0/SUCCESS)
Main PID: 3846 (httpd)
Status: "Processing requests..."
CGroup: /system.slice/httpd.service
tq3846 /usr/sbin/httpd -DFOREGROUND
tq3847 /usr/sbin/httpd -DFOREGROUND
tq3848 /usr/sbin/httpd -DFOREGROUND
tq3849 /usr/sbin/httpd -DFOREGROUND
tq3850 /usr/sbin/httpd -DFOREGROUND
mq3851 /usr/sbin/httpd -DFOREGROUND
10月 23 16:09:26 covb systemd[1]: Stopped The Apache HTTP Server.
10月 23 16:09:26 covb systemd[1]: Starting The Apache HTTP Server...
10月 23 16:09:26 covb httpd[3846]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, us...message
10月 23 16:09:26 covb systemd[1]: Started The Apache HTTP Server.
● rh-php72-php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/rh-php72-php-fpm.service; disabled; vendor preset: disabled)
Active: active (running) since 日 2022-10-23 16:09:25 JST; 9s ago
Main PID: 3780 (php-fpm)
Status: "Ready to handle connections"
CGroup: /system.slice/rh-php72-php-fpm.service
tq3780 php-fpm: master process (/etc/opt/rh/rh-php72/php-fpm.conf)
tq3782 php-fpm: pool www
tq3783 php-fpm: pool www
tq3784 php-fpm: pool www
tq3785 php-fpm: pool www
tq3786 php-fpm: pool www
tq3787 php-fpm: pool zabbix
tq3788 php-fpm: pool zabbix
tq3789 php-fpm: pool zabbix
tq3790 php-fpm: pool zabbix
mq3791 php-fpm: pool zabbix
10月 23 16:09:25 covb systemd[1]: Starting The PHP FastCGI Process Manager...
10月 23 16:09:25 covb systemd[1]: Started The PHP FastCGI Process Manager.
Hint: Some lines were ellipsized, use -l to show in full.
[root@covb ban]#
webアクセス
http://localhost/zabbix
にブラウザからアクセス
Discussion