1
0
mirror of https://github.com/coltoneshaw/CS-Repro-Mattermost.git synced 2025-12-23 18:11:34 +01:00

fixed some replica config settings

This commit is contained in:
coltoneshaw
2024-03-29 18:37:21 -04:00
parent 21fdbf5a37
commit 7e4f5cf5e8
12 changed files with 59 additions and 62 deletions

View File

@@ -0,0 +1,8 @@
{
"SqlSettings": {
"DataSourceReplicas": [
"postgres://mmuser:mmuser_password@cs-repro-postgres-replica-1:5432/mattermost?sslmode=disable&connect_timeout=10&binary_parameters=yes",
"postgres://mmuser:mmuser_password@cs-repro-postgres-replica-2:5432/mattermost?sslmode=disable&connect_timeout=10&binary_parameters=yes"
]
}
}

View File

@@ -59,6 +59,10 @@ hot_standby_feedback = on
# host - replace "x.x.x.x" with your IP or URL string.
primary_conninfo = 'host=cs-repro-postgres port=5432 user=replicauser password=replicauser_password'
# replication slot on sending server
# This needs to be configured using the docs below for "Keeping the replica and primary in sync."
primary_slot_name = ''
log_connections = on
log_disconnections = on
log_replication_commands = on

View File

@@ -2,16 +2,23 @@
set -e
echo "include '/files/postgres/replica/replica_config.conf'" >> /var/lib/postgresql/data/postgresql.conf
cp /var/lib/postgresql/data/postgresql.conf /files/postgres/replica/baseconfig.conf
## copying the base replica configuration and updating the primary slot name
cp /files/postgres/replica/base_replica_config.conf /files/postgres/replica/${REPLICA_NAME}.conf
sed -i "s/primary_slot_name = ''/primary_slot_name = '${REPLICA_NAME}_slot'/" /files/postgres/replica/${REPLICA_NAME}.conf
## copying the default postgres config and adding the replica specific configuration
echo "include '/files/postgres/replica/${REPLICA_NAME}.conf'" >> /var/lib/postgresql/data/postgresql.conf
cp /var/lib/postgresql/data/postgresql.conf /files/postgres/replica/${REPLICA_NAME}_postgres.conf
## Removing the pg data information to make way for the backup
rm -rf /var/lib/postgresql/data/*
export PGPASSWORD='replicauser_password'
pg_basebackup -h cs-repro-postgres -p 5432 -U replicauser -D /var/lib/postgresql/data -Fp -Xs -R
## Backup brings over the primary config, so we do not need it anymore.
rm -rf /var/lib/postgresql/data/postgresql.conf
cp /files/postgres/replica/baseconfig.conf /var/lib/postgresql/data/postgresql.conf
## Bringing back in the replica specific config.
cp /files/postgres/replica/${REPLICA_NAME}_postgres.conf /var/lib/postgresql/data/postgresql.conf
exec pg_ctl -D /var/lib/postgresql/data start

View File

@@ -1,19 +0,0 @@
#!/bin/bash
set -e
echo "include '/files/postgres/replica/replica_config.conf'" >> /var/lib/postgresql/data/postgresql.conf
echo "include '/files/postgres/replica/replica_1/replica_1_config.conf'" >> /var/lib/postgresql/data/postgresql.conf
cp /var/lib/postgresql/data/postgresql.conf /files/postgres/replica/replica_1/baseconfig.conf
rm -rf /var/lib/postgresql/data/*
export PGPASSWORD='replicauser_password'
pg_basebackup -h cs-repro-postgres -p 5432 -U replicauser -D /var/lib/postgresql/data -Fp -Xs -R
rm -rf /var/lib/postgresql/data/postgresql.conf
cp /files/postgres/replica/replica_1/baseconfig.conf /var/lib/postgresql/data/postgresql.conf
exec pg_ctl -D /var/lib/postgresql/data start

View File

@@ -1,3 +0,0 @@
# replication slot on sending server
# This needs to be configured using the docs below for "Keeping the replica and primary in sync."
primary_slot_name = 'replica_1_slot'

View File

@@ -1,19 +0,0 @@
#!/bin/bash
set -e
echo "include '/files/postgres/replica/replica_config.conf'" >> /var/lib/postgresql/data/postgresql.conf
echo "include '/files/postgres/replica/replica_2/replica_2_config.conf'" >> /var/lib/postgresql/data/postgresql.conf
cp /var/lib/postgresql/data/postgresql.conf /files/postgres/replica/replica_2/baseconfig.conf
rm -rf /var/lib/postgresql/data/*
export PGPASSWORD='replicauser_password'
pg_basebackup -h cs-repro-postgres -p 5432 -U replicauser -D /var/lib/postgresql/data -Fp -Xs -R
rm -rf /var/lib/postgresql/data/postgresql.conf
cp /files/postgres/replica/replica_2/baseconfig.conf /var/lib/postgresql/data/postgresql.conf
exec pg_ctl -D /var/lib/postgresql/data start

View File

@@ -1,3 +0,0 @@
# replication slot on sending server
# This needs to be configured using the docs below for "Keeping the replica and primary in sync."
primary_slot_name = 'replica_2_slot'