반응형
/********************************************************************************************
-- Title : [PGS9.2] WAL 아카이브 모드 설정 및 해제 - ver.dBRang
-- Reference : http://www.postgresql.org/docs/9.2/static/runtime-config-wal.html
-- Key word : archive noarchive 아카이브 모드 노아카이브 모드 continuous archiving
********************************************************************************************/
-- 1. 노아카이브 모드 확인
psql=# select * from pg_settings
where name in ('archive_mode', 'archive_command', 'archive_timeout', 'wal_level');
psql=# show wal_level;
psql=# show archive_mode;
psql=# show archive_command;
ㅇ /$POSTGRES_HOME/data/postgresql.conf 파일에서
wal_level, archive_mode, archive_command, archive_timeout을 아래 그림과 같이 세팅.
필요시(standby?) max_wal_sender도 세팅
ㅇ wal_level은 로그를 어느정도 기록할 것인가로써,
- minimal : 기본값으로 복구에 필요한 최소의 로그만 기록.
create table/create index/cluster/copy같은 벌크 작업은 로그 작성 생략.
- archive : 복구에 필요한 모든 WAL 아카이빙에 필요한 정보를 로깅.
- hot_standby : archive와 동일한 로깅을 하고, 더불어 Standby 구성을 위한 정보도 기록함.
상기와 같은 값을 가짐.
ㅇ archove_mode = on
- 아카이브 설정시 on, 노아카이브 설정시 off나 걍~ 주석(#)처리.
- wal_level = minimal시 설정되지 않음.
ㅇ archive_command =
'test ! -f /home/postgres/pgsql/ARCHIVE/%f && cp %p /home/postgres/pgsql/ARCHIVE/%f'
또는 'cp %p /home/database/ARCHIVE/%f'
- 아카이브 파일을 저장할 경로 설정, 노아카이브 설정시 역시 걍~ 주석(#) 처리.
- %p : wal 파일의 전체 경로를 대체
- %f : wal 파일명을 대체
ㅇ archive_timeout = {integer}
- wal 세그먼트 전환시 사용되는 시간(분)
- 보통 1분이 합리적이라 함.
-- 3. 아카이브 디렉토리 생성
# su - postgres
$ mkdir /home/postgres/pgsql/ARCHIVE
ㅇ 필요시 권한 부여(# chown -R postgres.postgres /home/postgres/pgsql/ARCHIVE)
--4. 서버 restart
$ pg_ctl restart
-- 5. 아카이브 모드 확인
psql=# select * from pg_settings
where name in ('archive_mode', 'archive_command', 'archive_timeout', 'wal_level');
psql=# show wal_level;
psql=# show archive_mode;
psql=# show archive_command;
-- 6. 노아카이브 모드 전환
ㅇ $POSTGRES_HOME/data/postgresql.conf에서
wal_levle = minimal로 처리하고
archive_mode = on, archive_command ={...}와 archive_timeout = {m} 를 주석(#)처리.
ㅇ /home/postgres/pgsql/ARCHIVE/* 삭제 가능
-- 참조
ㅇ 로그 스위치 : dbrang.tistory.com/754
반응형