Setting up PostgreSQL master server under Ubuntu
Install slightly
PostgreSQL master server:
$ vi/home/postgresql/data/postgresql.conf
Press A or I to enter edit mode
listen_addresses = ' * '
Wal_level = Hot_standby (default is commented)
Max_wal_senders = 5 (default is comment, this parameter is the maximum number of concurrent standby databases that can be controlled by the main library)
Wal_keep_segments = 32 (default is comment, set a value large enough to prevent the main library from generating the Wal log too fast, the log has not yet come
and transmitted to the standby will be covered by the loop)
Press the ESC key to exit the edit
: Wq (Save and exit)
$ vi/home/postgresql/data/pg_hba.conf
Press A or I to enter edit mode
Host replication Postgres 10.0.0.3/32 MD5 (MD5 is required password, trust is not required password)
Press the ESC key to exit the edit
: Wq (Save and exit)
$ psql
postgres=# Create user Yang superuser password ' 123456 ';
postgres=# \q
Restart PostgreSQL
$ NETSTAT-NTPL | grep 5432
$ kill-9 PID on the previous step
$ psql
postgres=# Select Pg_start_backup ("); Keep the primary database in a backup state
You can open a window again.
# scp-r/home/postgresql/data [email Protected]:/home/postgresql/data (The recommended action is to start the server before
The data of the directory renamed under Backup)
postgres=# select Pg_stop_backup (); To close a backup of the primary database
PostgreSQL from the server:
$ vi/home/postgresql/data/postgresql.conf
Press A or I to enter edit mode
Hot_standby = On (default is comment)
Press the ESC key to exit the edit
: Wq (Save and exit)
$ vi/home/postgresql/data/recovery.conf
Press A or I to enter edit mode
Standby_mode = ' on '
Primary_conninfo = ' host=10.0.0.2 port=5432 user=yang password=123456 '
Press the ESC key to exit the edit
: Wq (Save and exit)
$ rm-rf/home/postgresql/data/postmaster.pid
$ NETSTAT-NTPL | grep 5432
$ kill-9 PID on the previous step
$ postgres-d/home/postgresql/data
$ cat/home/postgresql/data/pg_log/postgresql-2015-01-14_180349.log (mostly see if there is "log:
Entering standby mode "and" consistent recovery state reached at 0/3000000 ")
Verify:
At this point, create a new database or table on the primary PostgreSQL, and then check to see if it is synchronized from PostgreSQL
This article from "Linux" blog, declined reprint!
Setting up PostgreSQL master server under Ubuntu