1.서버별 edb 및 efm48 설치
2.각 서버별 방화벽 OPEN===============================
sudo firewall-cmd --add-port=5444/tcp --permanent
sudo firewall-cmd --add-port=7800/tcp --permanent
sudo firewall-cmd --reload
3.JAVA 설치
yum -y install java
java install
sudo dnf install tzdata-java
yum list java*jdk-devel
yum install java-1.8.0-openjdk-devel.x86_64
echo $JAVA_HOME
which javac
readlink -f /usr/bin/javac /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64/bin/javac
4.1 MASTER NODE SETTING INIT DB 생성
PGSETUP_INITDB_OPTIONS="-E UTF-8 --lc-collate='C' --lc-ctype='C'" /usr/edb/as16/bin/edb-as-16-setup initdb
참고 <initdb -D /pg_data -E'UTF8' --locale=en_US.utf8 --waldir=/pg_wal
WAL LOG 위치를 변경 할 경우 waldir=/pg_wal 이 옵션 추가 한다.
4.2 MASTER NODE SETTING [/var/lib/edb/as16/data/pg_hba.conf]
방화벽 수정
내용 :
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 ident
host all all 192.168.52.0/24 md5
# IPv6 local connections:
host all all ::1/128 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 ident
host replication all ::1/128 ident
host replication all 192.168.52.0/24 md5
==============================================================================
192.168.52 <== DB 서비스 IP 각 설정에 맞게 수정
4.3 MASTER NODE SETTING [/var/lib/edb/as16/data/postgresql.conf]
listen_addresses = '*'
max_connections = 100
shared_buffers = 128MB
work_mem = 4MB
dynamic_shared_memory_type = posix
wal_level = replica
max_wal_size = 1GB
min_wal_size = 80MB
max_wal_senders = 4
hot_standby = on
wal_level = replica
archive_mode = on
archive_command = 'cp %p $PGDATA/archive/%f.arc'
archive_timeout = 1min
autovacuum = on
autovacuum_max_workers = 3
autovacuum_naptime = 1min
autovacuum_vacuum_threshold = 50
autovacuum_vacuum_insert_threshold = 1000
#optimizer_mode = choose # Oracle-style optimizer hints.
wal_log_hints = on
==============================================================================
참고 : stand by node 설치 ============위 master node setting 과정 반복 해서 설치 후
edb engine boot 확인후
rm -rf /var/lib/edb/as16/data 삭제한다.
==============================================================================
4.5 rm -rf /var/lib/edb/as16/data
4.6 streaming replication 준비
master node enterprisedb 계정으로 login
<복제 계정 생성>
ALTER USER enterprisedb IDENTIFIED BY 'edb';
CREATE USER repl WITH REPLICATION ENCRYPTED PASSWORD 'repl';
GRANT pg_read_all_settings TO enterprisedb;
<복제 슬롯을 만들어줌>
psql -c "select * from pg_create_physical_replication_slot('pgstandby1'); "
psql -c "select * from pg_create_physical_replication_slot('pgstandby2'); "
<서버 스트림 복제 생성 > stand by server 2대를 만들경우 아래 command 수행
node1 번
/usr/edb/as16/bin/pg_basebackup -h 192.168.52.166 -U repl -p 5444 -D /var/lib/edb/as16/data -P -v -R -X stream -S pgstandby1
node2
/usr/edb/as16/bin/pg_basebackup -h 192.168.52.166 -U repl -p 5444 -D /var/lib/edb/as16/data -P -v -R -X stream -S pgstandby3
4.7 active-stand by ha 구조로 서버를 생성 할경우 [witness server 구성이 필요없음 ]
stand by conf 를 hot_standby = off 로 세팅
4.8 witness, active,stand by 2대 구성 할 경우 master 에서 복제 스트림 구성 후
4.9 efm 설정
============efm 설정 관련 보안세팅 ==========================================
<보안 설정 >
[enterprisedb@localhost bin]$ efm encrypt efm
This utility will generate an encrypted password for you to place in your
EFM cluster property file: /etc/edb/efm-4.8/acctg.properties
Please enter the password and hit enter:
Please enter the password again to confirm:
The encrypted password is: 2279cfdb0a2cc47334c389ac83dea66a
Please paste this into your acctg.properties file
db.password.encrypted=2279cfdb0a2cc47334c389ac83dea66a
The /etc/edb/efm-4.8/acctg.properties file does not exist.
Make sure you are using the correct cluster name.
[enterprisedb@localhost bin]$
======================================================
위에 서 생성된 암호화 키값은 efm.propert 의 db.password.encrypted 값으로 세팅
4.8.1 witness 구성
서버별로 efm4.8 install 후
cd /etc/edb/efm-4.8 efm.properties , efm.nodes 설정 파일수정
ex ] efm.nodes 내용
192.168.52.169:7800 192.168.52.165:7800 192.168.52.168:7800
efm.propert 내용
================================================
db.user=enterprisedb
db.password.encrypted=559b4e4033a5a4de96f64733075cc278
db.port=5444
db.database=edb
db.service.owner=enterprisedb
db.bin=/usr/edb/as16/bin
db.data.dir=/var/lib/edb/as16/data
user.email=bumkyu@enterprisedb.com
frohttp://m.email=bumkyu@enterprisedb.com
script.notificationi=bumkyu@enterprisedb.com
bind.address=192.168.52.166:7800 <== 서버 자신 ip
is.witness=false
virtual.ip=192.168.52.180 <== service ip
virtual.ip.interface=ens160
virtual.ip.prefix=24
virtual.ip.single=true
efm.loglevel=TRACE
===============================
is.witness=false false 값이 세팅이 되면 해당 서버가 master server 가된다.
[stand by server 도 false 로
단 witness 서버를 구성할 경우 witness 서버만 true 로 설정]
파일 실행권한 세팅
===================================================
cp efhttp://m.properties.in efm.properties
cp efhttp://m.nodes.in efm.nodes
chown efm:efm efm.properties
chown efm:efm efm.properties
=======================================================
=========하나만 하고 나머지 서버들은 copy 해서 설정진행
scp efm.properties efm.nodes root@192.168.52.166:/etc/edb/efm-4.8/
scp efm.properties efm.nodes root@192.168.52.168:/etc/edb/efm-4.8/
scp efm.properties efm.nodes root@192.168.52.165:/etc/edb/efm-4.8/
===efm start/stop
systemctl start edb-efm-4.8
systemctl stop edb-efm-4.8
<cluster 상테조회>
efm cluster-status efm
<노드 추가할 경우 인증 절차>
efm allow-node efm 192.168.52.168
<cluster log 확인 >
tail -f /var/log/efm-4.8/startup-efm.log
tail -f /var/log/efm-4.8/efm.log
===========================
witness 서버세팅
witness 서버는 edb 설치가 필요없다.
단
efm 설치후
efm.nodes,efm.properties 값 수정한다.
단 efm.properties 의 is.witness=true 로 세팅