Source installation of PostgreSQL database under Linux

Source: Internet
Author: User
Tags postgresql readline

Lab Environment >>>>>>>>>>>>>>>>>>
Operating system: CentOS release 6.3 (Final)
Database version: PostgreSQL 9.3.5

The dependency on installing PostgreSQL has

A, requires a iso/ansic compiler (at least compatible with C89).

B. GNU make is required and other make programs are not available.

C, the GNU ReadLine Library is automatically used by default. requires ReadLine and readline-devel of two packages.

D, the default is to use the Zlib compression library. requires zlib and zlib-devel of two packages.

Where readline can easily edit and retrieve command history, the Zlib library enables pg_dump and Pg_restore compressed archive support.

If you do not need to use C and D dependencies, you can use the --without-readline and --without-zlib options when compiling. The specific installation method is as follows:

1. The dependency required to install PostgreSQL.

[[email protected]5201351 ~]# yum install gcc make-y[[email protected]5201351

2. Extract the PostgreSQL source package and enter the decompression directory. Execute the following command in turn:

[Email protected]5201351 postgresql-9.3. 5] #./Configure[[email protected]5201351 postgresql-9.3. 5  Make [email protected]5201351 postgresql-9.3. 5  Make Install

3. Create the user name and directory for the database service, and the permission settings.

[Email protected]5201351 postgresql-9.3. 5 ]# useradd postgres[[email protected]5201351 postgresql-9.3. 5 mkdir /usr/local/pgsql/data                    // CREATE database directory [[email protected]5201351 postgresql-9.3. 5 chown postgres/usr/local/pgsql/data           // Change the owner of the database directory

4. Switch to the Postgres user to edit the ~/.bash_profile file and add the directory of the database execution command to the PATH variable.

Path= $PATH: $HOME/bin:/usr/local/pgsql/bin     // Modify the PATH variable of the ~/.bash_profile file one line, modify and use the source to make it effective immediately, You can also log in again. 

5. Initialize and start the database.

[[email protected]5201351 ~]$ initdb-d/usr/local/pgsql/data                          // Initialize PostgreSQL database [[ Email protected]52013512>&1 &        // start PostgreSQL database 

After the installation is complete, the default configuration for postgresql.conf is as follows:

If we need to stop the PostgreSQL service, we can use the following command:

[Email protected]5201351 ~]$ pg_ctl stop-d/usr/local/pgsql/data

We can also copy the contrib/start-scripts/linux startup script file from the source bundle into the/ETC/INIT.D directory and name it postgresql-9.3.

You can start it later as you would any other service, or you can add it to boot. In general this script we may need to modify the options as shown in:

Finally, we add the postgresql-9.3 to the boot entry and can use the following command:

[Email protected]5201351 postgresql-9.3 on

Source installation of PostgreSQL database under Linux

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.