CentOS6 Postgresql 9.3 replication[현재안됨]

서버두개 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

 

아는사람만아는 GIS정부관련 코드 구하기_행정동,법정동,신주소코드

몇년쯤전부터 정부에서 사용하는 모든 구역명에 코드가 붙었다.
법정동,행정동,무슨무슨로2가 뭐 이런식으로 붙는 도로명주소에도 코드가 붙고.

각각 코드마다 관리하는 주체가 다른건 알겠는데 받는곳도 다르다.

법정동코드 – 안전행정부(안행부) – http://www.code.go.kr

행정동코드,법정동코드 – 안전행정부(안행부) – http://www.mospa.go.kr/ -> 업무안내 -> 주민등록 및 인감 -> 주민등록주소코드 변경내역(2014.1.2, 현재)

jscode20140102말소코드포함

jscode20140102

이렇게 선택하면 다운로드가 가능하다. 못 찾으면 인터넷 게시판에 올리는것보다 전화문의하는게 빠르다. 현재시점에서는 이 경로로 다운로드가능하고. 박근혜정부 임기까지는 유효하지않을까 싶다.

우편번호 – 우체국 – http://www.epost.go.kr/, http://www.code.go.kr

기타데이터…

통계청 www.kostat.go.kr

서울시정보공개 http://opengov.seoul.go.kr/, http://data.seoul.go.kr

홈페이지 주소체계가 너무 자주 바뀌고 관리주체도 다양해서 사용하기가 힘들다.

공식적으로 문제제기를 한번 해 봐야겠다. 어디 여론을 형성해서 단체로 민원을 넣던가

—아아 . 지금은 2018년
http://www.mois.go.kr/frt/bbs/type001/commonSelectBoardArticle.do?bbsId=BBSMSTR_000000000052&nttId=61552
18년