Postgresql, EPAS/HA

EFM

havy 2025. 6. 18. 16:14

EPAS에만 설치 가능, PostgreSQL은 불가......

 

 

 

 

 

Primary -192.168.56.151
Standby - 192.168.56.152
Witness - 192.168.56.153

모든서버에 
systemctl disable firewalld
systemctl stop firewalld

 

 

1. 파라미터 설정 (P, S 둘 다)

vi postgresql.conf

# Add settings for extensions herearchive_mode = onarchive_command = cp %p /var/lib/edb/as17/archive/%fwal_log_hints = onlisten_addresses = '192.168.56.151,192.168.56.152,192.168.56.153'

 

vi pg_hba.conf

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:


host    all             all             127.0.0.1/32            trust
host    all             all             192.168
.56.151/24       trust
host    all             all             192.168.56.152/24       trust
host    all             all             192.168.56.153/24       trust# IPv6 local connections:
host    all             all             0.0.0.0/0                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     trust
host    replication     all             127.0.0.1/32            trust
host    replication     all             ::1/128                 trust#efm
host    replication     all             192.168.56.151/24       trust
host    replication     all             192.168.56.152/24       trust
host    replication     all             192.168.56.153/24       trusthost    replication     repl             192.168.56.151/24       trust
host    replication     repl             192.168.56.152/24       trust
host    replication     repl             192.168.56.153/24       trust

 

 

2. Replication 구성

-- primary server
edb=# create user repl with replication login password '1234';
edb=# select * from pg_create_physical_replication_slot('repl_slot_01');
 
-- standy server
$ pg_basebackup -h 192.168.56.151  -D /var/lib/edb/as17/data/ -U repl -P -v -X stream -S repl_slot_01 -R

 

 

 

 

 

EFM 설치

 

1. Java-11 설치 (P,S,W 서버)

dnf install java-11설치 완료 후alternatives --config java 명령어로 Java 버젼 선택

 

2. EFM 패키지 설치 (P,S,W 서버)

dnf install edb-efm50 (버젼은 알맞게 설정하면 된다..)

 

3.efm.nodes, efm.properties copy (P)

[root@lyj1 efm-5.0]# pwd/etc/edb/efm-5.0[root@lyj1 efm-5.0]# ls -alrt합계 36-rw-r--r--. 1 root root 28998  3월 20 13:55 efm.properties.in-rw-r--r--. 1 root root   139  3월 20 13:55 efm.nodes.indrwxr-xr-x. 3 root root    21  5월 14 21:53 ..drwxr-xr-x. 2 root root    51  5월 14 21:53 .[root@lyj1 efm-5.0]# cp efm.properties.in efm.properties[root@lyj1 efm-5.0]# cp efm.nodes.in efm.nodes

 

4. password encrypt(P)

efm을 설치하면, OS에 efm 유저가 생성된다.

해당 유저의 password를 생성해주는 절차이다. (OS에서 따로 설성하지 않음)

[root@lyj1 bin]# pwd
/usr/edb/efm-5.0/bin
[root@lyj1 bin]# ls -alrt
합계 48
-rwxr-xr-x. 1 root root  1732  3월 20 13:55 runefm.sh
-rwxr-xr-x. 1 root root  2881  3월 20 13:55 runJavaApplication.sh
-rwxr-xr-x. 1 root root  2689  3월 20 13:55 efm_root_functions
-rwxr-xr-x. 1 root root  4669  3월 20 13:55 efm_pgpool_functions
-rwxr-xr-x. 1 root root 18029  3월 20 13:55 efm_db_functions
-rwxr-xr-x. 1 root root  2129  3월 20 13:55 efm_address
-rwxr-xr-x. 1 root root   386  3월 20 13:55 efm
drwxr-x---. 2 root efm     24  5월 14 21:53 secure
drwxr-xr-x. 3 root root   174  5월 14 21:53 .
drwxr-xr-x. 5 root root    41  5월 14 21:53 ..
[root@lyj1 bin]# ./efm encrypt efm
This utility will generate an encrypted password for you to place in your
EFM cluster property file: /etc/edb/efm-5.0/efm.propertiesPlease enter the password and hit enter:Please enter the password again to confirm:The encrypted password is: a676b2b18e211c7c9d1d4aa06d57ca7fPlease paste this into your efm.properties file
        db.password.encrypted=a676b2b18e211c7c9d1d4aa06d57ca7f

 

5. efm.properties, efm.nodes 설정(P)

 

vi efm.properties

db.user=enterprisedb
db.password.encrypted=a676b2b18e211c7c9d1d4aa06d57ca7f
db.port=5444
db.database=edb
db.service.owner=enterprisedb
#db.service.name=edb-as-16.service
db.bin=/usr/edb/as17/bin
db.data.dir=/var/lib/edb/as17/data
user.email=yjl0803@naver.com
bind.address=192.168.56.151:7800
is.witness=false
ping.server.ip=127.0.0.1
auto.allow.hosts=true
stable.nodes.file=true#virtual.ip=192.168.56.160
#virtual.ip.prefix=24
#virtual.ip.interface=enp0s8
#virtual.ip.single=true
ping.server.command=/bin/ping -q -c3 -w5efm.loglevel=TRACE

 

vi efm.nodes

192.168.56.151:7800192.168.56.152:7800192.168.56.153:7800

 

6. 설정 파일들 복사(P)

scp -r efm.properties efm.nodes root@192.168.56.152:/etc/edb/efm-5.0scp -r efm.properties efm.nodes root@192.168.56.153:/etc/edb/efm-5.0

 

7. Standby, Witness 환경에 맞게 설정파일 수정 ( Standby는 bind.address, Witness는 bind.address와 is.witness=true로 바꾸면 됨)

이후 chown -R efm:efm efm-5.0/로 권한 부여

 

8. EFM 기동 ( P → S → W 순으로..)

--Primarysystemctl start edb-efm-5.0
[root@lyj1 bin]# pwd
/usr/edb/efm-5.0/bin
[root@lyj1 bin]# ls -alrt
합계 48
-rwxr-xr-x. 1 root root  1732  3월 20 13:55 runefm.sh
-rwxr-xr-x. 1 root root  2881  3월 20 13:55 runJavaApplication.sh
-rwxr-xr-x. 1 root root  2689  3월 20 13:55 efm_root_functions
-rwxr-xr-x. 1 root root  4669  3월 20 13:55 efm_pgpool_functions
-rwxr-xr-x. 1 root root 18029  3월 20 13:55 efm_db_functions
-rwxr-xr-x. 1 root root  2129  3월 20 13:55 efm_address
-rwxr-xr-x. 1 root root   386  3월 20 13:55 efm
drwxr-x---. 2 root efm     24  5월 14 21:53 secure
drwxr-xr-x. 3 root root   174  5월 14 21:53 .
drwxr-xr-x. 5 root root    41  5월 14 21:53 ..###########클러스터 상태 확인##############[root@lyj1 bin]# ./efm cluster-status efm
Cluster Status: efm        Agent Type  Address              DB       VIP
        ----------------------------------------------------------------
        Primary     192.168.56.151       UPAllowed node host list:
        192.168.56.151 192.168.56.152 192.168.56.153Membership coordinator: 192.168.56.151Standby priority host list:
        (List is empty.)Promote Status:        DB Type     Address              WAL Received LSN   WAL Replayed LSN   Info
        ---------------------------------------------------------------------------
        Primary     192.168.56.151                          0/4027AA0        No standby databases were found.
#########Active 서버에서 Standby, Witness 노드 추가############### efm allow-node efm 192.168.56.152 // Standby 추가 
efm allow-node efm 192.168.56.153 // Witness 추가(allow-node signal sent to local agent. 뜨면 됨)

##############Standby, Witness EFM 기동############

########최종 상태 확인#############[root@lyj1 bin]# ./efm cluster-status efm
Cluster Status: efm        Agent Type  Address              DB       VIP
        ----------------------------------------------------------------
        Primary     192.168.56.151       UP
        Standby     192.168.56.152       UP
        Witness     192.168.56.153       N/AAllowed node host list:
        192.168.56.151 192.168.56.152 192.168.56.153Membership coordinator: 192.168.56.151Standby priority host list:
        192.168.56.152Promote Status:        DB Type     Address              WAL Received LSN   WAL Replayed LSN   Info
        ---------------------------------------------------------------------------
        Primary     192.168.56.151                          0/404AB58
        Standby     192.168.56.152       0/404AB58          0/404AB58        Standby database(s) in sync with primary. It is safe to promote.


'Postgresql, EPAS > HA' 카테고리의 다른 글

Repmgr  (0) 2025.06.18
pgpool-ll  (1) 2025.06.18