Installing the PostgreSQL database (Linux) [go]

Source: Internet
Author: User
Tags bz2 postgres database postgres db

From MARSPRJ

0. Compiling the Environment

    • Linux:centos 5.5
    • gcc:4.1.2

1. Installing PostgreSQL

1) Unzip the POSTGRESQL-9.1.7.TAR.BZ2

#tar JXVF postgresql-9.1.7.tar.bz2

2) Enter the postgresql-9.1.7 directory after decompression

#cd postgresql-9.1.7

3) Compile PostgreSQL source code

#./configure--prefix=/opt/pgsql-9.1.7

#make

#make Install

At this point, complete the installation of PostgreSQL. Enter the/opt/pgsql-9.1.7 directory to see the installed PostgreSQL files.

#ls/opt/pgsql-9.1.7

2. Create a PostgreSQL database

1) Create Postgres user

#useradd Postgres

Modify Postgres Password

#passwd Postgres

2) Set environment variables for postgres users

Switch to Postgres user

#su-postgres

Go to Postgres's home directory

#cd ~

Edit ~/.bash_profile File

#vi ~/.bash_profile

Set the following environment variables

Export pghome=/opt/pgsql-9.1.7

Export Pgdata=~/data

Save, Exit VI. Execute the following command to make the environment variable effective

#source ~/.bash_profile

3) Initialize the Postgres database

#initdb

This completes the initialization of the Postgres database.

4) Start Postgres DB instance

#pg_ctl start

You can see that the PostgreSQL DB instance has been started and you can see the postgres process running in the system by following the command

#ps-ef | grep postgres

5) Connect the PostgreSQL database

#psql-H 127.0.0.1-d postgres-u Postgres

6) Stop PostgreSQL DB instance

#pg_ctl stop

#ps-ef | grep postgres

You can see that no postgres process has been

3. Set up the PostgreSQL boot boot

PostgreSQL's boot-up script is located under the contrib/start-scripts path of the PostgreSQL source directory

The Linux file is the startup script on the Linux system

1) Modify the Linux file properties and add the X attribute

#chmod A+x Linux

2) Copy the Linux file to the/ETC/INIT.D directory and rename it to PostgreSQL

#cp Linux/etc/init.d/postgresql

3) Modify the two variables of the/etc/init.d/postgresql file

Prefix installation path set to PostgreSQL:/opt/pgsql-9.1.2

Pgdata Data Directory path set to PostgreSQL:

4) The PostgreSQL service can be started by executing service PostgreSQL start

#service PostgreSQL Start

5) Set up PostgreSQL service to boot from

#chkconfig--add PostgreSQL

Execute the above command to enable the start-up of the PostgreSQL service.

Installing the PostgreSQL database (Linux) [go]

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.