前口上
世の中に落ちてる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は黙って無効化。
sed -i -e 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
cat /etc/selinux/config
shutdown -r now
getenforce
dnf module install php:7.4
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はパスワードを記述。
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
dnf -y install mysql-server
mysql --version
XXXXXXXXはパスワードを記述。何か聞かれたらy
を打ちまくる作業。
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
=======================================
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 -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