Install PostgreSQL 9.2.3 from centos 6.3 minimal source code

Source: Internet
Author: User
Tags unix domain socket

Environment: centos 6.3 minimizes the default installation and configures the NIC.

Before installing PostgreSQL, check that the Internet connection is normal to download the installation file.

Use the Yum-y update command to upgrade the system to the latest version.

This installation separates the data file of postgresql from the execution file. If you want to set a different path, modify the corresponding execution command and database initialization script.

# Modify firewall settings and open port 5432
VI/etc/sysconfig/iptables
-A input-M state -- state new-m tcp-p tcp -- dport 5432-J accept

# Restart the firewall to make the new settings take effect
Service iptables restart

# New User Group
Groupadd Postgres

# Add a user
Useradd S-G Postgres

# Create a database execution file directory
Mkdir-P/usr/local/pgsql

# Creating a database data file directory
Mkdir-P/DB/pgsql/Data

# Modifying directory owner
Chown-r Postgres/usr/local/pgsql /.
Chown-r Postgres/DB/pgsql/Data
Chown-r Postgres/DB/pgsql/data /.

# Edit path search path
VI/etc/profile
Append these 2 lines to the end of the file:
Path =/usr/local/pgsql/bin: $ path
Export path

# Effective path search path
Source/etc/profile

# Install the tools and libraries required for compiling source code
Yum-y install wget GCC Readline-devel zlib-devel make

# Go To The Source Code compressed package download directory
CD/usr/src

# Download the source code compressed package
Wget http://ftp.postgresql.org/pub/source/v9.2.3/postgresql-9.2.3.tar.bz2

# Decompress the source code package
Tar jxvf./postgresql-9.2.3.tar.bz2

# Enter the decompressed source code directory
CD./postgresql-9.2.3

# Execute the source code compilation configuration script
./Configure

# Compile source code
Make

# Installation
Make install

# Change logon user
Su-Postgres

# Execute the database Initialization Script
/Usr/local/pgsql/bin/initdb -- encoding = utf8-D/DB/pgsql/Data

# Exit change Logon
Exit

# Copy the PostgreSQL execution script
CP/usr/src/postgresql-9.2.3/contrib/start-scripts/Linux/etc/init. d/PostgreSQL

# Add execution permission
Chmod + x/etc/init. d/PostgreSQL

# Edit the PostgreSQL execution script to specify the database file directory
VI/etc/init. d/PostgreSQL
Pgdata = "/DB/pgsql/Data"

# Edit the configuration file to configure the network address for database access
(Do not forget to remove # listen_addresses = previous #)

VI/DB/pgsql/data/PostgreSQL. conf
Listen_addresses = '*'

# Start the postgresql service
Service PostgreSQL start

# Log on to the database as the Postgres user and modify the Postgres user's Database Password
Psql-u Postgres
S = # alter user Postgres password '123 ';
Postgres = # \ q

# Edit the configuration file and set the password for MD5 Verification
VI/DB/pgsql/data/pg_hba.conf
# "Local" is for Unix domain socket connections only
Local all MD5
# IPv4 local connections:
# Host all 127.0.0.1/32 Trust
Host All all 0.0.0.0/0 MD5

# Restart the Database Service
Service PostgreSQL restart

# Set automatic start of service upon startup
Chkconfig PostgreSQL on

 

 

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.