一个服务器安装多个postgresql

下载 postgresql94-libs-9.4.4-1PGDG.rhel6.x86_64.rpm
      postgresql94-9.4.4-1PGDG.rhel6.x86_64.rpm
      postgresql94-server-9.4.4-1PGDG.rhel6.x86_64.rpm
      postgresql94-contrib-9.4.4-1PGDG.rhel6.x86_64.rpm

1、 依次安装
[root@localhost upload]# rpm -ivh postgresql94-libs-9.4.4-1PGDG.rhel6.x86_64.rpm
警告:postgresql94-libs-9.4.4-1PGDG.rhel6.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 442df0f8: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:postgresql94-libs-9.4.4-1PGDG.rhe################################# [100%]
[root@localhost upload]# rpm -ivh postgresql94-9.4.4-1PGDG.rhel6.x86_64.rpm
警告:postgresql94-9.4.4-1PGDG.rhel6.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 442df0f8: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:postgresql94-9.4.4-1PGDG.rhel6   ################################# [100%]
[root@localhost upload]# rpm -ivh postgresql94-server-9.4.4-1PGDG.rhel6.x86_64.rpm
警告:postgresql94-server-9.4.4-1PGDG.rhel6.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 442df0f8: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:postgresql94-server-9.4.4-1PGDG.r################################# [100%]
[root@localhost upload]# rpm -ivh postgresql94-contrib-9.4.4-1PGDG.rhel6.x86_64.rpm
警告:postgresql94-contrib-9.4.4-1PGDG.rhel6.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 442df0f8: NOKEY
错误:依赖检测失败:
        libxslt.so.1()(64bit) 被 postgresql94-contrib-9.4.4-1PGDG.rhel6.x86_64 需要
        libxslt.so.1(LIBXML2_1.0.11)(64bit) 被 postgresql94-contrib-9.4.4-1PGDG.rhel6.x86_64 需要
        libxslt.so.1(LIBXML2_1.0.18)(64bit) 被 postgresql94-contrib-9.4.4-1PGDG.rhel6.x86_64 需要
        libxslt.so.1(LIBXML2_1.0.22)(64bit) 被 postgresql94-contrib-9.4.4-1PGDG.rhel6.x86_64 需要

有依赖关系,用yum安装
[root@localhost upload]# yum install libxslt
已加载插件:fastestmirror
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
12: Timeout on http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
base                                                                                                                                                                            


                                      | 3.6 kB  00:00:00     
extras                                                                                                                                                                          


                                      | 3.4 kB  00:00:00     
updates                                                                                                                                                                         


                                      | 3.4 kB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: mirrors.cn99.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 libxslt.x86_64.0.1.1.28-5.el7 将被 安装
--> 解决依赖关系完成


依赖关系解决


===============================================================================================================================================================================


==============================================================
 Package                                                  架构                                                    版本                                                          


 源                                                     大小
===============================================================================================================================================================================


==============================================================
正在安装:
 libxslt                                                  x86_64                                                  1.1.28-5.el7                                                  


 base                                                  242 k


事务概要
===============================================================================================================================================================================


==============================================================
安装  1 软件包


总下载量:242 k
安装大小:486 k
Is this ok [y/d/N]: y
Downloading packages:
libxslt-1.1.28-5.el7.x86_64.rpm                                                                                                                                                 


                                      | 242 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
  正在安装    : libxslt-1.1.28-5.el7.x86_64                                                                                                                                     


                                                         1/1 
  验证中      : libxslt-1.1.28-5.el7.x86_64                                                                                                                                     


                                                         1/1 


已安装:
  libxslt.x86_64 0:1.1.28-5.el7                                                                                                                                                 


                                                             


完毕!
[root@localhost upload]# rpm -ivh postgresql94-contrib-9.4.4-1PGDG.rhel6.x86_64.rpm
警告:postgresql94-contrib-9.4.4-1PGDG.rhel6.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 442df0f8: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:postgresql94-contrib-9.4.4-1PGDG.################################# [100%]

2、初始化DB
[root@localhost upload]su - postgres
[postgres@localhost ~]$/usr/pgsql-9.4/bin/initdb -D /var/lib/pgsql/9.4/data   (此处不建议放在根目录下)

3、启动DB

[postgres@localhost ~]$/usr/pgsql-9.4/bin/pg_ctl -D /var/lib/pgsql/9.4/data -l logfile start

进入postgresql
[postgres@localhost ~]psql
psql (9.4.4)
输入 "help" 来获取帮助信息.
postgres=# \l
                                     资料库列表
   名称    |  拥有者  | 字元编码 |  校对规则   |    Ctype    |       存取权限        
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | 
 template0 | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(3 行记录)

安装成功

4、创建第二个实例
[postgres@localhost ~]$/usr/pgsql-9.4/bin/initdb -D /var/lib/pgsql/9.4/data1

5、修改第二个实例的端口

[postgres@localhost ~]cd /var/lib/pgsql/9.4/data1
[postgres@localhost data1]$ls
base    pg_clog      pg_hba.conf    pg_logical    pg_notify    pg_serial     pg_stat      pg_subtrans  pg_twophase  pg_xlog               postgresql.conf
global  pg_dynshmem  pg_ident.conf  pg_multixact  pg_replslot  pg_snapshots  pg_stat_tmp  pg_tblspc    PG_VERSION   postgresql.auto.conf
[postgres@localhost data1]$vi postgresql.conf
port = 8801


 
6、启动第二个实例
[postgres@localhost data1]$/usr/pgsql-9.4/bin/pg_ctl -D /var/lib/pgsql/9.4/data1 -l logfile start
进入第二实例
[postgres@localhost data1]$psql -p 8801     --记得带上端口号,不然默认5432端口
psql (9.4.4)
输入 "help" 来获取帮助信息.
postgres=# \l
                                     资料库列表
   名称    |  拥有者  | 字元编码 |  校对规则   |    Ctype    |       存取权限        
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | 
 template0 | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(3 行记录)


7、查看实例进程
[postgres@localhost 9.4]$netstat -anpt|grep postgre
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN      15425/postgres      
tcp        0      0 127.0.0.1:8801          0.0.0.0:*               LISTEN      15435/postgres      
tcp6       0      0 :::5432                 :::*                    LISTEN      15425/postgres      
tcp6       0      0 ::1:8801                :::*                    LISTEN      15435/postgres  

[postgres@localhost 9.4]$ps -ef |grep /usr/pgsql-9.4/bin/postgres
postgres  15425      1  0 17:14 pts/5    00:00:00 /usr/pgsql-9.4/bin/postgres -D /var/lib/pgsql/9.4/data
postgres  15435      1  0 17:14 pts/5    00:00:00 /usr/pgsql-9.4/bin/postgres -D /var/lib/pgsql/9.4/data1



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29989552/viewspace-2128880/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29989552/viewspace-2128880/

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值