はじめに
急遽ZABBIX Proxyが必要になったので、メモを残します。
環境
- OS CentOS Linux 8.1.1911
- zabbix-proxy-4.4.5
- mariaDB 10.3.17
###mariaDBインストール
インストールパッケージの検索とバージョン確認
$ dnf search maria
mariadb-server.x86_64 : The MariaDB server and related files
$ dnf info mariadb-server.x86_64
利用可能なパッケージ
名前 : mariadb-server
エポック : 3
バージョン : 10.3.17
リリース : 1.module_el8.1.0+257+48736ea6
Arch : x86_64
サイズ : 16 M
ソース : mariadb-10.3.17-1.module_el8.1.0+257+48736ea6.src.rpm
リポジトリー : AppStream
確認したら、インストール
$ dnf install mariadb-server.x86_64
Zabbix4.4のリポジトリインストール
Zabbixのリポジトリページから環境に応じたものを探してきます。
$ dnf install http://repo.zabbix.com/zabbix/4.4/rhel/8/x86_64/zabbix-release-4.4-1.el8.noarch.rpm
Zabbix-proxyのインストール
こちらも一応バージョンパッケージの検索とバージョン確認
$ dnf search zabbix-proxy
======================= 名前 一致: zabbix-proxy =======================
zabbix-proxy-mysql.x86_64 : Zabbix proxy for MySQL or MariaDB database
zabbix-proxy-pgsql.x86_64 : Zabbix proxy for PostgreSQL database
zabbix-proxy-sqlite3.x86_64 : Zabbix proxy for SQLite3 database
今回はmariadbなのでmysqlパッケージをインストール
$ dnf install zabbix-proxy-mysql
エラー:
問題: cannot install the best candidate for the job
- nothing provides libssh2.so.1()(64bit) needed by zabbix-proxy-mysql-4.4.5-2.el8.x86_64
(インストール不可のパッケージをスキップするには、'--skip-broken' を追加してみてください または、'--nobest' を追加して、最適候補のパッ
ケージのみを使用しないでください)
CentOS8のBaseリポジトリには**libssh2.so.1()(64bit)**がないらしい・・・
ということで今使っているリポジトリの確認
$ dnf repolist --all
repo id repo の名前 状態
AppStream CentOS-8 - AppStream 有効化: 5,001
AppStream-source CentOS-8 - AppStream Sources 無効化
BaseOS CentOS-8 - Base 有効化: 1,784
BaseOS-source CentOS-8 - BaseOS Sources 無効化
HighAvailability CentOS-8 - HA 無効化
PowerTools CentOS-8 - PowerTools 無効化
base-debuginfo CentOS-8 - Debuginfo 無効化
c8-media-AppStream CentOS-AppStream-8 - Media 無効化
c8-media-BaseOS CentOS-BaseOS-8 - Media 無効化
centosplus CentOS-8 - Plus 無効化
centosplus-source CentOS-8 - Plus Sources 無効化
cr CentOS-8 - cr 無効化
extras CentOS-8 - Extras 有効化: 3
extras-source CentOS-8 - Extras Sources 無効化
fasttrack CentOS-8 - fasttrack 無効化
zabbix Zabbix Official Repository - x86_64 有効化: 118
zabbix-non-supported Zabbix Official Repository non-supported - x8 有効化: 1
PowerToolsやcentosplusなどのリポジトリに存在しないか一応確認
$ dnf search --repo PowerTools libssh2
CentOS-8 - PowerTools
一致する項目はありませんでした。
dnf search --repo centosplus libssh2
CentOS-8 - Plus
一致する項目はありませんでした。
google先生にいろいろ伺ってみると、CentOS 8.0.1905のリポジトリにあるとの情報が
http://sig9.hatenablog.com/entry/2020/01/24/000000
そもそもlibssh2が使えないって事がRHEL8導入における検討事項に入ってるそう
全然読んでませんでした。
ということで、直接叩いてインストール
# dnf install http://mirror.centos.org/centos/8.0.1905/AppStream/x86_64/os/Packages/libssh2-1.8.0-8.module_el8.0.0+189+f9babebb.1.x86_64.rpm
やっとzabbix-proxyをインストール
$ dnf install zabbix-proxy-mysql
.
.
.
完了しました!
mariaDB起動
さくっと起動&自動起動に設定
$ systemctl start mariadb
$ systemctl enable mariadb
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.
###DBの初期設定と作成
初期設定にmysql_secure_installationを実行
$ mysql_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
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set 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.
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.
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.
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.
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!
公式ドキュメントの通り(3.2だけど)データベースの作成
# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 10.3.17-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)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.001 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by '<PASSWORD>';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> quit
Bye
初期スキーマのインポート
zcat /usr/share/doc/zabbix-proxy-mysql/schema.sql.gz | mysql -uzabbix -p zabbix
Zabbix Proxy初期設定
/etc/zabbix/zabbix_proxy.confにconfファイルが存在するので
以下項目の設定値を変更します。
- server 連携するZabbix-ServerのIPを指定
- Hostname 適当な名前で
- DBHost=localhost を追記
- DBName=zabbix に変更する
- DBPassword= を追記
SELinux無効化
どうせ引っかかるので、サクッと無効化しときます。
$ getenforce
Enforcing
$ setenforce permissive
$ getenforce
Permissive
$ vi /etc/selinux/config
#SELINUX=enforcing
SELINUX=disabled
Zabbix Proxy起動
やっと起動
$ systemctl start zabbix-proxy
$ systemctl status zabbix-proxy
● zabbix-proxy.service - Zabbix Proxy
Loaded: loaded (/usr/lib/systemd/system/zabbix-proxy.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2020-01-30 18:32:44 JST; 2s ago
Process: 19274 ExecStart=/usr/sbin/zabbix_proxy -c $CONFFILE (code=exited, status=0/SUCCESS)
Main PID: 19276 (zabbix_proxy)
Tasks: 29 (limit: 12116)
Memory: 31.8M
CGroup: /system.slice/zabbix-proxy.service
├─19276 /usr/sbin/zabbix_proxy -c /etc/zabbix/zabbix_proxy.conf
├─19277 /usr/sbin/zabbix_proxy: configuration syncer [synced config 0 bytes in 0.024490 sec, idle 3600 sec]
├─19278 /usr/sbin/zabbix_proxy: trapper #1 [processed data in 0.000000 sec, waiting for connection]
├─19279 /usr/sbin/zabbix_proxy: trapper #2 [processed data in 0.000000 sec, waiting for connection]
├─19280 /usr/sbin/zabbix_proxy: trapper #3 [processed data in 0.000000 sec, waiting for connection]
├─19281 /usr/sbin/zabbix_proxy: trapper #4 [processed data in 0.000000 sec, waiting for connection]
├─19283 /usr/sbin/zabbix_proxy: trapper #5 [processed data in 0.000000 sec, waiting for connection]
├─19285 /usr/sbin/zabbix_proxy: heartbeat sender [sending heartbeat message failed in 0.029840 sec, idle 60 sec]
├─19287 /usr/sbin/zabbix_proxy: data sender [sent 0 values in 0.023944 sec, idle 1 sec]
├─19289 /usr/sbin/zabbix_proxy: housekeeper [startup idle for 30 minutes]
├─19291 /usr/sbin/zabbix_proxy: http poller #1 [got 0 values in 0.001703 sec, idle 5 sec]
├─19292 /usr/sbin/zabbix_proxy: discoverer #1 [processed 0 rules in 0.013386 sec, idle 60 sec]
├─19295 /usr/sbin/zabbix_proxy: history syncer #1 [processed 0 values in 0.000052 sec, idle 1 sec]
├─19296 /usr/sbin/zabbix_proxy: history syncer #2 [processed 0 values in 0.000067 sec, idle 1 sec]
├─19297 /usr/sbin/zabbix_proxy: history syncer #3 [processed 0 values in 0.000063 sec, idle 1 sec]
├─19299 /usr/sbin/zabbix_proxy: history syncer #4 [processed 0 values in 0.000063 sec, idle 1 sec]
├─19301 /usr/sbin/zabbix_proxy: self-monitoring [processed data in 0.000052 sec, idle 1 sec]
├─19303 /usr/sbin/zabbix_proxy: task manager [processed 0 task(s) in 0.002560 sec, idle 5 sec]
├─19304 /usr/sbin/zabbix_proxy: poller #1 [got 0 values in 0.000134 sec, idle 5 sec]
├─19305 /usr/sbin/zabbix_proxy: poller #2 [got 0 values in 0.000160 sec, idle 5 sec]
├─19307 /usr/sbin/zabbix_proxy: poller #3 [got 0 values in 0.000150 sec, idle 5 sec]
├─19308 /usr/sbin/zabbix_proxy: poller #4 [got 0 values in 0.000143 sec, idle 5 sec]
├─19309 /usr/sbin/zabbix_proxy: poller #5 [got 0 values in 0.000166 sec, idle 5 sec]
├─19311 /usr/sbin/zabbix_proxy: unreachable poller #1 [got 0 values in 0.000134 sec, idle 5 sec]
├─19312 /usr/sbin/zabbix_proxy: icmp pinger #1 [got 0 values in 0.000172 sec, idle 5 sec]
├─19313 /usr/sbin/zabbix_proxy: preprocessing manager #1 started
├─19314 /usr/sbin/zabbix_proxy: preprocessing worker #1 started
├─19315 /usr/sbin/zabbix_proxy: preprocessing worker #2 started
└─19316 /usr/sbin/zabbix_proxy: preprocessing worker #3 started
1月 30 18:32:44 zabbix-proxy.local systemd[1]: Starting Zabbix Proxy...
1月 30 18:32:44 zabbix-proxy.local systemd[1]: zabbix-proxy.service: Supervising process 19276 which is not our child. We'll m> 1月 30 18:32:44 zabbix-proxy.local systemd[1]: Started Zabbix Proxy.
無事起動、お疲れ様でした!