
- Engin YILMAZ
- 12 Mart 2020
- 0 Yorum
- VERİ TABANI
Hi,
Firstly, we are checking database status below commands.
-bash-4.2$ /usr/pgsql-12/bin/repmgr -f /etc/repmgr/12/repmgr.conf cluster show
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+----------+---------+---------------+----------+----------+----------+----------+-----------------------------------------------------------
1 | PG-Node1 | primary | - failed | | default | 100 | ? | host=10.0.0.4 user=repmgr dbname=repmgr connect_timeout=2
2 | PG-Node2 | standby | * running | | default | 100 | 2 | host=10.0.0.5 user=repmgr dbname=repmgr connect_timeout=2
We are executing below commands for switch database.
-bash-4.2$ /usr/pgsql-12/bin/repmgr standby promote -f /etc/repmgr/12/repmgr.conf --log-to-file
[2020-03-12 10:54:21] [WARNING] 1 sibling nodes found, but option "--siblings-follow" not specified
[2020-03-12 10:54:21] [DETAIL] these nodes will remain attached to the current primary:
PG-Node3 (node ID: 3)
[2020-03-12 10:54:21] [NOTICE] promoting standby to primary
[2020-03-12 10:54:21] [DETAIL] promoting server "PG-Node2" (ID: 2) using pg_promote()
[2020-03-12 10:54:21] [NOTICE] waiting up to 60 seconds (parameter "promote_check_timeout") for promotion to complete
[2020-03-12 10:54:23] [NOTICE] STANDBY PROMOTE successful
[2020-03-12 10:54:23] [DETAIL] server "PG-Node2" (ID: 2) was successfully promoted to primary
We are checking cluster status, you can show, PG-Node2 machine is primary.
-bash-4.2$ /usr/pgsql-12/bin/repmgr -f /etc/repmgr/12/repmgr.conf cluster show
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+----------+---------+---------------+----------+----------+----------+----------+-----------------------------------------------------------
1 | PG-Node1 | primary | - failed | | default | 100 | ? | host=10.0.0.4 user=repmgr dbname=repmgr connect_timeout=2
2 | PG-Node2 | primary | * running | | default | 100 | 2 | host=10.0.0.5 user=repmgr dbname=repmgr connect_timeout=2
We are rejoining old primary machine as standby.
-bash-4.2$ /usr/pgsql-12/bin/repmgr -f /etc/repmgr/12/repmgr.conf node rejoin -d "postgres://repmgr@10.0.0.5:5432/repmgr"
INFO: local node 1 can attach to rejoin target node 2
DETAIL: local node's recovery point: 0/26000028; rejoin target node's fork point: 0/260000A0
NOTICE: setting node 1's upstream to node 2
WARNING: unable to ping "host=10.0.0.4 user=repmgr dbname=repmgr connect_timeout=2"
DETAIL: PQping() returned "PQPING_NO_RESPONSE"
NOTICE: starting server using "/usr/pgsql-12/bin/pg_ctl -w -D '/var/lib/pgsql/12/data' start"
INFO: waiting for node "PG-Node1" (ID: 1) to connect to new primary; 1 of max 60 attempts
DETAIL: checking for record in node "PG-Node2"'s "pg_stat_replication" table where "application_name" is "PG-Node1"
INFO: waiting for node "PG-Node1" (ID: 1) to connect to new primary; 6 of max 60 attempts
DETAIL: checking for record in node "PG-Node2"'s "pg_stat_replication" table where "application_name" is "PG-Node1"
INFO: waiting for node "PG-Node1" (ID: 1) to connect to new primary; 11 of max 60 attempts
DETAIL: checking for record in node "PG-Node2"'s "pg_stat_replication" table where "application_name" is "PG-Node1"
INFO: waiting for node "PG-Node1" (ID: 1) to connect to new primary; 16 of max 60 attempts
DETAIL: checking for record in node "PG-Node2"'s "pg_stat_replication" table where "application_name" is "PG-Node1"
INFO: waiting for node "PG-Node1" (ID: 1) to connect to new primary; 21 of max 60 attempts
DETAIL: checking for record in node "PG-Node2"'s "pg_stat_replication" table where "application_name" is "PG-Node1"
INFO: waiting for node "PG-Node1" (ID: 1) to connect to new primary; 26 of max 60 attempts
DETAIL: checking for record in node "PG-Node2"'s "pg_stat_replication" table where "application_name" is "PG-Node1"
INFO: waiting for node "PG-Node1" (ID: 1) to connect to new primary; 31 of max 60 attempts
DETAIL: checking for record in node "PG-Node2"'s "pg_stat_replication" table where "application_name" is "PG-Node1"
INFO: waiting for node "PG-Node1" (ID: 1) to connect to new primary; 36 of max 60 attempts
DETAIL: checking for record in node "PG-Node2"'s "pg_stat_replication" table where "application_name" is "PG-Node1"
INFO: waiting for node "PG-Node1" (ID: 1) to connect to new primary; 41 of max 60 attempts
DETAIL: checking for record in node "PG-Node2"'s "pg_stat_replication" table where "application_name" is "PG-Node1"
INFO: waiting for node "PG-Node1" (ID: 1) to connect to new primary; 46 of max 60 attempts
DETAIL: checking for record in node "PG-Node2"'s "pg_stat_replication" table where "application_name" is "PG-Node1"
INFO: waiting for node "PG-Node1" (ID: 1) to connect to new primary; 51 of max 60 attempts
DETAIL: checking for record in node "PG-Node2"'s "pg_stat_replication" table where "application_name" is "PG-Node1"
INFO: waiting for node "PG-Node1" (ID: 1) to connect to new primary; 56 of max 60 attempts
DETAIL: checking for record in node "PG-Node2"'s "pg_stat_replication" table where "application_name" is "PG-Node1"
NOTICE: NODE REJOIN successful
DETAIL: node 1 is now attached to node 2
We are checking cluster below command, we will have shown PG-Node2 as primary, other one is standby.
-bash-4.2$ /usr/pgsql-12/bin/repmgr -f /etc/repmgr/12/repmgr.conf cluster show
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+----------+---------+---------------+----------+----------+----------+----------+-----------------------------------------------------------
1 | PG-Node1 | standby | running | | default | 100 | 1 | host=10.0.0.4 user=repmgr dbname=repmgr connect_timeout=2
2 | PG-Node2 | primary | * running | | default | 100 | 2 | host=10.0.0.5 user=repmgr dbname=repmgr connect_timeout=2
Best Regards.
Engin YILMAZ.
Yorumlar
Henüz yorum yapılmadı.