summaryrefslogtreecommitdiff
path: root/src/sample/scripts
diff options
context:
space:
mode:
authorBo Peng2022-06-05 06:54:12 +0000
committerBo Peng2022-06-05 06:55:18 +0000
commita64df3b9558ae9b2657be76e2ce7b6d151675f83 (patch)
tree676439c36e894319b773b851bddffd4864d0fb14 /src/sample/scripts
parent7c7e422c04990cc478f17d25ce4da3308cbea145 (diff)
Update PSQL connection information in sample scripts.
Diffstat (limited to 'src/sample/scripts')
-rwxr-xr-xsrc/sample/scripts/failover.sh.sample2
-rwxr-xr-xsrc/sample/scripts/follow_primary.sh.sample9
-rwxr-xr-xsrc/sample/scripts/recovery_1st_stage.sample4
3 files changed, 8 insertions, 7 deletions
diff --git a/src/sample/scripts/failover.sh.sample b/src/sample/scripts/failover.sh.sample
index 713992d3c..b5119ccf4 100755
--- a/src/sample/scripts/failover.sh.sample
+++ b/src/sample/scripts/failover.sh.sample
@@ -58,7 +58,7 @@ fi
if [ $OLD_PRIMARY_NODE_ID != "-1" -a $FAILED_NODE_ID != $OLD_PRIMARY_NODE_ID ]; then
# If Standby node is down, drop replication slot.
- ${PGHOME}/bin/psql -h ${OLD_PRIMARY_NODE_HOST} -p ${OLD_PRIMARY_NODE_PORT} \
+ ${PGHOME}/bin/psql -h ${OLD_PRIMARY_NODE_HOST} -p ${OLD_PRIMARY_NODE_PORT} postgres \
-c "SELECT pg_drop_replication_slot('${REPL_SLOT_NAME}');" >/dev/null 2>&1
if [ $? -ne 0 ]; then
diff --git a/src/sample/scripts/follow_primary.sh.sample b/src/sample/scripts/follow_primary.sh.sample
index 8be4348ae..3c7c88d6f 100755
--- a/src/sample/scripts/follow_primary.sh.sample
+++ b/src/sample/scripts/follow_primary.sh.sample
@@ -71,7 +71,7 @@ fi
echo follow_primary.sh: pg_rewind for node ${NODE_ID}
# Create replication slot "${REPL_SLOT_NAME}"
-${PGHOME}/bin/psql -h ${NEW_PRIMARY_NODE_HOST} -p ${NEW_PRIMARY_NODE_PORT} \
+${PGHOME}/bin/psql -h ${NEW_PRIMARY_NODE_HOST} -p ${NEW_PRIMARY_NODE_PORT} postgres \
-c "SELECT pg_create_physical_replication_slot('${REPL_SLOT_NAME}');" >/dev/null 2>&1
if [ $? -ne 0 ]; then
@@ -84,7 +84,7 @@ ssh -T -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${POSTGRESQL_
${PGHOME}/bin/pg_ctl -w -m f -D ${NODE_PGDATA} stop
- ${PGHOME}/bin/pg_rewind -D ${NODE_PGDATA} --source-server=\"user=postgres host=${NEW_PRIMARY_NODE_HOST} port=${NEW_PRIMARY_NODE_PORT}\"
+ ${PGHOME}/bin/pg_rewind -D ${NODE_PGDATA} --source-server=\"user=${POSTGRESQL_STARTUP_USER} host=${NEW_PRIMARY_NODE_HOST} port=${NEW_PRIMARY_NODE_PORT} dbname=postgres\"
rm -rf ${NODE_PGDATA}/pg_replslot/*
@@ -133,12 +133,13 @@ EOT
else
echo \"standby_mode = 'on'\" >> ${RECOVERYCONF}
fi
+ sed -i -e \"s/#*port = .*/port = ${NODE_PORT}/\" ${NODE_PGDATA}/postgresql.conf
"
if [ $? -ne 0 ]; then
# drop replication slot
- ${PGHOME}/bin/psql -h ${NEW_PRIMARY_NODE_HOST} -p ${NEW_PRIMARY_NODE_PORT} \
+ ${PGHOME}/bin/psql -h ${NEW_PRIMARY_NODE_HOST} -p ${NEW_PRIMARY_NODE_PORT} postgres \
-c "SELECT pg_drop_replication_slot('${REPL_SLOT_NAME}');" >/dev/null 2>&1
if [ $? -ne 0 ]; then
@@ -169,7 +170,7 @@ if [ $? -eq 0 ]; then
else
# If start Standby failed, drop replication slot "${REPL_SLOT_NAME}"
- ${PGHOME}/bin/psql -h ${NEW_PRIMARY_NODE_HOST} -p ${NEW_PRIMARY_NODE_PORT} \
+ ${PGHOME}/bin/psql -h ${NEW_PRIMARY_NODE_HOST} -p ${NEW_PRIMARY_NODE_PORT} postgres \
-c "SELECT pg_drop_replication_slot('${REPL_SLOT_NAME}');" >/dev/null 2>&1
if [ $? -ne 0 ]; then
diff --git a/src/sample/scripts/recovery_1st_stage.sample b/src/sample/scripts/recovery_1st_stage.sample
index f178f492d..c01001c65 100755
--- a/src/sample/scripts/recovery_1st_stage.sample
+++ b/src/sample/scripts/recovery_1st_stage.sample
@@ -37,7 +37,7 @@ else
fi
## Create replication slot "${REPL_SLOT_NAME}"
-${PGHOME}/bin/psql -h ${PRIMARY_NODE_HOST} -p ${PRIMARY_NODE_PORT} \
+${PGHOME}/bin/psql -h ${PRIMARY_NODE_HOST} -p ${PRIMARY_NODE_PORT} postgres \
-c "SELECT pg_create_physical_replication_slot('${REPL_SLOT_NAME}');" >/dev/null 2>&1
if [ $? -ne 0 ]; then
@@ -74,7 +74,7 @@ EOT
if [ $? -ne 0 ]; then
- ${PGHOME}/bin/psql -h ${PRIMARY_NODE_HOST} -p ${PRIMARY_NODE_PORT} \
+ ${PGHOME}/bin/psql -h ${PRIMARY_NODE_HOST} -p ${PRIMARY_NODE_PORT} postgres \
-c "SELECT pg_drop_replication_slot('${REPL_SLOT_NAME}');" >/dev/null 2>&1
if [ $? -ne 0 ]; then