centos6.5 compile and install pgsql9.4.4 and master-slave stream replication

Source: Internet
Author: User
Tags postgresql readline

# # PostgreSQL Yum Source website

https://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/repoview/

Dependency Packages

ReadLine readline-devel zlib zlib-devel ncurses-base ncurses-libs ncurses-devel


######### Compiling and installing

# wget Https://ftp.postgresql.org/pub/source/v9.4.4/postgresql-9.4.4.tar.gz-P/usr/local/src/

# tar XF postgresql-9.4.4.tar.gz && CD postgresql-9.4.4

#./configure--prefix=/usr/pgsql-9.4

# make-j 2 && make install# #要求make版本3.8+, use make--version to detect the make compiler version

# ln-sv/usr/pgsql-9.4/usr/local/pgsql# # Convenient later version upgrade


######## Configuring environment variables

# vim/etc/profile.d/pgsql.sh

Pghome=/usr/local/pgsql

Pgdata=/usr/local/pgsql_data

Path= $PATH: $PGHOME/bin

Export Pghome PGDATA PATH

# source/etc/profile.d/pgsql.sh# # Configuration takes effect immediately

# ldconfig/usr/local/pgsql/lib/# # import Pgsql Library Path

# cd/usr/local/src/postgresql-9.4.4/contrib/

# make-j 2 && make install# # Install the three-party extension


######## adding Pgsql Users and data storage directories

# Useradd-r Postgres

# Mkdir/usr/local/pgsql_data

# chown Postgres/usr/local/pgsql_data


######## Primary Library Initialization Pgsql

# su-postgres# # Pgsql not be able to use the root user by default

$ pg_ctl-d $PGDATA init# # Initialize DB


# # # Configure master-Slave flow replication

$ CD $PGDATA

$ vim postgresql.conf

listen_addresses = ' * '

Wal_level = Hot_standby

Max_wal_senders = 2

log_destination = ' stderr '# # # The following is the turn on logging feature

Logging_collector = On

log_directory = ' Pg_log '

Log_filename = ' Postgresql-%y-%m-%d_%h%m%s.log '

Log_rotation_age = 30d

Log_min_messages = Error

Log_min_error_statement = Error

log_min_duration_statement = 1s

Log_timezone = ' asia/chongqing '

$ pg_ctl-d $PGDATA start# # Startup database

# # # Create a stream copy account

$ psql

postgres=# CREATE ROLE repluser Login Replication encrypted password ' repluser ';

$ vim pg_hba.conf# # Configure Replication account authentication license

Host replication Repluser 192.168.5.134/32 MD5

$ pg_ctl-d $PGDATA Reload# # Overloads make configuration effective


######## Configuration from Library

# Su-postgres

$ pg_basebackup-h 192.168.5.129-u repluser-d $PGDATA-X stream-p-R #-R can automatically generate a recovery.conf configuration file that is copied from the main library A basic backup

$ chmod 0700 $PGDATA

$ vim postgresql.conf# # can query libraries when configuring stream replication

Hot_standby = On

$ pg_ctl-d $PGDATA Start


######## checking the flow replication process

$ ps-c Postgres-f | grep wal# # appears this process indicates a successful configuration

UID PID PPID C stime TTY time CMD

Postgres 71424 71418 0 18:50? 00:00:00 Postgres:wal receiver Process streaming 05000a08


########

SELECT * from Pg_roles; # # Enquiry Account

# # # # Account Password modification

postgres= #alter user postgres with password ' new password ';





This article is from the "rookie" blog, please be sure to keep this source http://1433584.blog.51cto.com/1423584/1954688

centos6.5 compile and install pgsql9.4.4 and master-slave stream replication

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.