Setting up PostgreSQL master server under Ubuntu (Method 1)
Install slightly
PostgreSQL master server:
$ vi/etc/postgresql/9.1/main/postgresql.conf
Press A or I to enter edit mode
listen_addresses = ' * ' (default is commented, this does not change when synchronizing from PostgreSQL will report a connection rejection)
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)
log_destination = ' stderr '
Logging_collector = On
log_directory = ' pg_log ' (absolute path:/var/lib/postgresql/9.1/main/)
Log_file_name = ' Postgresql-%y-%m-%d_%h%m%s.log '
Log_rotation_size = 10MB
Press the ESC key to exit the edit
: Wq (Save and exit)
$ vi/etc/postgresql/9.1/main/pg_hba.conf
Press A or I to enter edit mode
Host replication Yang 10.0.0.3/32 MD5 (MD5 is required password, trust is not required)
Press the ESC key to exit the edit
: Wq (Save and exit)
$ psql
postgres=# Create user Yang superuser password ' 123456 ';
postgres=# \q
Restart PostgreSQL
$ Service PostgreSQL Restart
$ psql
postgres=# Select Pg_start_backup ("); Keep the primary database in a backup state
You can open a window again.
# scp-r/var/lib/postgresql/9.1/main [email PROTECTED]:/VAR/LIB/POSTGRESQL/9.1/(recommended before operation)
will be renamed from the server's main directory under Backup)
postgres=# select Pg_stop_backup (); To close a backup of the primary database
PostgreSQL from the server:
$ vi/etc/postgresql/9.1/main/postgresql.conf
Press A or I to enter edit mode
Hot_standby = On (default is comment)
log_destination = ' stderr '
Logging_collector = On
log_directory = ' pg_log ' (absolute path:/var/lib/postgresql/9.1/main/)
Log_file_name = ' Postgresql-%y-%m-%d_%h%m%s.log '
Log_rotation_size = 10MB
Press the ESC key to exit the edit
: Wq (Save and exit)
$ vi/var/lib/postgresql/9.1/main/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/var/lib/postgresql/9.1/main/postmaster.pid
$ NETSTAT-NTPL | grep 5432
$ kill-9 PID on the previous step
$ service PostgreSQL Start
$ cat/var/lib/postgresql/9.1/main/pg_log/postgresql-2015-01-14_180349.log (mostly see if there's
With "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 is from the "Linux" blog, so be sure to keep this source http://yangzhiming.blog.51cto.com/4849999/1665548
Setting up PostgreSQL master server under Ubuntu (Method 1)