-
-
Save bitdivine/8897d37607d60b42a2ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hostssl replication replicator 5.6.7.8 md5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
listen_address = # make sure we're listening as appropriate | |
wal_level = hot_standby | |
max_wal_senders = 3 | |
checkpoint_segments = 8 | |
wal_keep_segments = 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wal_level = hot_standby | |
max_wal_senders = 3 | |
checkpoint_segments = 8 | |
wal_keep_segments = 8 | |
hot_standby = on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo Stopping PostgreSQL | |
sudo service postgresql stop | |
echo Cleaning up old cluster directory | |
sudo -u postgres rm -rf /var/lib/postgresql/9.2/main | |
echo Starting base backup as replicator | |
sudo -u postgres pg_basebackup -h 1.2.3.4 -D /var/lib/postgresql/9.2/main -U replicator -v -P | |
echo Writing recovery.conf file | |
sudo -u postgres bash -c "cat > /var/lib/postgresql/9.2/main/recovery.conf <<- _EOF1_ | |
standby_mode = 'on' | |
primary_conninfo = 'host=1.2.3.4 port=5432 user=replicator password=thepassword sslmode=require' | |
trigger_file = '/tmp/postgresql.trigger' | |
_EOF1_ | |
" | |
echo Setting up a self signed ssl cert: | |
pushd /var/lib/postgresql/9.2/main/ | |
openssl req -new -text -out server.req | |
openssl rsa -in privkey.pem -out server.key | |
rm privkey.pem | |
openssl req -x509 -in server.req -text -key server.key -out server.crt | |
chmod og-rwx server.key | |
chown postgres:postgres server.* | |
chmod 600 server.* | |
popd | |
echo Starting PostgreSQL | |
sudo service postgresql start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo -u postgres psql -x -c "select * from pg_stat_replication;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo -u postgres psql -c "CREATE USER replicator REPLICATION LOGIN ENCRYPTED PASSWORD 'thepassword';" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment