본문 바로가기

RDBMS/PostgreSQL

Replication

Replication ( streming Replication )


1. Master ( Primary ) 서버 구성

$ psql –U postgres -p 5432

postgres=# CREATE ROLE replication REPLICATION LOGIN PASSWORD 'password';                                                                # 동기화 계정 생성

$ vi /raid/usr/local/pgsql/data/data/postgresql.conf

# Replication 관련 parameter 수정

---------------------------------------------------------------------------------------------

#------------------------------------------------------------------------------

# WRITE AHEAD LOG

#------------------------------------------------------------------------------

# - Settings -

wal_level = hot_standby                    # 마스터가 슬레이브의 접속을 받아들이는 설정

# - Archiving –

archive_mode = on                                                 # Data Archiving 설정

archive_command = 'cp %p /raid/usr/local/pgsql/data/data/pg_archive/%f'

# Data Archiving 명령어 선언

#------------------------------------------------------------------------------

# REPLICATION

#------------------------------------------------------------------------------

# - Sending Server(s) –

max_wal_senders = 5                                   # 최대 walsender process 의 개수

wal_keep_segments = 32  # Replication 전용으로 남겨둘 wal 파일의 개수. 0 설정시 disables

# - Standby Servers –

hot_standby = on                                      # 복구 진행중 쿼리 사용가능 여부

---------------------------------------------------------------------------------------------


$ vi /raid/usr/local/pgsql/data/data/pg_hba.conf

# 동기화 계정 통신 설정

---------------------------------------------------------------------------------------------

host    replication     replication     192.168.44.0/24         md5

# IP 입력부분 최상단에 추가

---------------------------------------------------------------------------------------------


2. 동기화 작업

2.1 pg_basebackup

$ pg_basebackup -D /raid/usr/local/pgsql/data/data/ -v -Fp -h 192.168.44.151 -p 54000 -U replication

# pg_basebackup 을 이용하여 Master 데이터 디렉토리 백업 후 복사

# 통신 오류 확인 시 pg_hba.conf 파일 확인      


  


'RDBMS > PostgreSQL' 카테고리의 다른 글

설치  (0) 2017.03.23