Installation of postgresql9.6

Source: Internet
Author: User
Tags postgresql

Environment: CentOS6.9 x86_64

network environment of the machine: 10. X.X.X/8 (8-bit mask)

# Install RPM Package

Yum Install pgdg-centos96-9.6-3.noarch.rpm-y Yum Install postgresql96 postgresql96-server-y

# Prepare the Pgsql data storage directory

Mkdir/bdata/data/nowdb2/chown postgres.postgres/bdata/data/nowdb2/-R chmod 700/bdata/data/nowdb2/

vim/etc/init.d/postgresql-9.6 Modify the Pgdata path inside the startup script:


# Initialize Database

/etc/init.d/postgresql-9.6 Initdb

Su-postgres edit. bash_profile files, write Pghome and Pgdata for later use, with the following content:

[-f/etc/profile] && Source/etc/profilepgdata=/bdata/data/nowdb2/datapghome=/usr/pgsql-9.6/export Pgdataexport pghome[-f/var/lib/pgsql/.pgsql_profile] && source/var/lib/pgsql/.pgsql_profile

# Make Environment variables effective


vim/bdata/data/nowdb2/data/postgresql.conf modify some of the parameters (there are many parameters that can actually be modified), for example:

listen_addresses = ' * ' port = 5432max_connections = 500shared_buffers = 1024mbtemp_buffers = 16mbwork_mem = 4MB

# Start Pgsql

$PGHOME/bin/pg_ctl start-d $PGDATA

# Create a copy-right account for later use

CREATE ROLE Replica Login replication encrypted password ' replica ';

# Add a password to the Postgres account and later use it for Pg_rewind:

Alter user postgres password ' postgres ';

# Create a regular account and business library

Create DATABASE db1;create user devuser3 login password ' 111111 ' valid until ' 2020-01-11 '; ALTER DATABASE DB1 owner to Devu Ser3;

To edit an authorization file:

Vim Pg_hba.conf adds a line:

Host all Postgres md5host all Devuser3 MD5

# Overloaded configuration file

$PGHOME/bin/pg_ctl reload-d $PGDATA

In this way, we can connect to PostgreSQL on other machines.

Installation of postgresql9.6

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: 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.