Environment: CentOS6.9 x86_64
network environment of the machine: 10. X.X.X/8 (8-bit mask)
# Install RPM Package
Yum Install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/ 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:
Pgdata=/bdata/data/nowdb2/datapglog=/bdata/data/nowdb2/pgstartup.log
# 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
Source/var/lib/pgsql/.pgsql_profile
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 10.0.0.0/8 md5host all Devuser3 10.0.0.0/8 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