Setting up PostgreSQL master server under Ubuntu

Source: Internet
Author: User
Tags postgresql psql


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

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.