RHEL7.2+PostgreSQL9.6.1


Requirements softwares

1.GNU make version 3.80 or newer is required

[root@rhel7 ~]# make --version

GNU Make 3.82

Built for x86_64-redhat-linux-gnu

2.You need an ISO/ANSI C compiler (at least C89-compliant). Recent versions of GCC are recommended

[root@rhel7 ~]# gcc --version

gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)

3. tar is required to unpack the source distribution, in addition to either gzip or bzip2.

4.The GNU Readline library is used by default.

readline

readline-devel

libedit

Optional

perl 5.8 or later

python

Kerberos

OpenSSL

OpenLDAP

and/or PAM

Flex 2.5.31 or later

Bison 1.875 or later


useradd pguser

su - pguser

tar -zxvfpostgresql-9.6.1.tar.gz


Install

cdpostgresql-9.6.1

./configure

默认安装目录/usr/local/pgsql,可以使用--prefix=path进行修改,./configure --help

make

The last line displayed should be:
All of PostgreSQL successfully made. Ready to install.

su (使用root安装)

make install

PostgreSQL installation complete.

Set the environment variables for pguser

mkdir /usr/local/pgsql/data #PostgreSQL数据存储目录

chown pguser:pguser /usr/local/pgsql/data

export LD_LIBRARY_PATH=/usr/local/pgsql/lib

export PG_HOME=/usr/local/pgsql

export PATH=$PG_HOME/bin/:$PATH

export PGDATA=/usr/local/pgsql/data

Initilize the DBServer

(使用pguser)

[pguser@rhel7~]$initdb-D/usr/local/pgsql/dataThefilesbelongingtothisdatabasesystemwillbeownedbyuser"pguser".Thisusermustalsoowntheserverprocess.Thedatabaseclusterwillbeinitializedwithlocale"en_US.UTF-8".Thedefaultdatabaseencodinghasaccordinglybeensetto"UTF8".Thedefaulttextsearchconfigurationwillbesetto"english".Datapagechecksumsaredisabled.fixingpermissionsonexistingdirectory/usr/local/pgsql/data...okcreatingsubdirectories...okselectingdefaultmax_connections...100selectingdefaultshared_buffers...128MBselectingdynamicsharedmemoryimplementation...posixcreatingconfigurationfiles...okrunningbootstrapscript...okperformingpost-bootstrapinitialization...oksyncingdatatodisk...okWARNING:enabling"trust"authenticationforlocalconnectionsYoucanchangethisbyeditingpg_hba.conforusingtheoption-A,or--auth-localand--auth-host,thenexttimeyouruninitdb.Success.Youcannowstartthedatabaseserverusing:pg_ctl-D/usr/local/pgsql/data-llogfilestart

Start the DBServer

[pguser@rhel7~]$postgres-D/usr/local/pgsql/data>logfile2>&1&[1]13799[pguser@rhel7~]$ps-ef|greppostgrepguser137994377012:37pts/000:00:00postgres-D/usr/local/pgsql/datapguser1380113799012:37?00:00:00postgres:checkpointerprocesspguser1380213799012:37?00:00:00postgres:writerprocesspguser1380313799012:37?00:00:00postgres:walwriterprocesspguser1380413799012:37?00:00:00postgres:autovacuumlauncherprocesspguser1380513799012:37?00:00:00postgres:statscollectorprocesspguser138074377012:37pts/000:00:00grep--color=autopostgre

连接测试

[pguser@rhel7~]$psql--listListofdatabasesName|Owner|Encoding|Collate|Ctype|Accessprivileges-----------+--------+----------+-------------+-------------+-------------------postgres|pguser|UTF8|en_US.UTF-8|en_US.UTF-8|template0|pguser|UTF8|en_US.UTF-8|en_US.UTF-8|=c/pguser+|||||pguser=CTc/pgusertemplate1|pguser|UTF8|en_US.UTF-8|en_US.UTF-8|=c/pguser+|||||pguser=CTc/pguser(3rows)[pguser@rhel7~]$psqlpostgrespsql(9.6.1)Type"help"forhelp.postgres=#selectversion();version---------------------------------------------------------------------------------------------------------PostgreSQL9.6.1onx86_64-pc-linux-gnu,compiledbygcc(GCC)4.8.520150623(RedHat4.8.5-4),64-bit(1row)postgres=#selectcurrent_date;date------------2016-12-01(1row)postgres=#\q

官方文档:https://www.postgresql.org/docs/9.6/static/installation.html