Chinaunix首页 | 论坛 | 博客
  • 博客访问: 439896
  • 博文数量: 52
  • 博客积分: 1076
  • 博客等级: 准尉
  • 技术积分: 821
  • 用 户 组: 普通用户
  • 注册时间: 2011-08-18 20:05
个人简介

Hello World !

文章分类

全部博文(52)

文章存档

2016年(1)

2014年(1)

2013年(8)

2012年(38)

2011年(4)

分类: Mysql/postgreSQL

2013-03-17 09:38:54

安装环境:redhat 6.2
posgresql-8.4  (redhat系统光盘自带) 
===========Install
[root@DataBase Packages]# ls |grep postgre
postgresql-8.4.9-1.el6_1.1.i686.rpm
postgresql-contrib-8.4.9-1.el6_1.1.i686.rpm
postgresql-devel-8.4.9-1.el6_1.1.i686.rpm
postgresql-docs-8.4.9-1.el6_1.1.i686.rpm
postgresql-jdbc-8.4.701-3.el6.i686.rpm
postgresql-libs-8.4.9-1.el6_1.1.i686.rpm
postgresql-odbc-08.04.0200-1.el6.i686.rpm
postgresql-plperl-8.4.9-1.el6_1.1.i686.rpm
postgresql-plpython-8.4.9-1.el6_1.1.i686.rpm
postgresql-pltcl-8.4.9-1.el6_1.1.i686.rpm
postgresql-server-8.4.9-1.el6_1.1.i686.rpm
postgresql-test-8.4.9-1.el6_1.1.i686.rpm
qt-postgresql-4.6.2-20.el6.i686.rpm
[root@DataBase Packages]# rpm -ivh --nodeps postgresql-*
warning: postgresql-8.4.9-1.el6_1.1.i686.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                ########################################### [100%]
   1:postgresql-libs        ########################################### [  8%]
   2:postgresql             ########################################### [ 17%]
   3:postgresql-server      ########################################### [ 25%]
   4:postgresql-plperl      ########################################### [ 33%]
   5:postgresql-plpython    ########################################### [ 42%]
   6:postgresql-pltcl       ########################################### [ 50%]
   7:postgresql-test        ########################################### [ 58%]
   8:postgresql-contrib     ########################################### [ 67%]
   9:postgresql-devel       ########################################### [ 75%]
  10:postgresql-docs        ########################################### [ 83%]
  11:postgresql-odbc        ########################################### [ 92%]
  12:postgresql-jdbc        ########################################### [100%]
/var/tmp/rpm-tmp.eLCJ5n: line 1: /usr/bin/rebuild-gcj-db: No such file or directory
[root@DataBase Packages]# service postgresql initdb
Initializing database:                                     [  OK  ]
[root@DataBase Packages]# vi /var/lib/pgsql/data/postgresql.conf
# - Connection Settings -

listen_addresses = '*'          # what IP address(es) to listen on;
                                        # comma-separated list of addresses;
                                        # defaults to 'localhost', '*' = all
                                        # (change requires restart)
port = 5432                             # (change requires restart)
max_connections = 100                   # (change requires restart)
[root@DataBase Packages]# vi /var/lib/pgsql/data/pg_hba.conf
# IPv4 local connections:
host    all         all         0.0.0.0/0          md5
[root@DataBase Packages]# su postgres
bash-4.1$ psql
psql: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
bash-4.1$ service postgresql status
postmaster is stopped
bash-4.1$ service postgresql start
Starting postgresql service: /etc/init.d/postgresql: line 114: echo: write error: Permission denied
touch: cannot touch `/var/lock/subsys/postgresql': Permission denied
/etc/init.d/postgresql: line 122: /var/run/postmaster.5432.pid: Permission denied

bash-4.1$ exit
exit
[root@DataBase Packages]#  service postgresql start
Starting postgresql service:                               [  OK  ]
[root@DataBase Packages]# su postgres
bash-4.1$ psql
psql (8.4.9)
Type "help" for help.

postgres=# ALTER USER postgres WITH PASSWORD 'postgres01';
ALTER ROLE
postgres=# \q
bash-4.1$ exit
exit
[root@DataBase Packages]# service postgresql restart
Stopping postgresql service:                               [  OK  ]
Starting postgresql service:                               [  OK  ]


开机自启动
[root@DataBase Packages]# chkconfig --list|grep postgresql
[root@DataBase Packages]# chkconfig --add postgresql
[root@DataBase Packages]# chkconfig --list|grep postgresql
postgresql      0:off   1:off   2:off   3:off   4:off   5:off   6:off
[root@DataBase Packages]# chkconfig --level 2 postgresql on
[root@DataBase Packages]# chkconfig --level 3 postgresql on
[root@DataBase Packages]# chkconfig --level 4 postgresql on
[root@DataBase Packages]# chkconfig --level 5 postgresql on
[root@DataBase Packages]#  chkconfig --list|grep postgresql
postgresql      0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@DataBase Packages]# chkconfig --level 1 postgresql on
[root@DataBase Packages]#  chkconfig --list|grep postgresql
postgresql      0:off   1:on    2:on    3:on    4:on    5:on    6:off
[root@DataBase Packages]#


修改Postgresql端口
[root@DataBase data]# vi /var/lib/pgsql/data/postgresql.conf
# - Connection Settings -

listen_addresses = '*'          # what IP address(es) to listen on;
                                        # comma-separated list of addresses;
                                        # defaults to 'localhost', '*' = all
                                        # (change requires restart)
port = 5555                             # (change requires restart)
max_connections = 100                   # (change requires restart)
[root@DataBase data]# vi /etc/init.d/postgresql
# Set defaults for configuration variables
PGENGINE=/usr/bin
PGPORT=5555
[root@DataBase data]# service postgresql restart
Stopping postgresql service:                               [  OK  ]
Starting postgresql service:                               [  OK  ]
[root@DataBase Packages]# ps -ef|grep postgres
postgres  2812     1  0 09:08 ?        00:00:00 /usr/bin/postmaster -p 5555 -D /var/lib/pgsql/data
postgres  2814  2812  0 09:08 ?        00:00:00 postgres: logger process
postgres  2816  2812  0 09:08 ?        00:00:00 postgres: writer process
postgres  2817  2812  0 09:08 ?        00:00:00 postgres: wal writer process
postgres  2818  2812  0 09:08 ?        00:00:00 postgres: autovacuum launcher process
postgres  2819  2812  0 09:08 ?        00:00:00 postgres: stats collector process
postgres  2823  2812  0 09:09 ?        00:00:00 postgres: postgres postgres 192.168.1.100(63643) idle
root     21493  1393  0 09:20 pts/0    00:00:00 grep postgres
[root@DataBase data]# su postgres
bash-4.1$ psql -p 5555
psql (8.4.9)
Type "help" for help.

postgres=# CREATE ROLE demo LOGIN
postgres-# PASSWORD 'demo'
postgres-#  SUPERUSER INHERIT NOCREATEDB NOCREATEROLE;
CREATE ROLE
postgres=# CREATE DATABASE HelloVillage
postgres-# WITH OWNER = postgres
postgres-#        ENCODING = 'UTF8'
postgres-#        TABLESPACE = pg_default
postgres-#        LC_COLLATE = 'en_US.UTF-8'
postgres-#        LC_CTYPE = 'en_US.UTF-8'
postgres-#   CONNECTION LIMIT = 100;
CREATE DATABASE
postgres=# \l
                                   List of databases
     Name     |  Owner   | Encoding |  Collation  |    Ctype    |   Access privileges
--------------+----------+----------+-------------+-------------+-----------------------
 hellovillage | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 postgres     | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 template0    | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
                                                                : postgres=CTc/postgres
 template1    | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
                                                                : postgres=CTc/postgres
(4 rows)

postgres=#


===========Unistall
[root@DataBase Packages]# rpm -qa|grep post
postgresql-server-8.4.9-1.el6_1.1.i686
postgresql-test-8.4.9-1.el6_1.1.i686
postgresql-odbc-08.04.0200-1.el6.i686
postgresql-8.4.9-1.el6_1.1.i686
postgresql-plperl-8.4.9-1.el6_1.1.i686
postgresql-pltcl-8.4.9-1.el6_1.1.i686
postgresql-contrib-8.4.9-1.el6_1.1.i686
postgresql-docs-8.4.9-1.el6_1.1.i686
postgresql-jdbc-8.4.701-3.el6.i686
postgresql-libs-8.4.9-1.el6_1.1.i686
postgresql-plpython-8.4.9-1.el6_1.1.i686
postgresql-devel-8.4.9-1.el6_1.1.i686
postfix-2.6.6-2.2.el6_1.i686
[root@DataBase Packages]# rpm -e postgresql-test-8.4.9-1.el6_1.1.i686
[root@DataBase Packages]# rpm -e postgresql-devel-8.4.9-1.el6_1.1.i686
[root@DataBase Packages]# rpm -e postgresql-plpython-8.4.9-1.el6_1.1.i686
[root@DataBase Packages]# rpm -e postgresql-jdbc-8.4.701-3.el6.i686
/var/tmp/rpm-tmp.ATvJQn: line 1: /usr/bin/rebuild-gcj-db: No such file or directory
[root@DataBase Packages]# rpm -e postgresql-docs-8.4.9-1.el6_1.1.i686
[root@DataBase Packages]# rpm -e postgresql-contrib-8.4.9-1.el6_1.1.i686
[root@DataBase Packages]# rpm -e postgresql-pltcl-8.4.9-1.el6_1.1.i686
[root@DataBase Packages]# rpm -e postgresql-plperl-8.4.9-1.el6_1.1.i686
[root@DataBase Packages]# rpm -e postgresql-odbc-08.04.0200-1.el6.i686
[root@DataBase Packages]# rpm -e postgresql-server-8.4.9-1.el6_1.1.i686
[root@DataBase Packages]# rpm -e postgresql-8.4.9-1.el6_1.1.i686
[root@DataBase Packages]# rpm -e postgresql-libs-8.4.9-1.el6_1.1.i686

rpm -e postgresql-test-8.4.9-1.el6_1.1.i686
rpm -e postgresql-devel-8.4.9-1.el6_1.1.i686
rpm -e postgresql-plpython-8.4.9-1.el6_1.1.i686
rpm -e postgresql-jdbc-8.4.701-3.el6.i686
rpm -e postgresql-docs-8.4.9-1.el6_1.1.i686
rpm -e postgresql-contrib-8.4.9-1.el6_1.1.i686
rpm -e postgresql-pltcl-8.4.9-1.el6_1.1.i686
rpm -e postgresql-plperl-8.4.9-1.el6_1.1.i686
rpm -e postgresql-odbc-08.04.0200-1.el6.i686
rpm -e postgresql-server-8.4.9-1.el6_1.1.i686
rpm -e postgresql-8.4.9-1.el6_1.1.i686
rpm -e postgresql-libs-8.4.9-1.el6_1.1.i686

阅读(7100) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~