The following uses PostgreSQL9.1.2 as an example. You can also refer to the INSTALL file in the package. The steps are as follows: 1. Download the PostgreSQL source code package and put it in any directory:
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, put it in any directory http://www.postgresql.org/ftp/source/v9.1.2/
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)