1. Rocky8에 zabbix 6.4 서버를 설치한다. (Vagrant로 설치)
2. PostgreSQL 13 설치한다.
Zabbix서버 테스트 및 설치환경
구분 | Vagrant로 설치 | IP |
Zabbix 서버 | cfg.vm.box = "generic/rocky8" https://app.vagrantup.com/generic/boxes/rocky8 |
192.168.56.230 |
vyOS | cfg.vm.box = "vyos/current" https://app.vagrantup.com/vyos/boxes/current |
192.168.56.235 |
- Zabbix서버 Vagrant파일 샘플 (Vagrant 설치방법은 https://hwpform.tistory.com/category/vagrant) 참조
- cfg.vm.box 값(https://app.vagrantup.com/generic/boxes/rocky8) 말고는 본인의 PC 환경에 맞게 수정 하면됨
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.define "rock8Zabbix" do |cfg|
cfg.vm.box = "generic/rocky8"
cfg.vm.provider "virtualbox" do |vb|
vb.name = "rocky8Zabbix"
vb.cpus = 4
vb.memory = 4096
vb.customize ["modifyvm", :id, "--groups", "/default_group"]
end
cfg.vm.host_name = "rocky8Zabbix"
cfg.vm.network "private_network", ip: "192.168.56.230"
cfg.vm.network "forwarded_port", guest: 22, host: 60230, auto_correct: true, id: "ssh"
cfg.vm.synced_folder "../data", "/vagrant", disabled: true
# cfg.vm.provision "shell", path: "config.sh"\
# cfg.vm.provision "shell", path: "install_pkg.sh", args: [ Ver, "Main" ]
# cfg.vm.provision "shell", path: "master_node.sh"\
end
end
# vagrant 설치 로그
C:\Users\shim>vagrant up
Bringing machine 'rock8Zabbix' up with 'virtualbox' provider...
==> rock8Zabbix: Importing base box 'generic/rocky8'...
==> rock8Zabbix: Matching MAC address for NAT networking...
==> rock8Zabbix: Checking if box 'generic/rocky8' version '4.3.12' is up to date...
==> rock8Zabbix: Setting the name of the VM: rocky8Zabbix
==> rock8Zabbix: Clearing any previously set network interfaces...
==> rock8Zabbix: Preparing network interfaces based on configuration...
rock8Zabbix: Adapter 1: nat
rock8Zabbix: Adapter 2: hostonly
==> rock8Zabbix: Forwarding ports...
rock8Zabbix: 22 (guest) => 60230 (host) (adapter 1)
==> rock8Zabbix: Running 'pre-boot' VM customizations...
==> rock8Zabbix: Booting VM...
==> rock8Zabbix: Waiting for machine to boot. This may take a few minutes...
rock8Zabbix: SSH address: 127.0.0.1:60230
rock8Zabbix: SSH username: vagrant
rock8Zabbix: SSH auth method: private key
rock8Zabbix:
rock8Zabbix: Vagrant insecure key detected. Vagrant will automatically replace
rock8Zabbix: this with a newly generated keypair for better security.
rock8Zabbix:
rock8Zabbix: Inserting generated public key within guest...
rock8Zabbix: Removing insecure key from the guest if it's present...
rock8Zabbix: Key inserted! Disconnecting and reconnecting using new SSH key...
==> rock8Zabbix: Machine booted and ready!
==> rock8Zabbix: Checking for guest additions in VM...
rock8Zabbix: The guest additions on this VM do not match the installed version of
rock8Zabbix: VirtualBox! In most cases this is fine, but in rare cases it can
rock8Zabbix: prevent things such as shared folders from working properly. If you see
rock8Zabbix: shared folder errors, please make sure the guest additions within the
rock8Zabbix: virtual machine match the version of VirtualBox you have installed on
rock8Zabbix: your host and reload your VM.
rock8Zabbix:
rock8Zabbix: Guest Additions Version: 6.1.30
rock8Zabbix: VirtualBox Version: 7.0
==> rock8Zabbix: Setting hostname...
==> rock8Zabbix: Configuring and enabling network interfaces...
C:\Users\shim>
- Zabbix 설치 파일 다운로드 사이트 접속 (https://www.zabbix.com)
https://www.zabbix.com/download?utm_campaign=mainpage&utm_source=website&utm_medium=header
- Zabbix 설치하고픈 환경 선택 (Zabbix 6.4, Rocky Linux 8, Server, Agent, PostgreSQL, Apache)를 선택함
- 설치방법 안내 (홈페이지 안내 방법에 의해 설치하면 됨)
- 0. 서버 환경 (설치로그)
# 최초 vagrant / vagrant 로 서버 로그인하여 root 패스워드 변경
$ sudo passwd root
Changing password for user root.
New password:
===========================================================================================
# 원격 접속 가능하게 sshd_config 파일 수정
# pwd
/etc/ssh
# ls
moduli ssh_config ssh_config.d sshd_config ssh_host_ecdsa_key ssh_host_ecdsa_key.pub ssh_host_ed25519_key ssh_host_ed25519_key.pub ssh_host_rsa_key ssh_host_rsa_key.pub
# vi sshd_config
PermitRootLogin yes <-- yes로 변경
PasswordAuthentication yes <-- yes로 변경
============================================================================================
# 시간 맞추기
# sudo timedatectl set-timezone Asia/Seoul
- a. install Zabbix repository
# rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/8/x86_64/zabbix-release-6.4-1.el8.noarch.rpm
Retrieving https://repo.zabbix.com/zabbix/6.4/rhel/8/x86_64/zabbix-release-6.4-1.el8.noarch.rpm
warning: /var/tmp/rpm-tmp.2MCKgC: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:zabbix-release-6.4-1.el8 ################################# [100%]
# 레포지토리 설치 확인
# pwd
/etc/yum.repos.d
# ls
epel-modular.repo epel-testing-modular.repo Rocky-AppStream.repo Rocky-Debuginfo.repo Rocky-Extras.repo Rocky-Media.repo Rocky-Plus.repo Rocky-ResilientStorage.repo Rocky-Sources.repo
epel.repo epel-testing.repo Rocky-BaseOS.repo Rocky-Devel.repo Rocky-HighAvailability.repo Rocky-NFV.repo Rocky-PowerTools.repo Rocky-RT.repo zabbix.repo
# dnf clean all
0 files removed
- b. Switch DNF module version for PHP
# dnf module switch-to php:7.4
Rocky Linux 8 - AppStream 4.9 MB/s | 11 MB 00:02
Rocky Linux 8 - BaseOS 2.8 MB/s | 7.1 MB 00:02
Rocky Linux 8 - Extras 8.0 kB/s | 14 kB 00:01
Extra Packages for Enterprise Linux 8 - x86_64 5.3 MB/s | 16 MB 00:03
Zabbix Official Repository - x86_64 122 kB/s | 208 kB 00:01
Zabbix Official Repository non-supported - x86_64 1.1 kB/s | 1.4 kB 00:01
Dependencies resolved.
=======================================================================================================================================================================================================================================
Package Architecture Version Repository Size
=======================================================================================================================================================================================================================================
Enabling module streams:
httpd 2.4
nginx 1.14
php 7.4
Transaction Summary
=======================================================================================================================================================================================================================================
Is this ok [y/N]: y
Complete!
- c. Install Zabbix server, frontend, agent
# dnf install zabbix-server-pgsql zabbix-web-pgsql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent
=======================================================================================================================================================================================================================================
Package Architecture Version Repository Size
=======================================================================================================================================================================================================================================
Installing:
zabbix-agent x86_64 6.4.13-release1.el8 zabbix 592 k
zabbix-apache-conf noarch 6.4.13-release1.el8 zabbix 27 k
zabbix-selinux-policy x86_64 6.4.13-release1.el8 zabbix 320 k
zabbix-server-pgsql x86_64 6.4.13-release1.el8 zabbix 1.9 M
zabbix-sql-scripts noarch 6.4.13-release1.el8 zabbix 7.9 M
zabbix-web-pgsql noarch 6.4.13-release1.el8 zabbix 26 k
..
..
Transaction Summary
=======================================================================================================================================================================================================================================
Install 51 Packages
Complete!
- d. Create initial database
- 먼저 서버에 postgresql을 설치해야 됨
- 레포지토리 버전 확인 및 기존 버전 비활성화
# dnf module list postgresql
Rocky Linux 8 - AppStream 5.6 kB/s | 4.8 kB 00:00
Rocky Linux 8 - BaseOS 5.3 kB/s | 4.3 kB 00:00
Rocky Linux 8 - Extras 3.7 kB/s | 3.1 kB 00:00
Extra Packages for Enterprise Linux 8 - x86_64 4.8 kB/s | 8.2 kB 00:01
Zabbix Official Repository - x86_64 4.8 kB/s | 2.9 kB 00:00
Zabbix Official Repository non-supported - x86_64 4.9 kB/s | 2.9 kB 00:00
Rocky Linux 8 - AppStream
Name Stream Profiles Summary
postgresql 9.6 client, server [d] PostgreSQL server and client module
postgresql 10 [d] client, server [d] PostgreSQL server and client module
postgresql 12 client, server [d] PostgreSQL server and client module
postgresql 13 client, server [d] PostgreSQL server and client module
postgresql 15 client, server [d] PostgreSQL server and client module
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
# dnf -qy module disable postgresql
# dnf module list postgresql
Last metadata expiration check: 0:02:24 ago on Sun 31 Mar 2024 07:33:39 AM KST.
Rocky Linux 8 - AppStream
Name Stream Profiles Summary
postgresql 9.6 [x] client, server [d] PostgreSQL server and client module
postgresql 10 [d][x] client, server [d] PostgreSQL server and client module
postgresql 12 [x] client, server [d] PostgreSQL server and client module
postgresql 13 [x] client, server [d] PostgreSQL server and client module
postgresql 15 [x] client, server [d] PostgreSQL server and client module
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
- PostgreSQL 13 리포지토리 설치
# dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
=======================================================================================================================================================================================================================================
Package Architecture Version Repository Size
=======================================================================================================================================================================================================================================
Installing:
pgdg-redhat-repo noarch 42.0-40PGDG @commandline 14 k
Transaction Summary
=======================================================================================================================================================================================================================================
Install 1 Package
..
Complete!
- PostgreSQL 13 설치
# dnf install -y postgresql13-server
=======================================================================================================================================================================================================================================
Package Architecture Version Repository Size
=======================================================================================================================================================================================================================================
Installing:
postgresql13-server x86_64 13.14-1PGDG.rhel8 pgdg13 5.5 M
Installing dependencies:
libicu x86_64 60.3-2.el8_1 baseos 8.8 M
postgresql13 x86_64 13.14-1PGDG.rhel8 pgdg13 1.5 M
postgresql13-libs x86_64 13.14-1PGDG.rhel8 pgdg13 419 k
Transaction Summary
=======================================================================================================================================================================================================================================
Install 4 Packages
Total download size: 16 M
Installed size: 62 M
Downloading Packages:
(1/4): libicu-60.3-2.el8_1.x86_64.rpm 6.7 MB/s | 8.8 MB 00:01
(2/4): postgresql13-libs-13.14-1PGDG.rhel8.x86_64.rpm 169 kB/s | 419 kB 00:02
(3/4): postgresql13-13.14-1PGDG.rhel8.x86_64.rpm 458 kB/s | 1.5 MB 00:03
(4/4): postgresql13-server-13.14-1PGDG.rhel8.x86_64.rpm 1.2 MB/s | 5.5 MB 00:04
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 2.4 MB/s | 16 MB 00:06
PostgreSQL 13 for RHEL / Rocky / AlmaLinux 8 - x86_64 2.4 MB/s | 2.4 kB 00:00
Complete!
- PostgreSQL 13 설치 확인
# cat passwd
postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash
# su - postgres
$ pwd
/var/lib/pgsql
$ pwd
/usr/pgsql-13/bin
# postgresql-13-setup initdb
Initializing database ... OK
# cat /var/lib/pgsql/13/initdb.log
runuser: may not be used by non-root users
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /var/lib/pgsql/13/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Asia/Seoul
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
Success. You can now start the database server using:
/usr/pgsql-13/bin/pg_ctl -D /var/lib/pgsql/13/data/ -l logfile start
- PostgreSQL 13 서비스 상태 확인 (Active : Failed)
# systemctl status postgresql-13.service
● postgresql-13.service - PostgreSQL 13 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-13.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sun 2024-03-31 07:58:51 KST; 3min 59s ago
Docs: https://www.postgresql.org/docs/13/static/
Process: 27856 ExecStartPre=/usr/pgsql-13/bin/postgresql-13-check-db-dir ${PGDATA} (code=exited, status=1/FAILURE)
Mar 31 07:58:51 rocky8Zabbix systemd[1]: Starting PostgreSQL 13 database server...
Mar 31 07:58:51 rocky8Zabbix postgresql-13-check-db-dir[27856]: "/var/lib/pgsql/13/data/" is missing or empty.
Mar 31 07:58:51 rocky8Zabbix postgresql-13-check-db-dir[27856]: Use "/usr/pgsql-13/bin/postgresql-13-setup initdb" to initialize the database cluster.
Mar 31 07:58:51 rocky8Zabbix postgresql-13-check-db-dir[27856]: See /usr/share/doc/postgresql13/README.rpm-dist for more information.
Mar 31 07:58:51 rocky8Zabbix systemd[1]: postgresql-13.service: Control process exited, code=exited status=1
Mar 31 07:58:51 rocky8Zabbix systemd[1]: postgresql-13.service: Failed with result 'exit-code'.
Mar 31 07:58:51 rocky8Zabbix systemd[1]: Failed to start PostgreSQL 13 database server.
- PostgreSQL 13 서비스 재기동 (Active : running)
# systemctl disable postgresql-13.service
Removed /etc/systemd/system/multi-user.target.wants/postgresql-13.service.
# systemctl stop postgresql-13.service
# systemctl enable postgresql-13.service
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-13.service → /usr/lib/systemd/system/postgresql-13.service.
# systemctl start postgresql-13.service
# systemctl status postgresql-13.service
● postgresql-13.service - PostgreSQL 13 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-13.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2024-03-31 08:03:17 KST; 4s ago
Docs: https://www.postgresql.org/docs/13/static/
Process: 28095 ExecStartPre=/usr/pgsql-13/bin/postgresql-13-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 28101 (postmaster)
Tasks: 8 (limit: 23144)
Memory: 16.9M
CGroup: /system.slice/postgresql-13.service
├─28101 /usr/pgsql-13/bin/postmaster -D /var/lib/pgsql/13/data/
├─28102 postgres: logger
├─28104 postgres: checkpointer
├─28105 postgres: background writer
├─28106 postgres: walwriter
├─28107 postgres: autovacuum launcher
├─28108 postgres: stats collector
└─28109 postgres: logical replication launcher
Mar 31 08:03:17 rocky8Zabbix systemd[1]: Starting PostgreSQL 13 database server...
Mar 31 08:03:17 rocky8Zabbix postmaster[28101]: 2024-03-31 08:03:17.692 KST [28101] LOG: redirecting log output to logging collector process
Mar 31 08:03:17 rocky8Zabbix postmaster[28101]: 2024-03-31 08:03:17.692 KST [28101] HINT: Future log output will appear in directory "log".
Mar 31 08:03:17 rocky8Zabbix systemd[1]: Started PostgreSQL 13 database server.
- PostgreSQL 13 LISTEN 상태확인
# netstat -ntpa |grep LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1165/sshd
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 28101/postmaster
tcp6 0 0 :::22 :::* LISTEN 1165/sshd
- PostgreSQL 13 계정 및 데이터베이스 생성 ※ zabbix 홈페이지에 나와 있는 zabbix 계정생성 및 db 생성
# sudo -u postgres createuser --pwprompt zabbix
# sudo -u postgres createdb -O zabbix zabbix
또는 postgres 로 로그인 하여
$ cd /usr/pgsql-13/bin/
$ psql
postgres=# create user zabbix password 'zabbix' superuser;
postgres=# create database zabbix owner zabbix;
혹시 몰라서 postgres 패스워드를 zabbix으로 변경
postgres=# alter user postgres with password 'zabbix';
- 계정생성 확인 ( zabbix 계정 superuser로 생성)
$ cd /usr/pgsql-13/bin/
$ psql
psql (13.14)
Type "help" for help.
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
zabbix | | {}
postgres=# ALTER USER zabbix superuser;
ALTER ROLE
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
zabbix | Superuser | {}
- 데이터베이스 생성 확인
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
zabbix | zabbix | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
(4 rows)
postgres=# \dn
List of schemas
Name | Owner
--------+----------
public | postgres
(1 row)
- Zabbix 서버에서 초기 스키마와 데이터를 가져옴
# zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix
- e. Configure the database for Zabbix server
- Edit file /etc/zabbix/zabbix_server.conf
DBPassword=password
- f. Start Zabbix server and agent processes
# systemctl restart zabbix-server zabbix-agent httpd php-fpm
# systemctl enable zabbix-server zabbix-agent httpd php-fpm
- g. Open Zabbix UI web page
- http://192.168.56.230/zabbix/
- 접속이 안되는 경우 방화벽 문제로 일단 disable 시킨다
# systemctl stop firewalld.service
# systemctl disable firewalld.service
- 데이터베이스를 연결할수 없습니다. 라고 나옴
- 접속 파라미터를 수정
# /var/lib/pgsql/13/data/postgresql.conf
listen_addresses = 'localhost' 를 listen_addresses = '*' 로 변경
#/var/lib/pgsql/13/data/pg_hba.conf
host all all 0.0.0.0/0 scram-sha-256 / 줄 추가
host all all 0.0.0.0/0 trust / superuser 패스워드 없이 로그인시 줄 추가
(간혹 superuser 패스워드를 모를경우 trust mode로 설정하고
HeidiSQL 툴로 패스워드 없이 접속하여 superuser 초기 패스워드 변경)
# systemctl restart postgresql-13 / 시스템 환경 변경시 restart는 필수
- 데이터베이스 스키마 확인 (스키마 명 \dn명령어로 확인 public 으로 확인됨)
# su - postgres
Last login: Sun Mar 31 09:05:46 KST 2024 on pts/0
$ psql
psql (13.14)
Type "help" for help.
postgres=# \dn
List of schemas
Name | Owner
--------+----------
public | postgres
(1 row)
- 재접속 확인
- Zabbix로그인 : Username : Admin / Password : zabbix (Admin A는 대문자 주의)
- 로그인 된 화면
Zabbix 한글 설정 (Language 설정)
- 메뉴을 한글로 보고싶을 때 설정하는 방법
# localectl list-locales
# dnf install glibc-langpack-ko -y
# localectl set-locale LANG=ko_KR.utf8
# localectl
System Locale: LANG=ko_KR.utf8
VC Keymap: us
X11 Layout: us
최종 설치 정보
# netstat -ntpa |grep LISTEN
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 839/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 1170/zabbix_server
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 822/sshd
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 1097/postmaster
tcp6 0 0 :::10050 :::* LISTEN 839/zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 1170/zabbix_server
tcp6 0 0 :::80 :::* LISTEN 820/httpd
tcp6 0 0 :::22 :::* LISTEN 822/sshd
tcp6 0 0 :::5432 :::* LISTEN 1097/postmaster
# systemctl list-unit-files
UNIT FILE STATE
firewalld.service disabled
zabbix-agent.service enabled
zabbix-server.service enabled
postgresql-13.service enabled
# zabbix 설치위치
# pwd
/etc/zabbix
# Postgresql-13 실행파일 위치
$ pwd
/usr/pgsql-13/bin
# Postgresql-13 환경파일 위치
$ pwd
/var/lib/pgsql/13/data
'Manage OpenSource > ZABBIX' 카테고리의 다른 글
[Zabbix] Vyos 설치 및 Zabbix 연동 (1) | 2024.03.31 |
---|