Setting up PostgreSQL master server under Ubuntu (Method 1)

Source: Internet
Author: User
Tags postgresql psql


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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.