Readline is an open-source cross-platform library that provides interactive text editing. Postgresql requires readline support.
Https://ftp.postgresql.org/pub/source/v9.3.5/postgresql-9.3.5.tar.gz wget-c
[Root @ rootop postgresql-9.3.5] # yum install readline-devel
[Root @ rootop postgresql-9.3.5] #./configure -- prefix =/usr/local/pgsql
[Root @ rootop postgresql-9.3.5] # make
[Root @ rootop postgresql-9.3.5] # make install
Add a system account:
[Root @ rootop ~] # Useradd S
[Root @ rootop ~] # Passwd IPVS
Create a data directory:
[Root @ rootop ~] # Mkdir/usr/local/pgsql/data
[Root @ rootop ~] # Chown postgres: postgres/usr/local/pgsql/data/
Initialize the database:
[Root @ rootop ~] # Su postgres # switch to postgres for user execution
[S @ rootop ~] $/Usr/local/pgsql/bin/initdb-D/usr/local/pgsql/data/
You can use/usr/local/pgsql/bin/postgres-D/usr/local/pgsql/data/
OR/usr/local/pgsql/bin/pg_ctl-D/usr/local/pgsql/data/-l logfile start to start the service.
It is recommended that the following script start method listen to Port 5432 on tcp after it is started.
[S @ rootop ~] $ Lsof-I: 5432
Command pid user fd type device size/OFF NODE NAME
IPVS 5140 IPVs 3u IPv4 2394876345 0t0 TCP localhost: IPVS (LISTEN)
Copy the management script (root operation ):
[Root @ rootop postgresql-9.3.5] # cp contrib/start-scripts/linux/etc/init. d/postgresql
[Root @ rootop postgresql-9.3.5] # chmod o + x/etc/init. d/postgresql
Edit the startup script. Note the following information:
# Installation path
Prefix =/usr/local/pgsql
# Data Directory
PGDATA = "/usr/local/pgsql/data"
# Start a user
PGUSER = postgres
# Log path
PGLOG = "$ PGDATA/serverlog"
Then, you can manage it through service postgresql start | stop | restart | reload | status.
Start startup:
[Root @ AY131126202614070132Z ~] # Chkconfig postgresql on
Related configuration files:
You can configure the listening address, port, and number of connections through/usr/local/pgsql/data/postgresql. conf.
Listen_addresses =
Port =
Max_connections =
You can use/usr/local/pgsql/data/pg_assist.conf to configure the addresses that allow remote connection.
Host all 127.0.0.1/32 trust
Log on to the database:
[Root @ AY131126202614070132Z ~] #/Usr/local/pgsql/bin/psql-h 127.0.0.1-d postgres-U postgres
Psql (9.3.5)
Type "help" for help.
S = # \ l # View existing databases
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
----------- + ---------- + ------------- + -----------------------
Postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
Template0 | postgres | UTF8 | en_US.UTF-8 | = c/postgres +
| Postgres = CTc/postgres
Template1 | postgres | UTF8 | en_US.UTF-8 | = c/postgres +
| Postgres = CTc/postgres
(3 rows)
S = # \ q # exit
Parameters supported by psql can be obtained through/usr/local/pgsql/bin/psql -- help.
Installation is complete.