Install PostgreSQL with the source code in CentOS

Source: Internet
Author: User
1. create an IPVs user, set its HOME directory to/usr/local/pgsqlgroupadd-g88postgresuseradd-u88-g88-d/usr/local/pgsql1_schmod755/usr/local/pgsqlpasswdpostgres ################# ############## 1. create a postgres user and set its HOME directory to/usr/local/pgsql
Groupadd-g 88 postgres
Useradd-u 88-g 88-d/usr/local/pgsql postgres
Chmod 755/usr/local/pgsql
Passwd IPVS

######################################## ##################
2. log in with the postgres user, upload the source code to its HOME directory, and then start compilation and installation:

Tar-xvf postgresql-9.3.4.tar.bz2
Cd postgresql-9.3.4
./Configure -- without-readline
Make & make install

######################################## ##################
3. initialize the database

Cd ~
Mkdir data
Chown-R postgres data
Su IPVs # use postgres users to initialize databases
Cd bin
./Initdb-D ../data-E UTF8

######################################## ##################
5. modify the configuration file

Cd ~
Vi. bash_profile
# Append the following six lines to the end of the file (first press the I key, then paste the following content, then press the insert key, and enter: wq)
Export PATH = "$ PATH":/usr/local/pgsql/bin
Export POSTGRES_HOME =/usr/local/pgsql
Export PGLIB = $ s_s_home/lib
Export PGDATA = $ s_s_home/data
Export MANPATH = "$ MANPATH": $ POSTGRES_HOME/man
Export LD_LIBRARY_PATH = "$ LD_LIBRARY_PATH": "$ PGLIB"
# Re-read
Source ~ /. Bash_profile
Verify
Echo $ s_s_home

######################################## ##################
6. open a remote client connection

 

Cd ~

Cd data

Vi postgresql. conf
Modify # listen_addresses = "localhost"
Changed to listen_addresses = "*"
Remove the comment (#) before port = 5432

Vi pg_hba.conf
Add the following in IPv4 local connections:
Host all 192.168.1.88/24 md5

######################################## ##################
7. start the database and set the super user's postgres and password

Cd ~
Cd bin
./Pg_ctl-D ../data-l logfile start
./Psql-d postgres
Alter user login S with password '123 ';
\ Q # log out of the PostgreSQL console

######################################## ##################
Note:
######################################## ##################

START database
Cd ~
Cd bin
./Pg_ctl-D ../data-l logfile start

Stop Database
Cd ~
Cd bin
./Pg_ctl stop-D ../data-w

If you cannot remotely connect to the database, disable the firewall with the root permission and try again (/etc/init. d/iptables stop)
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.