PostgreSQL Stream mode construction

Source: Internet
Author: User
Tags openldap

PostgreSQL Stream mode construction

PostgreSQL Stream mode construction

1. Compile and install

Yum install-y gcc-c ++ automake autoconf libjpeg-devel libpng-devel freetype-devel libxml2 libxml2-devel zlib-devel glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses -devel curl-devel plugin e2fsprogs-devel krb5 krb5-devel libidn-devel openssl-devel openldap-devel plugin openldap-clients openldap-servers bison * glib * flex readline-devel apr -util apr-develrzsz sysstat e4fsprogs ntp readline-devel openssl-devel pam-devel libxml2-devel libxslt-devel python-devel tcl-devel flex bison

Tar-jxvf postgresql-9.2.1.tar.bz2
Cd postgresql-9.2.1
./Configure -- prefix =/usr/local/pgsql
Gmake world
Gmake install-world

2. Create a user and authorize

# Create a database directory
Mkdir/data
# Create user ipvs and authorize
Useradd S
Chown postgres. postgres/data

3. Configure Environment Variables

# Switch to postgres user
Su ipvs
# Configure the environment variable for it:
Vim ~ Postgres/. bash_profile
PGLIB =/usr/local/pgsql/lib
PGDATA =/data
PATH = $ PATH:/usr/local/pgsql/bin
MANPATH = $ MANPATH:/usr/local/pgsql/man
Export PGLIB PGDATA PATH MANPATH
Export PGDATA =/data

4. initialize the database

Initdb-D $ PGDATA

5. Modify the Master configuration file

Vim pg_cmd.conf

Host all 192.168.2.4/32 trust

Host all ipvs 192.168.2.4/32 trust

Vim ipvs. conf
Listen_addresses = '*'
Wal_level = 'hot _ standby'
Max_wal_senders = 3
Wal_keep_segments = 16 #80 GB required on pg_xlog
Cp/usr/local/pgsql/share/recovery. conf. sample/data/recovery. cone
Vim reconver. conf
Standby_mode = on
Primary_conninfo = 'host = master port = 5433 user = s s' # slave node Information

6. Generate a slave database instance

[S @ localhost data] $ pg_ctl-D $ PGDATA-p 5432

Transfer data files to slave

Run

[Postgres @ localhost data] $ pg_basebackup-D $ PGDATA-Fp-Xs-v-h master-p 5432-U postgres

7. Modify the Slave configuration file

[S @ localhost data] $ vim postgresql. conf

Delete "#"

Hot_standby = on
Vim reconver. conf
Standby_mode = on
Primary_conninfo = 'host = master port = 5432 user = s s' # master node Information

8. Start the Master/Slave Database

Pg_ctl-D $ PGDATA

Master


[S @ localhost data] $ ps-ef | grep postgres | grep sender
Postgres 12021 10924 0? 00:00:00 ipvs: wal sender process ipvs 172.16.0.132 (33427) streaming 0/3036838

Slave

[S @ localhost data] $ ps-ef | grep postgres | grep recover
Postgres 5479 5471 0? 00:00:00 postgres: startup process recovering 000000020000000000000000000d


Note: At this time, slave synchronizes data from the master, but slave is read-only.

------------------------------------ Lili split line ------------------------------------

Install PostgreSQL 6.3 on yum in CentOS 9.3

PostgreSQL cache details

Compiling PostgreSQL on Windows

Configuration and installation of LAPP (Linux + Apache + PostgreSQL + PHP) Environment in Ubuntu

Install and configure phppgAdmin on Ubuntu

Install PostgreSQL9.3 on CentOS

Configure a Streaming Replication cluster in PostgreSQL

How to install PostgreSQL 7/6 and phpPgAdmin in CentOS 5/6. 4

------------------------------------ Lili split line ------------------------------------

PostgreSQL details: click here
PostgreSQL: click here

This article permanently updates the link address:

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.