Revision [19532]
This is an old revision of PostgresStreamingNotes made by MikeShultz on 2017-04-18 12:29:51.
Notes on Streaming Test
https://www.postgresql.org/docs/9.6/static/high-availability.html
Setup
Install
rpm -i https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -i https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm yum install htop pg_activity mlocate bash-completion bash-completion-extras yum install postgresql96.x86_64 postgresql96-contrib.x86_64 postgresql96-devel.x86_64 postgresql96-libs.x86_64 postgresql96-server.x86_64 yum install postgis2_96 postgis2_96-utils postgis2_96-client
PostgreSQL Setup
Initialize the DB and get our schema and data into the new primary server.
# initialize on-disk DB /usr/pgsql-9.6/bin/postgresql96-setup initdb # Get roles pg_dumpall -r --file=./pg_roles.sql -h db0.cloud.votesmart.org -U mike -l pvsadmin # Get schema pg_dump -s -d pvsadmin -n public -n pyadmin -n django -n whitefront -h db0.cloud.votesmart.org -U mike -f pvsadmin_schema-20170417.sql # Get data #pg_dump -a -d pvsadmin -n public -n pyadmin -n django -n whitefront -h db0.cloud.votesmart.org -U mike -f pvsadmin_data-20170417.sql pg_dump -Fc -a -d pvsadmin -n public -n pyadmin -n django -n whitefront -h db0.cloud.votesmart.org -U mike -f pvsadmin_data-20170417.sql # On the new database server, create the DB and extensions necessary psql -c 'CREATE DATABASE pvsadmin' postgres psql -c 'CREATE EXTENSION postgis' pvsadmin # Import roles psql -1f pg_roles.sql # # This shouldn't be necessary after this one time, but leaving it here in case it's needed again # # Remove old user references sed -i 's/FROM adrian/FROM postgres/' pvsadmin_schema-20170417.sql sed -i 's/TO adrian/TO postgres/' pvsadmin_schema-20170417.sql sed -i 's/FROM slon/FROM postgres/' pvsadmin_schema-20170417.sql sed -i 's/TO slon/TO postgres/' pvsadmin_schema-20170417.sql # Remove all GRANTs to old users sed -i '/TO pgsql/d' pvsadmin_schema-20170417.sql sed -i '/TO jason/d' pvsadmin_schema-20170417.sql sed -i '/TO clinton/d' pvsadmin_schema-20170417.sql sed -i '/TO sarkis/d' pvsadmin_schema-20170417.sql sed -i '/TO ecasey/d' pvsadmin_schema-20170417.sql # Remove slony triggers and references sed -i '/_cluster_/d' pvsadmin_schema-20170417.sql # Import schema psql -1f pvsadmin_schema-20170417.sql pvsadmin # Import data psql -1f pvsadmin_data-20170417.sql pvsadmin #pg_restore -1 -a -d pvsadmin -h db0.cloud.votesmart.org -U mike --disable-triggers pvsadmin_data-20170417.sql pg_restore -1 -a -d pvsadmin --disable-triggers pvsadmin_data-20170417.sql
CategoryITMisc