LoginSignup
2
1

【AWS EC2】Zabbix6.0インストール(AlmaLinux9.3, MySQL8.0.36, PHP-fpm8.1)

Last updated at Posted at 2024-03-19

前口上

 AlmaLinux9系かつPHP8.1で、Zabbix6.0の記事がなさげだったので作成。
 コンセプト的には、黙ってコマンドを打ちまくれば構築完成する手順にした。

1 環境

・AWS EC2
・Alma Linux/9.3
・Zabbix/6.0.27
・MySQL/8.0.36
・PHP-fpm/8.1.27
・Apache/2.4.57

2 構築

基礎情報確認
uname -a ; id -un
cat /etc/redhat-release
アップデート
dnf update -y
ホスト名変更
hostnamectl set-hostname XXXXXXXX

※ XXXXXXXX は好きなホスト名を記述。
タイムゾーン設定
timedatectl set-timezone Asia/Tokyo
timedatectl
ロケール設定
locale
localectl set-locale LANG=ja_JP.utf8
localectl set-keymap jp106
locale
localectl
PHP8.1導入
dnf module list php
dnf -y module enable php:8.1
dnf module list php
dnf upgrade -y
Zabbix6.0インストール
rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-6.0-4.el9.noarch.rpm
dnf clean all

dnf -y install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-web-japanese

※以下は任意
dnf -y install zabbix-agent2 zabbix-get
dnf -y install glibc-locale-source glibc-langpack-ja zabbix-web-japanese
ZBX conf 修正
cat /etc/zabbix/zabbix_server.conf | grep DBPassword
cp -ip /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.`date +%Y%m%d`01
sed -i -e 's/# DBPassword=/DBPassword=XXXXXXXX/g' /etc/zabbix/zabbix_server.conf
cat /etc/zabbix/zabbix_server.conf | grep DBPassword
diff /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.`date +%Y%m%d`01

※ XXXXXXXX はパスワードを記述。
MySQLインストール
dnf -y install mysql-server
mysql --version

cat /etc/my.cnf.d/mysql-server.cnf
echo character_set_server=utf8mb4 >> /etc/my.cnf.d/mysql-server.cnf
echo collation_server=utf8mb4_bin >> /etc/my.cnf.d/mysql-server.cnf
echo skip-character-set-client-handshake >> /etc/my.cnf.d/mysql-server.cnf
echo innodb_file_per_table >> /etc/my.cnf.d/mysql-server.cnf
echo performance_schema=0 >> /etc/my.cnf.d/mysql-server.cnf
echo log_timestamps=SYSTEM >> /etc/my.cnf.d/mysql-server.cnf
cat /etc/my.cnf.d/mysql-server.cnf
MySQL installation
systemctl -l status mysqld.service
systemctl enable --now mysqld
systemctl -l status mysqld.service

mysql_secure_installation
=======================================
Would you like to setup VALIDATE PASSWORD component?:n

New password: XXXXXXXX
Re-enter new password: XXXXXXXX

Do you wish to continue with the password provided?:y
Remove anonymous users?:y
Disallow root login remotely?:y
Remove test database and access to it?:y
Reload privilege tables now?:y

※ XXXXXXXX はパスワードを記述。
=======================================

systemctl restart mysqld.service
systemctl -l status mysqld.service
MySQL DB 設定
mysql -uroot -p

create database zabbix character set utf8mb4 collate utf8mb4_bin;
create user zabbix@localhost identified by 'XXXXXXXX';
grant all privileges on zabbix.* to zabbix@localhost;
show databases;
set global log_bin_trust_function_creators = 1;
quit; 
※ XXXXXXXX はパスワードを記述。

■SQL導入
zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix

■設定修正
mysql -uroot -p
set global log_bin_trust_function_creators = 0;
quit; 
サービス起動
systemctl -l status zabbix-server php-fpm httpd | grep -E "(●|Active:)"
systemctl -l status zabbix-agent2 | grep -E "(●|Active:)"

systemctl enable --now zabbix-server php-fpm httpd
systemctl enable --now zabbix-agent2

systemctl -l status zabbix-server php-fpm httpd | grep -E "(●|Active:)"
systemctl -l status zabbix-agent2 | grep -E "(●|Active:)"
Chrome導入
※レポート機能を使う場合
■パッケージを以下よりインストール
https://www.google.com/chrome/?platform=linux

■/tmpフォルダ等に配置してインストール
dnf install -y /tmp/google-chrome-stable_current_x86_64.rpm

cat /etc/zabbix/zabbix_server.conf | grep StartReportWriters
sed -i -e 's/# StartReportWriters=0/StartReportWriters=3/g' /etc/zabbix/zabbix_server.conf

cat /etc/zabbix/zabbix_server.conf | grep StartReportWriters
diff /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.`date +%Y%m%d`01
SELinux設定
dnf -y install zabbix-selinux-policy

semanage boolean -l | grep zabbix
setsebool -P httpd_can_connect_zabbix on
setsebool -P zabbix_can_network on
semanage boolean -l | grep zabbix

3 GUI接続

 構築されたEC2のアドレスに接続。画面に従って操作すれば完成。
 xxx.xxx.xxx.xxx/zabbix

 DBパスワードを入力し、ホスト名も入力して、タイムゾーンをAsia/Tokyoにするだけ。

参考

・TNKさん/Zabbix 6.0をAlmaLinux 8にインストール(MySQL編)
 https://qiita.com/atanaka7/items/f0d5c510487a779a0aa6

・hoshinoさん/Zabbix 6.4インストール手順(RHEL9 / Apache2.4 / PHP-FPM8.0 / MySQL8.0)
 https://densan-hoshigumi.com/server/zabbix64-rhel9-apache-mysql-install

・murachiさん/Zabbix6.4 を AlmaLinux 9 にインストール(MySQL) サーバ/エージェント
 https://qiita.com/murachi1208/items/3c0dab0f90b3ba992b06

2
1
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
2
1