centos
rpm -qf
rpm -qa
디렉토리 구조 나옴.
일단 이정도.
ubuntu
dpkg -L <packagename>
centos
rpm -qf
rpm -qa
디렉토리 구조 나옴.
일단 이정도.
ubuntu
dpkg -L <packagename>
서버두개 Master Slave인 경우
대략적인 설정을 하고 확인한 것은. pg의 레플리케이션은 파일을 Master서버에서 파일을 퍼와서 Slave서버에 바로 배치입력시키는 과정을 자동화해놓은 정도의 수준인 것처럼 보인다.
Master
ip : 192.168.0.101
username : testuser
password : testpass1234
권한 : replication
아이디 비밀번호가 같을 필요는 없지만 편의상 같ㄱ ㅔ한다
Slave
ip : 192.168.0.102
username : testuser
password : testpass1234
Master서버 설정
데이터 경로
자동설치의 경우 /etc/init.d/postgresql-0.3 스크립트에서 수정해야된다
# Set defaults for configuration variables PGENGINE=/usr/pgsql-9.3/bin PGPORT=5432 #PGDATA=/var/lib/pgsql/9.3/data PGDATA=/home/postgres/data #PGLOG=/var/lib/pgsql/9.3/pgstartup.log PGLOG=/home/postgres/data/pg_log/pgstartup.log # Log file for pg_upgrade #PGUPLOG=/var/lib/pgsql/data/$PGMAJORVERSION/pgupgrade.log PGUPLOG=/home/postgres/data/$PGMAJORVERSION/pgupgrade.log
pg_hba.conf
local trust, 외부접속설정. replication설정을 주의
# "local" is for Unix domain socket connections only ###trust로하자 편하게 local all all trust # IPv4 local connections: host all all 127.0.0.1/32 ident ## 아무데서나 접속하게해준다는 뜻. 하나하나 설정해주는게 보안에 좋다. 내 경우는 방화벽도 있고 암호도 있으니까 그냥 ip는 풀어놨다 host all all 0.0.0.0/0 md5 # IPv6 local connections: host all all ::1/128 ident # Allow replication connections from localhost, by a user with the # replication privilege. #local replication postgres peer #host replication postgres 127.0.0.1/32 ident #host replication postgres ::1/128 ident ## 리플레케이션 유저를 설정. trust 또는 md5로 보통 쓴다 host replication testuser 192.168.0.102/0 trust
postgresql.conf
listen_addresses = '*' port = 5432 wal_level = hot_standby archive_mode = on archive_command = 'cp %p /home/postgres/data/pg_archive/%f' max_wal_senders = 3 wal_keep_segments = 8
pg인증방식
pg_hba.conf
host all all 127.0.0.1/32 trust
host all all 127.0.0.1/32 md5
local all postgres peer
local all postgres md5
Slave서버
# pg_basebackup -h 192.168.0.101 -p 5432 -U testuser -D /home/postgres/data --xlog --checkpoint=fast --progress # chown postgres:postgres /home/postgres -R # mkdir /home/postgres/data/pg_archive
pg_hba.conf
노예는 이것만 설정한다. 사용만 하면되니까… 마스터에서 접근은 안한다.
host all all 0.0.0.0/0 md5
postgresql.conf
listen_addresses = '*' port = 5432 wal_level = hot_standby archive_mode = on archive_command = 'cp %p /home/postgres/data/pg_archive/%f' max_wal_senders = 2 wal_keep_segments = 8
recoverty.conf
다른쪽들은 복제할 때 다 됐을테니 따로 안해도 된다… 이것만 새로 생성
restore_command = 'cp /home/postgres/data/pg_archive/%f %p' archive_cleanup_command = 'pg_archivecleanup /home/postgres/data/pg_archive %r' recovery_target_timeline = 'latest' standby_mode = on primary_conninfo = 'host=192.168.0.101 port=5432 user=testuser password=testpass1234' #trigger_file = '/tmp/pgsql.trigger'
주의할점
로그확인을 잘 하자.
참고한 페이지
http://mixellaneous.tistory.com/1007
https://www.digitalocean.com/community/articles/how-to-set-up-master-slave-replication-on-postgresql-on-an-ubuntu-12-04-vps
http://wiki.postgresql.org/wiki/Binary_Replication_Tutorial
http://histlinux.egloos.com/1227710
http://mixellaneous.tistory.com/1007
http://dba.stackexchange.com/questions/16781/postgresql-9-1-hot-backup-error-the-database-system-is-starting-up