Source Installation PostgreSQL

Source: Internet
Author: User
Tags chmod dba postgresql psql readline file permissions

Database version:

PostgreSQL 9.6.3


System version:

CentOS Release 6.6 (Final)


Download software (Download software):

[email protected] tools]# wget https://ftp.postgresql.org/pub/source/v9.6.3/postgresql-9.6.3.tar.gz


To see if it is already installed (check is not instatll):

[Email protected] tools]# Ps-ef |grep pgsql

Root 28590 18695 0 20:24 pts/0 00:00:00 grep pgsql

[Email protected] ~]$ Rpm-qa |grep postgres

Postgresql-libs-8.4.18-1.el6_4.x86_64


Decompression (Extract software):

[Email protected] tools]# Tar XF postgresql-9.6.3.tar.gz


Compile and install (Complie):

[Email protected] tools]# CD postgresql-9.6.3

[Email protected] postgresql-9.6.3]#/configure--prefix=/usr/local/pgsql

Compile everything you can compile, including documents (HTML and Man pages) and additional modules (contrib):

[[email protected] postgresql-9.6.3]# make world && make Install-world

......

MAKE[2]: Leaving directory '/home/tools/postgresql-9.6.3/contrib/vacuumlo '

MAKE[1]: Leaving directory '/home/tools/postgresql-9.6.3/contrib '

PostgreSQL, contrib, and documentation installation complete.


Create with groups and users (create group and user)

[[email protected] ~]# GROUPADD-G 101 dba

[[email protected] ~]# Cat/etc/group|grep DBA

DBA:X:101:

[Email protected] ~]# useradd-u 516-g dba-g root-d/usr/local/pgsql postgres

[[email protected]ren2 ~]# ID postgres

uid=516 (Postgres) gid=101 (DBA) groups=101 (DBA), 0 (Root)

-U UID

-G Initial User group

-G Secondary User group

-M Create user home directory (System user does not create home directory by default)

-M does not create a user home directory (default for normal users to create home directories)

-S shell default is/bin/bash

-D Specify home directory


[email protected] home]# groups Postgres

POSTGRES:DBA Root


Configuring the Postgres Password

[Email protected] home]# passwd postgres


[Email protected] skel]# ls-al/etc/skel/

Total 20

Drwxr-xr-x. 2 root root 4096 Dec 20 2016.

Drwxr-xr-x. Root root 4096 Jul 11 22:27.

-rw-r--r--. 1 root root. bash_logout

-rw-r--r--. 1 root root 176 Jul Bash_profile

-rw-r--r--. 1 root root 124 Jul BASHRC

[Email protected] skel]# cp/etc/skel/.*/usr/local/pgsql/


Creating a Data directory (create database folder)

[Email protected] ~]# mkdir-p/usr/local/pgsql/data


Configuration. Bash_profile (Configure. Bash_profile)

[Email protected] pgsql]# Cat/usr/local/pgsql/.bash_profile

#. Bash_profile

# Get the aliases and functions

If [-f ~/.BASHRC]; Then

. ~/.bashrc

Fi

# User specific environment and startup programs

Path= $PATH: $HOME/bin

Export Pghome=/usr/local/pgsql

Export Pgdata=/usr/local/pgsql/data

Export path= $PATH:/usr/local/pgsql/bin

Set Umask to 022

Umask 022

ps1= ' Uname-n ' ":" ' $USER ' ":" ' $PWD ' ":>"; Export PS1


Modify file permissions and owners (Chmod and Chown)

[Email protected] pgsql]# chmod-r 755/usr/local/pgsql

[Email protected] pgsql]# chown-r postgres:dba/usr/local/pgsql

[Email protected] pgsql]# chmod-r 700/usr/local/pgsql/data


Configure the PostgreSQL service to start and set up self-boot (Configure PostgreSQL services and Boot auto start)-This step is not done

[Email protected] start-scripts]# cp/home/tools/postgresql-9.6.3/contrib/start-scripts/linux/etc/init.d/ PostgreSQL

[Email protected] start-scripts]# chmod +x/etc/init.d/postgresql

[Email protected] start-scripts]# chkconfig--list |grep PostgreSQL

[Email protected] start-scripts]# chkconfig--add PostgreSQL

[Email protected] start-scripts]# chkconfig--list |grep PostgreSQL

PostgreSQL 0:off 1:off 2:on 3:on 4:on 5:on 6:off


Initializing data and starting (Initialize database and start database)

[Email protected] start-scripts]# Su-postgres

[[Email protected] start-scripts]$ CD

[Email protected] ~]$ pwd

/usr/local/pgsql

[Email protected] ~]$. . bash_profile


#初始化生成数据文件

Darren2:postgres:/usr/local/pgsql:>/usr/local/pgsql/bin/initdb-d/usr/local/pgsql/data


#启动数据库

Darren2:postgres:/usr/local/pgsql:>pg_ctl start

Server starting

Darren2:postgres:/usr/local/pgsql:>log:database system was shut down at 2017-07-12 00:49:17 CST

Log:multixact member wraparound protections is now enabled

Log:database system is ready to accept connections

Log:autovacuum Launcher started


Creating Users and databases (create user and database)

Psql

Psql (9.6.3)

Type ' help ' for help.

postgres=# Create user admin password ' admin ' login;

CREATE ROLE

postgres=# CREATE database TestDB with Owner=admin;

CREATE DATABASE


Darren2:postgres:/usr/local/pgsql:>pg_ctl status

Pg_ctl:server is running (pid:51498)

/usr/local/pgsql/bin/postgres


Common Error during installation

Compile time error:

[Email protected] postgresql-9.6.3]#/configure--prefix=/usr/local/pgsql--without-zlib

......

Configure:error:readline Library not found--prompt to find ReadLine

If you had readline already installed, see Config.log for details on the

Failure. It is possible the compiler "t looking in the proper directory.

Use--without-readline to disable ReadLine support.

Check that the system has ReadLine installed:

[Email protected] postgresql-9.6.3]# Rpm-qa |grep readline

Compat-readline5-5.2-17.1.el6.x86_64

Readline-6.0-4.el6.x86_64

With Yum search you can find that Readline-devel is not installed:

[email protected] postgresql-9.6.3]# Yum search ReadLine

......

Readline-devel.i686:files needed to develop programs which use the ReadLine library

Readline-devel.x86_64:files needed to develop programs which use the ReadLine library

......

After installing through Yum, the compilation can be done by:

[email protected] postgresql-9.6.3]# Yum install-y readline-devel


This article is from the "10979687" blog, please be sure to keep this source http://10989687.blog.51cto.com/10979687/1971094

Source Installation PostgreSQL

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.