2016. 3. 8. 14:58 DB
BDR drop 관련
http://database.sarang.net/?inc=read&criteria=pgsql&subcrit=qna&aid=9645
현재 Test용으로 Master(Active) - Master(Active) 로 구성하여 replication 시험을 하고 있습니다.
시험하고 나서 시험용 DataBase를 지우려고 하면 다음과 같은 에러가 나옵니다.
postgres=# drop database park;
ERROR: database "park" is used by a logical replication slot
DETAIL: There is 1 slot, 1 of them active.
그래서 해당 slot을 지우려고 다음과 같이 하였습니다.
ostgres=# select * from pg_replication_slots;
slot_name | plugin | slot_type | datoid | database | active | xmin | catalog_xmin | restart_lsn
-----------------------------------------+--------+-----------+--------+----------+--------+------+--------------+-------------
bdr_25753_6257997305196062070_1_40293__ | bdr | logical | 25753 | park | t | | 2112 | 0/2F69390
(1 row)
postgres=# select pg_drop_replication_slot('bdr_25753_6257997305196062070_1_40293__');
ERROR: replication slot "bdr_25753_6257997305196062070_1_40293__" is already active
위와 같이 나왔습니다. bidr에서 replication 관련 slot이 떠 있어서 그런것으로 예상되는데
이 replication을 disable(inactive, stop) 상태로 만들고 위의 'park' 이라는 database를 삭제하고 싶습니다.
저도 slot은 구성을 안해봐서 잘은 모르지만..
위의 error 시에
wal_sender_timeout을 낮추고
2. postgres.conf reload 후에
3.pg_drop_replication_slot('');
으로 하는 방법이 있는 것으로 알고 있습니다.
postgres=# select pg_drop_replication_slot('bdr_25753_6257997305196062070_1_40293__');
pg_drop_replication_slot
--------------------------
(1 row)
근데 한가지만 더 문의드려도 될까요?
위와 같이 "pg_replication_slots" 여기서는 삭제가 되었습니다.
그런후에 database를 삭제하려고 다음과 같이 수행하였더니 아래와 같은 메세지가 나옵니다.
postgres=# drop database park;
ERROR: database "park" is being accessed by other users
DETAIL: There is 1 other session using the database.
현재 위와 같이 database를 지우려고 할때 안되어서 다른쪽 장비의 db를 shutdown 해 놓고도 해 보았습니다.
몇일 동안 맨땅에 헤딩중입니다. 혹시 아시면 알려주세요. Tip이라도 감사합니다.
정말 감사합니다. DB restart는 되지 않았고 알려주신 두번째 방법으로 했더니 drop이 되네요.
select * from pg_stat_activity where datname='park';
select pg_terminate_backend('pid')
옆에 계신분이라면 저녁이라도 사드리고 싶네요.
처음 postgresql을 접하다 보니 많이 모르는 부분이 많네요
'DB' 카테고리의 다른 글
Postgresql 모니터링 (0) | 2019.10.27 |
---|---|
postgresql 이중화 관련 (0) | 2015.07.25 |
postgresql 이중화 관련 (0) | 2015.05.22 |
Postgresql Replication(이중화) (0) | 2015.03.03 |
postgresql 백업 및 복구 (1) | 2015.02.01 |