本記事の目的
備忘録
環境
- Rocky Linux 9.6
- Zabbix 7.0 LTS
- Server
- Agent2
- Frontend
- MariaDB 11.8 (LTS: 2028-06-04 Community Support Limit)
- Nginx 1.20
on VirtualBox
Rocky Linux をインストール
とりあえずやる
最小限インストールを選択した
ssh
今回は、NAT にしている。ポートフォワーディングで ssh は 127.0.1.1:22 -> VM IP:22 になるようにした
(本筋とは関係ないがメモしておくコマンド)
# IPv6 Disable sudo nmcli c mod enp0s3 ipv6.method disable # bash-completion (タブ補完) sudo dnf update sudo dnf install bash-completion # グローバルに設定を反映させる cat << 'EOL' | sudo tee /etc/profile.d/bash_completion.sh > /dev/null # Enable bash-completion for all users if [ -f /etc/bash_completion ]; then . /etc/bash_completion fi EOL sudo chmod +x /etc/profile.d/bash_completion.sh # 即時反映 source /etc/profile.d/bash_completion.sh
sudo dnf install vim
Zabbix install の参考資料
SELinux を permissive へ
sestatus # 元ファイルのバックアップ sudo cp -ivp /etc/selinux/config{,.$(date -I)} # 編集 sudo sed -i 's/^SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config # 確認 sestatus # reboot sudo reboot
EPEL をインストール
参考
sudo dnf config-manager --set-enabled crb
sudo dnf install epel-release
NGINX をインストール
sudo dnf install nginx
MariaDB をインストール
OS で最初から選択できる MariaDB を選ぶ場合
sudo dnf install mariadb-{server,client}
11.8 の場合
cat << 'EOL' | sudo tee /etc/yum.repos.d/MariaDB.repo > /dev/null # MariaDB 11.8 RedHatEnterpriseLinux repository list - created 2025-09-11 11:10 UTC # https://mariadb.org/download/ [mariadb] name = MariaDB # rpm.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details. # baseurl = https://rpm.mariadb.org/11.8/rhel/$releasever/$basearch baseurl = https://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/yum/11.8/rhel/$releasever/$basearch # gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB gpgkey = https://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck = 1 EOL sudo dnf install MariaDB-server MariaDB-client
Zabbix をインストールしていく
EPEL は入れているが、 exclude する必要があるので入れる
[ope@sample ~]$ cat /etc/yum.repos.d/epel.repo [epel] name=Extra Packages for Enterprise Linux $releasever - $basearch # It is much more secure to use the metalink, but if you wish to use a local mirror # place its address here. #baseurl=https://download.example/pub/epel/$releasever/Everything/$basearch/ metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch&infra=$infra&content=$contentdir enabled=1 gpgcheck=1 countme=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever [epel-debuginfo]
こうなっているので、[epel]
セクションのどこかに excludepkgs=zabbix*
を入れる
[ope@sample ~]$ cat -n /etc/yum.repos.d/epel.repo 1 [epel] 2 name=Extra Packages for Enterprise Linux $releasever - $basearch 3 # It is much more secure to use the metalink, but if you wish to use a local mirror 4 # place its address here. 5 #baseurl=https://download.example/pub/epel/$releasever/Everything/$basearch/ 6 metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch&infra=$infra&content=$contentdir 7 enabled=1 8 gpgcheck=1 9 countme=1 10 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever 11 12 [epel-debuginfo] # 11行目に追記する sudo sed '10a excludepkgs=zabbix*' /etc/yum.repos.d/epel.repo -i
Zabbix リポジトリをインストール
sudo rpm -Uvh https://repo.zabbix.com/zabbix/7.0/rocky/9/x86_64/zabbix-release-latest-7.0.el9.noarch.rpm sudo dnf clean all
Zabbix の必要パッケージインストール
sudo dnf install zabbix-server-mysql \ zabbix-web-mysql \ zabbix-nginx-conf \ zabbix-sql-scripts \ zabbix-selinux-policy \ zabbix-agent
初期データベースを作る
# 起動しているか確認 sudo systemctl status mariadb # 起動していなければスタート sudo systemctl start mariadb # 次いでに自動起動していなければ設定 sudo systemctl enable mariadb # root でログイン sudo mysql -uroot -p myroot_password create database zabbix character set utf8mb4 collate utf8mb4_bin; create user zabbix@localhost identified by 'zb_password'; grant all privileges on zabbix.* to zabbix@localhost; set global log_bin_trust_function_creators = 1; quit;
最初のスキーマを設定する
この時一緒に Admin のパスワードを決める
sudo zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
log
[ope@sample ~]$ sudo zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead Enter password: # <-- ここは、データベースの zabbix ユーザーのパスワード [ope@sample ~]$
log_bin_trust_function_creators
を disable に
sudo mysql -uroot -p set global log_bin_trust_function_creators = 0; quit;
データベースのパスワードを config ファイルに設定する
cd /etc/zabbix/ sudo cp -ivp zabbix_server.conf{,.$(date -I)} sudo sed '/DBPassword=/a DBPassword=zb_password' zabbix_server.conf -i
Zabbix フロントエンドの設定
/etc/nginx/conf.d/zabbix.conf
の編集
cd /etc/nginx/conf.d/ # 以下のコメントアウト部分を任意に編集 [ope@sample conf.d]$ cat zabbix.conf server { # listen 8080; # server_name example.com; ## サンプル [ope@sample conf.d]$ head zabbix.conf server { listen 0.0.0.0:8080; server_name god-eye.com; # config test sudo nginx -t
Zabbix スタート
sudo systemctl status zabbix-server zabbix-agent nginx php-fpm sudo systemctl restart zabbix-server zabbix-agent nginx php-fpm sudo systemctl status zabbix-server zabbix-agent nginx php-fpm sudo systemctl enable zabbix-server zabbix-agent nginx php-fpm
firewalld で穴あけ
sudo firewall-cmd --add-port=8080/tcp --permanent sudo firewall-cmd --add-port=10050/tcp --permanent sudo firewall-cmd --add-port=10051/tcp --permanent sudo firewall-cmd --reload
UI を開く
127.0.0.1:80
を VM 内の 0.0.0.0:8080
とマッピング(ポートフォワーディング)
http://127.0.0.1
を開く
Next
Next
MariaDB は MySQL 互換なのでそのまま
Port は 0
がデフォルトなのでそのまま
zabbix@localhost
のパスワードをパスワード欄に入れる
Zabbix server name watcher
にする
Default time zonee JST
にする
Default theme そのまま
こんな感じ
next
サマリ
next
おめでとう
Finish
初期ユーザー情報
Admin
/ zabbix