Postgresql9.2 centos Installation

Source: Internet
Author: User
Tags unix domain socket

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

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

Use

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 postgres -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/datachown -R postgres /db/pgsql/data/.

# Edit path search path

VI/etc/profile Add the following two rows: Path =/usr/local/pgsql/bin: $ pathexport 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

You can enter the URL here to see the latest installation package version: http://ftp.postgresql.org/pub/source/v9.2.4/

wget http://ftp.postgresql.org/pub/source/v9.2.4/postgresql-9.2.4.tar.bz2

# Decompress the source code package

tar jxvf ./postgresql-9.2.4.tar.bz2

# Enter the decompressed source code directory

cd ./postgresql-9.2.4

# Execute the source code compilation configuration script

./configure

# Source code compilation and Installation

makemake 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 I am a hateful placeholder!

# Copy the PostgreSQL execution script

cp /usr/src/postgresql-9.2.4/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/postgresqlPGDATA="/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.conflisten_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 all md5
# IPv4 local connections:
#host all 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.