일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
- 아카이브로그 삭제
- sql문 짤릴 때
- 다른계정에서 dblink 삭제방법
- sql문 전체 출력 방법
- PostgreSQL 스키마 관리
- PostgreSQL Backup and Recovery
- oracle error
- pg_basebackup
- 19c tde
- ogg 구성
- PostgreSQL Install
- Linux
- Goldengate
- ogg 설치 방법
- ogg-01028
- oracle
- PostgreSQL 테이블스페이스 생성 삭제
- table lock 조치 방법
- pg_dumpall
- dblink 삭제
- PostgreSQL 아키텍처
- psql 복구
- db upgrade
- OGG
- PostgreSQL 테이블스페이스 관리
- pgcrypto
- PostgreSQL Parameter
- multitenant
- PostgreSQL Admin
- PostgreSQL Parameter 설정 방법
- Today
- Total
인성장
[PostgreSQL] 수동 Fail-over, Fail-back 방법 본문
본 문서는 Streaming Replication 방식으로 PostgreSQL 이중화 구성(설치)된 환경에서 수동으로 Fail-over ,Fail-back 하는 방법에 대한 문서입니다.
PostgreSQL HA 구성 방법
https://checktech.tistory.com/2
Linux 7.9 에 PostgreSQL 15 이중화(HA) 설치 가이드
본 문서는 Streaming Replication 방식으로 PostgreSQL 이중화 구성(설치)에 대한 내용입니다. 설치 환경 1. OS : CentOS Linux Release 7.9 2009 2. DB : PostgreSQL 15.3 3. IP & Hostname Primary Server IP & Hostname Standby Server IP & Ho
checktech.tistory.com
설치 환경
1. OS : CentOS Linux Release 7.9 2009
2. DB : PostgreSQL 15.3
3. IP & Hostname
Primary Server IP & Hostname | Standby Server IP & Hostname |
192.168.0.148 ispg1 | 192.168.0.158 ispg2 |
PostgreSQL HA Failover 방법
※ Primary 는 1번 노드에서 수행, Standby 는 2번 노드에서 수행, 둘 다 있으면 두 노드에서 작업 수행하시면 됩니다.
장애상황 테스트를 위해 Primary 서버 강제 종료 Primary
[root@ispg1 ~]# shutdown -h now
Standby DB postgresql.conf 파일 수정 Standby
Archive 관련 파라미터 주석 해제
[postgres@ispg2 data]$ vi postgresql.conf
...(생략)...
archive_mode = on -- 주석(#) 해제
archive_command = 'cp %p /postgres/app/postgres/pgsql15/pg_arch/%f' -- 주석(#) 해제
archive_timeout = 120 -- 주석(#) 해제
...(생략)...
Standby -> Primary 전환 Standby
[postgres@ispg2 data]$ /postgres/app/postgres/pgsql15/bin/pg_ctl promote
waiting for server to promote.... done
server promoted
Standby -> Primary 전환 후 Data Insert 테스트 Standby
장애난 기존 Primary 서버 기동 후 HA 재구성 Primary
standby.signal 생성, postgresql.auto.conf 내용 추가
postgresql.auto.conf 는 기존 Standby DB의 postgresql.auto.conf 의 primary_conninfo 내용 중 host 상대 IP로 수정하여 작성하면 됩니다.
[postgres@ispg1 ~]$ cd $PGDATA
[postgres@ispg1 ~]$ touch standby.signal
[postgres@ispg1 ~]$ chmod 600 standby.signal
[postgres@ispg1 ~]$ vi postgresql.auto.conf
# Do not edit this file manually!
# It will be overwritten by the ALTER SYSTEM command.
primary_conninfo = 'user=hauser passfile=''/home/postgres/.pgpass'' channel_binding=disable host=192.168.0.158 port=5001 sslmode=disable sslcompression=0 sslsni=1 ssl_min_protocol_version=TLSv1.2 gssencmode=disable krbsrvname=postgres target_session_attrs=any'
기존 Primary 서버 기동 Primary
[postgres@ispg1 ~]$ pg_ctl -D /postgres/app/postgres/pgsql15/data/ start
이렇게 되면 Failover가 완료되어 기존 Standby가 Primary로 바뀌어 Read Write 이 가능하게 되고, 기존 Primary가 Standby로 변경되어 Read Only로만 동작하게 됩니다.
여기서 이전처럼 1번 서버가 Primary로 동작하게끔 하려면 아래 내용대로 Failback 진행하면 됩니다.
PostgreSQL HA Failback 방법
현재 Primary DB 서버 종료
Standby
[postgres@ispg2 data]$ pg_ctl -D /postgres/app/postgres/pgsql15/data/ stop
[선택사항] postgresql.conf파일 수정 Standby
Standby 쪽에 Archive WAL File 관리가 힘들면 주석처리 해주세요.
[postgres@ispg2 data]$ vi postgresql.conf
...(생략)...
#archive_mode = on
#archive_command = 'cp %p /postgres/app/postgres/pgsql15/pg_arch/%f'
#archive_timeout = 120
...(생략)...
Standby -> Primary 전환 Primary
[postgres@ispg1 ~]$ pg_ctl -D /postgres/app/postgres/pgsql15/data/ promote
Standby 서버 data 디렉토리 아래 standby.signal 파일 생성, postgresql.auto.conf 내용 수정 Standby
[postgres@ispg2 ~]$ cd $PGDATA
[postgres@ispg2 ~]$ touch standby.signal
[postgres@ispg2 ~]$ chmod 600 standby.signal
[postgres@ispg2 ~]$ vi postgresql.auto.conf
# Do not edit this file manually!
# It will be overwritten by the ALTER SYSTEM command.
primary_conninfo = 'user=hauser passfile=''/home/postgres/.pgpass'' channel_binding=disable host=192.168.0.148 port=5001 sslmode=disable sslcompression=0 sslsni=1 ssl_min_protocol_version=TLSv1.2 gssencmode=disable krbsrvname=postgres target_session_attrs=any'
DB 기동 Standby
[postgres@ispg2 data]$ pg_ctl -D /postgres/app/postgres/pgsql15/data/ start
데이터 동기화 테스트 Primary Standby
Failback 완료
'PostgreSQL > Admin' 카테고리의 다른 글
[PostgreSQL] Parameter 설정 방법 (0) | 2024.02.02 |
---|---|
[PostgreSQL] 데이터베이스 관리(생성, 삭제, 조회, 변경 등) (0) | 2023.12.12 |
[PostgreSQL] pg_hba.conf (1) | 2023.11.30 |
[PostgreSQL] 원격 접속 허용 방법 (외부 접근 제어, 접속 인증 설정) (0) | 2023.11.30 |
[PostgreSQL] 기동 정지 방법 (2) | 2023.11.30 |