0
[Email protected] ~]# uname-a
Linux pghost 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 03:15:09 UTC x86_64 x86_64 x86_64 gnu/linux
[Email protected] ~]# cat/etc/issue
CentOS Release 6.5 (Final)
Kernel \ r on an \m
1
Yum-y Install ReadLine readline-devel zlib zlib-devel OpenSSL openssl-devel pam-devel libxml2-devel libxslt-devel python- Devel tcl-devel gcc make Flex Bison perl perl-devel perl-extutils*
2
Useradd Postgres
3
Vi/home/postgres/.bash_profile
Export pgport=5432
Export Pgdata=/opt/pgsql9.3.4/pgdata
Export Lang=en_us.utf8
Export Pghome=/opt/pgsql
Export ld_library_path= $PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib: $LD _library_ PATH
Export path= $PGHOME/bin: $PATH:.
Export manpath= $PGHOME/share/man: $MANPATH
Export Pguser=postgres
Export pghost= $PGDATA
4
[Email protected] ~]# cd/root/backup/
[email protected] backup]# LL
Total 21356
-rw-r--r--. 1 root root 21865589 Sep 7 09:21 postgresql-9.3.4.tar.gz
[Email protected] backup]# TAR-ZXVF postgresql-9.3.4.tar.gz
[email protected] backup]# LL
Total 21360
Drwxrwxrwx. 6 1107 1107 4096 Mar postgresql-9.3.4
5
[Email protected] backup]# CD postgresql-9.3.4
[Email protected] postgresql-9.3.4]#/configure--prefix=/opt/pgsql9.3.4--with-pgport=5432--with-perl--WITH-TCL- -with-python--with-openssl--with-pam--without-ldap--with-libxml--with-libxslt--enable-thread-safety-- With-wal-blocksize=8--with-blocksize=8 && Gmake World
...
...
GMAKE[2]: Leaving directory '/ROOT/BACKUP/POSTGRESQL-9.3.4/CONTRIB/XML2 '
GMAKE[1]: Leaving directory '/root/backup/postgresql-9.3.4/contrib '
PostgreSQL, contrib, and documentation successfully made. Ready to install.
[Email protected] postgresql-9.3.4]#
[email protected] postgresql-9.3.4]# LL
Total 1448
-rw-r--r--. 1 root root 359981 Sep 17:26 config.log
-rwxr-xr-x. 1 root root 39791 Sep 17:26 config.status
-rw-r--r--. 1 root root 3618 Sep 17:26 gnumakefile
Drwxrwxrwx. 1107 1107 4096 Sep 17:26 src
6
[Email protected] postgresql-9.3.4]# gmake Install-world
...
...
GMAKE[2]: Leaving directory '/ROOT/BACKUP/POSTGRESQL-9.3.4/CONTRIB/XML2 '
GMAKE[1]: Leaving directory '/root/backup/postgresql-9.3.4/contrib '
PostgreSQL, contrib, and documentation installation complete.
[Email protected] postgresql-9.3.4]#
7
[Email protected] postgresql-9.3.4]# ll/opt/
Total 8
Drwxr-xr-x. 6 root root 4096 Sep 17:31 pgsql9.3.4
Drwxr-xr-x. 2 root root 4096 Nov RH
[Email protected] postgresql-9.3.4]# ln-s/opt/pgsql9.3.4/opt/pgsql
[Email protected] postgresql-9.3.4]# ll/opt/
Total 8
lrwxrwxrwx. 1 root root Sep 17:33 Pgsql-/opt/pgsql9.3.4
Drwxr-xr-x. 6 root root 4096 Sep 17:31 pgsql9.3.4
Drwxr-xr-x. 2 root root 4096 Nov RH
[Email protected] postgresql-9.3.4]#
[Email protected] postgresql-9.3.4]# ll/opt/pgsql9.3.4/
Total 16
Drwxr-xr-x. 2 root root 4096 Sep 17:31 bin
Drwxr-xr-x. 6 root root 4096 Sep 17:31 include
Drwxr-xr-x. 4 root root 4096 Sep 17:31 Lib
Drwxr-xr-x. 8 root root 4096 Sep 17:31 share
8
[Email protected] ~]# chown-r root:daemon/opt/pgsql9.3.4/
[Email protected] ~]# ll/opt/
Total 8
lrwxrwxrwx. 1 root root Sep 17:33 Pgsql-/opt/pgsql9.3.4
Drwxr-xr-x. 6 root daemon 4096 Sep 17:31 pgsql9.3.4
Drwxr-xr-x. 2 root root 4096 Nov RH
[Email protected] ~]# ll/opt/pgsql9.3.4/
Total 16
Drwxr-xr-x. 2 root daemon 4096 Sep 17:31 bin
Drwxr-xr-x. 6 root daemon 4096 Sep 17:31 include
Drwxr-xr-x. 4 root daemon 4096 Sep 17:31 Lib
Drwxr-xr-x. 8 root daemon 4096 Sep 17:31 share
9
[Email protected] pgsql9.3.4]# mkdir pgdata
[Email protected] pgsql9.3.4]# chown postgres:postgres pgdata/
[email protected] pgsql9.3.4]# LL
Total 20
Drwxr-xr-x. 2 root daemon 4096 Sep 17:31 bin
Drwxr-xr-x. 6 root daemon 4096 Sep 17:31 include
Drwxr-xr-x. 4 root daemon 4096 Sep 17:31 Lib
Drwxr-xr-x. 2 postgres postgres 4096 Sep 17:48 pgdata
Drwxr-xr-x. 8 root daemon 4096 Sep 17:31 share
10
[Email protected] postgresql-9.3.4]# Su-postgres
[Email protected] ~]$ initdb-d $PGDATA-e UTF8--locale=c-u postgres-w
...
...
Syncing data to disk ... ok
Warning:enabling "Trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option-a, or
--auth-local and--auth-host, the next time you run INITDB.
Success. You can now start the database server using:
Postgres-d/opt/pgsql9.3.4/pgdata
Or
pg_ctl-d/opt/pgsql9.3.4/pgdata-l logfile Start
[Email protected] ~]$
11
[email protected] opt]# ll pgsql9.3.4/
Total 20
Drwxr-xr-x. 2 root daemon 4096 Sep 17:31 bin
Drwxr-xr-x. 6 root daemon 4096 Sep 17:31 include
Drwxr-xr-x. 4 root daemon 4096 Sep 17:31 Lib
DRWX------. Postgres postgres 4096 Sep 11:51 pgdata
Drwxr-xr-x. 8 root daemon 4096 Sep 17:31 share
12
[Email protected] opt]# VI pgsql9.3.4/pgdata/pg_hba.conf
# IPV4 Local connections:
Host All 0.0.0.0/0 MD5
13
[Email protected] opt]# VI pgsql9.3.4/pgdata/postgresql.conf
listen_addresses = ' * '
#listen_addresses = ' localhost '
unix_socket_directories = '. '
#unix_socket_directories = '/tmp '
Unix_socket_permissions = 0700
#unix_socket_permissions = 0777
14
[Email protected] ~]$ pg_ctl-d/opt/pgsql9.3.4/pgdata/-l/opt/pgsql9.3.4/pgdata/pg_log/startup.log start
Server starting
[Email protected] ~]$
[Email protected] ~]$ Ps-ef | grep postgres
Postgres 33829 1 0 15:26 pts/1 00:00:00/opt/pgsql9.3.4/bin/postgres-d/opt/pgsql9.3.4/pgdata
Postgres 33831 33829 0 15:26? 00:00:00 Postgres:checkpointer Process
Postgres 33832 33829 0 15:26? 00:00:00 Postgres:writer Process
Postgres 33833 33829 0 15:26? 00:00:00 Postgres:wal Writer Process
Postgres 33834 33829 0 15:26? 00:00:00 postgres:autovacuum Launcher Process
Postgres 33835 33829 0 15:26? 00:00:00 postgres:stats Collector Process
[Email protected] ~]$
15
[Email protected] ~]# Vi/etc/sysconfig/iptables
-A input-m state--state new-m tcp-p TCP--dport 5432-j ACCEPT
[Email protected] ~]#/etc/init.d/iptables restart
16
[Email protected] ~]#/opt/postgresql/9.3/bin/psql-h 192.168.19.77-upostgres
Password for user postgres:
Psql.bin (9.3.5, Server 9.3.4)
Type ' help ' for help.
postgres=#
Reference: http://www.postgresql.org/docs/9.3/interactive/tutorial-install.html
-----------------
Reprint Please specify the Source:
Blog.csdn.net/beiigang
Source Installation postgresql934