Skip to content

Instantly share code, notes, and snippets.

@eclecticmiraclecat
Created September 24, 2020 16:52
Show Gist options
  • Save eclecticmiraclecat/f517ac43abcd17495dd06341f58b3b88 to your computer and use it in GitHub Desktop.
Save eclecticmiraclecat/f517ac43abcd17495dd06341f58b3b88 to your computer and use it in GitHub Desktop.

run docker

docker run -it jberkus/pgreplicationtutorial

tmux

[ctrl]+b c
su - postgres
[ctrl]+b n
[ctrl]+b n
(you should be in "postgres" shell)
pg_ctl -D 9.4/master start

create replica of master

cd 9.4
ls
(all the directory are separate data directory for postgres)
pg_basebackup -x -P -D replica1 -p 5432 -h localhost
cp /setup/postgres/replica1/* replica1/
chown postgres:postgres replica1
pg_ctl -D replica1 start
ps aux | grep postgres
psql -p 5432 libdata
\dt
\q
psql -p 5433 libdata
\dt
\q

create traffic on master

createdb -p 5432 bench
pgbench -i -s 10 -U bench bench
psql -p 5432 bench
\dt
\q
psql -p 5433 bench
\dt
\q
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment