본문 바로가기

리눅스

Rocky Linux 9에서 Zabbix 6.0 구축

기본설정: 

1. selinux disable

2. IP / Hostname / ssh config / epel,remi repo 세팅

3. dnf update

 

환경소개

[root@wszbxapp01:/root]# cat /etc/redhat-release
Rocky Linux release 9.2 (Blue Onyx)
[root@wszbxapp01:/root]# ip -br a
lo               UNKNOWN        127.0.0.1/8 ::1/128
eth0             UP             192.168.137.101/24 fe80::7f3c:8441:beff:a7c0/64

1. MariaDB 10.5 설치

[root@wszbxapp01:/root]# dnf install -y mariadb-server mariadb
========================================================================================================================================================================
 꾸러미                                          구조                             버전                                        저장소                               크기
========================================================================================================================================================================
설치 중:
 mariadb                                         x86_64                           3:10.5.16-2.el9_0                           appstream                           1.6 M
 mariadb-server                                  x86_64                           3:10.5.16-2.el9_0                           appstream                           9.4 M
취약한 종속 꾸러미 설치 중:
 mariadb-backup                                  x86_64                           3:10.5.16-2.el9_0                           appstream                           6.4 M
 mariadb-gssapi-server                           x86_64                           3:10.5.16-2.el9_0                           appstream                            19 k
 mariadb-server-utils                            x86_64                           3:10.5.16-2.el9_0                           appstream                           213 k
완료되었습니다!

[root@wszbxapp01:/root]# systemctl enable --now mariadb.service
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

[root@wszbxapp01:/root]# mariadb-secure-installation

Enter current password for root (enter for none):
OK, successfully used password, moving on...

You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n] n
 ... skipping.

Change the root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!
Remove anonymous users? [Y/n] y
 ... Success!
Disallow root login remotely? [Y/n] y
 ... Success!
Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
Reload privilege tables now? [Y/n] y
 ... Success!
 
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!

[root@wszbxapp01:/root]# mysql -V
mysql  Ver 15.1 Distrib 10.5.16-MariaDB, for Linux (x86_64) using  EditLine wrapper

 

2. 자빅스 설치

[root@wszbxapp01:/root]# rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-6.0-4.el9.noarch.rpm
https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-6.0-4.el9.noarch.rpm(을)를 복구합니다
경고: /var/tmp/rpm-tmp.QLpcaW: Header V4 RSA/SHA512 Signature, key ID 08efa7dd: NOKEY
Verifying...                          ################################# [100%]
준비 중...                         ################################# [100%]
Updating / installing...
   1:zabbix-release-6.0-4.el9         ################################# [100%]

[root@wszbxapp01:/root]# dnf makecache    (새로 설치된 yum 리포지토리에 대한 yum 캐시를 빌드)
Rocky Linux 9 - BaseOS                                                                                                                  3.0 kB/s | 4.1 kB     00:01
Rocky Linux 9 - AppStream                                                                                                               4.9 kB/s | 4.5 kB     00:00
Rocky Linux 9 - CRB                                                                                                                     7.0 kB/s | 4.5 kB     00:00
Rocky Linux 9 - Extras                                                                                                                  4.8 kB/s | 2.9 kB     00:00
Zabbix Official Repository - x86_64                                                                                                     5.3 kB/s | 2.9 kB     00:00
Zabbix Official Repository (non-supported) - x86_64                                                                                     5.2 kB/s | 2.9 kB     00:00
Zabbix Official Repository (Agent2 Plugins) - x86_64                                                                                    5.2 kB/s | 2.9 kB     00:00
메타 자료 캐쉬가 생성되었습니다.

[root@wszbxapp01:/root]# dnf install -y zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent
완료되었습니다!

2-1. Mariadb 구성하기 (Zabbix 백엔드 데이터 저장소 DB)

[root@wszbxapp01:/root]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 10.5.16-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.000 sec)

MariaDB [(none)]> create user zabbix@localhost identified by '비번';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> quit;
Bye

[root@wszbxapp01:/root]# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
Enter password: 상기 비번 입력

2-2. Zabbix Conf 설정

[root@wszbxapp01:/etc]# vi /etc/zabbix_server.conf                         (이상하게 나는 /etc/밑에있음)
DBPassword=비번입력
:wq

[root@wszbxapp01:/etc]# systemctl enable --now zabbix-server zabbix-agent httpd php-fpm
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-server.service → /usr/lib/systemd/system/zabbix-server.service.
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-agent.service → /usr/lib/systemd/system/zabbix-agent.service.
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.

2-3. HTTP 방화벽 설정

[root@wszbxapp01:/etc]# firewall-cmd --permanent --add-service=http
success
[root@wszbxapp01:/etc]# firewall-cmd --reload
success
[root@wszbxapp01:/etc]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth0
  sources:
  services: cockpit dhcpv6-client http
  
 [root@wszbxapp01:/etc]# systemctl restart mariadb zabbix-server zabbix-agent httpd php-fpm

3. 브라우저로 들어가서 Zabbix 설정하면 완료!

* http://192.168.137.101/zabbix/setup.php

 

■포트 개방

자빅스 호스트서버: 10050/tcp, 10051/tcp

자빅스 에이전트서버: 10050/tcp

 

출처:https://www.centlinux.com/2022/10/install-zabbix-monitoring-tool-on-rocky-linux.html