LoginSignup
1
1

More than 1 year has passed since last update.

【AWS EC2】【RHEL8.6】Zabbix6.0構築(MySQL/Apache)

Last updated at Posted at 2022-06-16

前口上

 世の中に落ちてるZabbix6.0の記事がなんか微妙に使いにくいので作成。
 コンセプト的には、黙ってコマンドを打ちまくれば構築完成する手順にした。

1 環境

・AWS EC2
・RHEL/8.6
・MySQL/8.0.26
・Apache/2.4.37

2 構築

基礎情報確認
uname -a ; id -un
cat /etc/redhat-release
cat /etc/os-release

 XXXXXXXXは好きなホスト名を記述。

ホスト名変更
hostnamectl set-hostname XXXXXXXX
もしくはnmtui
タイムゾーン設定
timedatectl
timedatectl set-timezone Asia/Tokyo
timedatectl

 SELinuxは黙って無効化。

SELinux無効化
getenforce
cat /etc/selinux/config
sed -i -e 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
cat /etc/selinux/config
shutdown -r now
getenforce
アップデート
dnf update -y
Zabbix6.0インストール
rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm
dnf clean all
dnf -y install zabbix-server-mysql zabbix-web-mysql zabbix-web-japanese zabbix-apache-conf zabbix-sql-scripts
dnf -y install zabbix-agent2

 DBPasswordだけ編集する。XXXXXXXXはパスワードを記述。

zabbix_server.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
MySQLインストール
dnf -y install mysql-devel
dnf -y install mysql-server
mysql --version
mysql-server.cnf
cat /etc/my.cnf.d/mysql-server.cnf

echo innodb_file_per_table >> /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 performance_schema=0 >> /etc/my.cnf.d/mysql-server.cnf
echo log_timestamps=SYSTEM >> /etc/my.cnf.d/mysql-server.cnf
echo log_bin_trust_function_creators=1 >> /etc/my.cnf.d/mysql-server.cnf

cat /etc/my.cnf.d/mysql-server.cnf

systemctl -l status mysqld.service
systemctl enable --now mysqld
systemctl -l status mysqld.service

 XXXXXXXXはパスワードを記述。何か聞かれたらyを打ちまくる作業。

MySQL installation
mysql_secure_installation
=======================================
Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: y

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
New password: XXXXXXXX
Re-enter new password: XXXXXXXX

Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
=======================================

systemctl restart mysqld.service
systemctl -l status mysqld.service

 XXXXXXXXはパスワードを記述。

MySQL DB設定
mysql -uroot -pXXXXXXXX

=======================================
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;
quit;
=======================================

zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
サービス起動
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:)"

3 GUI接続・最終設定

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

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

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