20210617 PostgreSQL

JM·2021년 6월 21일
0

Trouble shooting

목록 보기
1/5

1. 구성

  • PostgreSQL 9.6 2EA, repmgr 이중화 구성 (Active / Standby)

2. 문의 사항

  • WAL 파일 증가 원인 분석 및 해결 요청

3. 원인 분석

  • 4/27 Failover 발생 (해당 일 작업 내역, OS 로그 확인 불가로 원인 파악 불가능)
  • Active DB Down
  • PostgreSQL 에러 로그는 특이 사항 없음
  • pg_xlog 디렉토리의 WAL 사이즈 약 200GB (archive_status 디렉토리의 파일 상태는 모두 .done)

    📌 If WAL archiving cannot keep up with the pace that WAL is generated, or if archive_command fails repeatedly, old WAL files will accumulate in pg_xlog until the situation is resolved.

>> Failover 이후 archive_command 명령어 수행 과정에서 문제 발생하여 WAL 사이즈 증가 추측

4. 해결 방안

  • pg_archivecleanup 유틸리티로 WAL 정리
  • repmgr standby clone 명령어로 기존 Active DB를 Standby DB로 복구
  • 서비스 정상 확인

5. 특이사항

  • WAL 개수는 max_wal_size 값에 의해 유지(rotate)
    ex) max_wal_size = 1GB (defalut) 일 경우 WAL 개수는 64개 (16MB * 64 = 1GB)
  • But max_wal_size 값이 4GB로 WAL 개수는 256개로 유지되는 것으로 예상하였으나 그 이상 증가...
  • WAL 개수는 max_wal_size 뿐만 아니라 wal_keep_segments 영향을 받음

    📌 Independently of max_wal_size, wal_keep_segments + 1 most recent WAL files are kept at all times.

profile
오픈소스 DB엔지니어

0개의 댓글