RedHat5.5 install PostgreSQL

Source: Internet
Author: User
The following uses PostgreSQL9.1.2 as an example. You can also refer to the INSTALL file in the package. The procedure is as follows:

The following uses PostgreSQL 9.1.2 as an example. You can also refer to the INSTALL file in the package. The procedure is as follows:

The following uses PostgreSQL 9.1.2 as an example. You can also refer to the INSTALL file in the package. The procedure is as follows:

1. Download the PostgreSQL source code package and place it in any directory

2. decompress the file

# Tar zxvf postgresql-9.1.2.tar.gz

# Cd postgresql-9.1.2

3. Configuration:

#./Configure -- prefix =/usr/local/pgsql

4. Compile:

# Make

5. installation:

# Make install

6. Create a postgresql user group and user:

# Groupadd S

# Useradd-g postgres

7. Create a database file storage directory and grant the permission to the postgresql user

# Mkdir/usr/local/pgsql/data

# Cd/usr/local/pgsql

# Chown-R postgres. postgres data

8. Set Environment Variables

# Vi/etc/profile

Export PATH = $ PATH:/usr/local/pgsql/bin

Export MANPATH = $ MANPATH:/usr/local/pgsql/man

Export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/local/pgsql/lib

Add the above information at the end of the file, save and exit.

9. initialize the database and start the database.

# Su-postgres

# Initdb-D/usr/local/pgsql/data

Now you can start the database.

# Pg_ctl-D/usr/local/pgsql/data-l/usr/local/pgsql/data/pgsql. logstart

"Server starting" prompt"

Then we run the process to check whether the service has been started:

# Ps-A | grep postgres

10. Configure the listening address and port:
# Vi/usr/local/pgsql/data/postgresql. conf

Listen_addresses = '*' # cancel the comment of the row and set the value in single quotes *

Port = 5432 # cancel comments of this row

11. Configure to allow remote connection:

# Vi/usr/local/pgsql/data/pg_assist.conf

Add

Hostall all 192.168.1.0/24 trust

Or

Hostall all samenet trust

Each entry in the configuration file is described in detail. For more information, see click to open the link.

# Perform the following operations to obtain root user permissions by su root:

12. Configure iptables to allow remote host access:

# Vi/etc/sysconfig/iptables-config

Add

-ARH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 5432-j ACCEPT

Restart the iptables service


# Service iptables restart

13. Start the postgresql database with the system startup:

Copy the startup script to the/etc/init. d/directory from the installation file directory extracted in step 1. Execute the following command:

# Cd/etc/rc. d/init. d

# Cp/postgresql-9.1.2/contrib/start-scripts/linuxpostgresql

# Chmod + x postgresql

# Chkconfig -- add postgresql

Start the database:

# Service postgresql start

The configuration is complete.

Appendix: For my projects, use postgresql as follows:

1. Use securecrt and telnet to log on to the host with postgresql

2. type the command su root to obtain root user permissions.

3. type the postgres user identity obtained by the command su-postgres.

4. type the command psql to use the default database postgres (user-created database)

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.