0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【AWS EC2】【CentOS8 Stream】Zabbix6.0インストール(MySQL/Apache)

Last updated at Posted at 2022-11-18

前口上

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

1 環境

・AWS EC2
・CentOS 8 Stream
・MySQL/8.0.26
・PHP/7.4.30
・Apache/2.4.37

2 構築

基礎情報確認
uname -a ; id -un
cat /etc/redhat-release
cat /etc/os-release
アップデート
dnf update -y

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

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

 SELinuxは黙って無効化。

SELinux無効化
sed -i -e 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
cat /etc/selinux/config
shutdown -r now
getenforce
PHP7.4使うで
dnf module install php:7.4
Zabbix6.0インストール
rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm
dnf install -y zabbix-server-mysql zabbix-web-service zabbix-sql-scripts zabbix-agent2 zabbix-web-mysql zabbix-apache-conf zabbix-web-japanese

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

zabbix_server.conf
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-server
mysql --version

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

MySQL installation
systemctl start mysqld
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
=======================================
mysql-server.cnf
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 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 restart mysqld.service
systemctl enable 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 with mysql_native_password 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-agent2 zabbix-server php-fpm httpd | grep -E "(●|Active:)"

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

systemctl -l status zabbix-agent2 zabbix-server php-fpm httpd | grep -E "(●|Active:)"

3 GUI接続・最終設定

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

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

参考

https://qiita.com/atanaka7/items/a27105e00eedbfed66cc
https://www.zabbix.com/download?zabbix=6.0&os_distribution=centos&os_version=8&components=server_frontend_agent&db=mysql&ws=apache

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?