Running multiple PostgreSQL 9.2 Instances on one server in CentOS 6/RHEL 6/Fedora

原帖网站速度很慢,故转帖在此

This post describes how to run multiple PostgreSQL 9.2 Instances on one server in CentOS 6/RHEL 6/Fedora flavors. I am assuming that you have a running postgresql engine on the server already. If not check this post on how to install postgresql server that I wrote earlier and install the first/main instance. Now that you have a running database engine(I will call it first instance) you can start slicing second instance on the same server. As most of my posts I will divide this post into multiple steps for easier understanding and implementation.

    1. Create new data directories for this second instance and let postgres user own them
mkdir /var/lib/pgsql/9.2/data2
chown postgres.postgres /var/lib/pgsql/9.2/data2

    2. Create new init script for this instance and edit it

Copy the init script from first instance and rename it to postgresql2-9.2 and edit it for making changes that reflect the new data directory that we created in the above step.

cp /etc/init.d/postgresql-9.2/etc/init.d/postgresql2-9.2
vi /etc/init.d/postgresql2-9.2


modify the following lines as shown below:

73# Set defaults for configuration variables
74 PGENGINE=/usr/pgsql-9.2/bin
75 PGPORT=5433
76 PGDATA=/var/lib/pgsql/9.2/data2
77 PGLOG=/var/lib/pgsql/9.2/pgstartup2.log
78# Log file for pg_upgrade
79 PGUPLOG=/var/lib/pgsql/$PGMAJORVERSION/pgupgrade2.log
80
81 lockfile="/var/lock/subsys/${NAME}"
82 pidfile="/var/run/postmaster2-9.2.pid"

I have updated PGPORT, PGDATA, PGLOG, PGUPLOG, pidfile variables specific to this new instance. You can subscript to what ever you like. I am currently sub-scripting all file names with 2. Also you can use what ever open port you want this new server instance to run on.

    3. Initialize and start this new postgres instance
service postgresql2-9.2 initdb
service postgresql2-9.2 start

    4. Update configs : pg_hba.conf and postgresql.conf

Update the listen address and port variable values to reflect to what they actually should be.

vi /var/lib/pgsql/9.2/data2/postgresql.conf
57# - Connection Settings -
58
59 listen_addresses ='*'# what IP address(es) to listen on;
60# comma-separated list of addresses;
61# defaults to 'localhost'; use '*' for all
62# (change requires restart)
63 port =5433# (change requires restart)

Update pg_hba.conf to your needs. Please check my other post that I have link up on how to install postgresql 9.2 which have a bit more description on ph_hba conf file.

    5. Test connect and add this new instance service to server startup

Connect to this new instance, and see if you can connect, create a user and do what ever you want there.

su postgres
psql -p5433 -dpostgres

And here is how you add it to server startup list :

chkconfig --add postgresql2-9.2 
chkconfig postgresql2-9.2--level 2345 on

Thats all folks you have a new shiny postgres instance running on the same server as main instance. You can slice as many instances as you want as long as you have enough memory and processors on this server. Open up this port in iptables to access it from outside the server if needed.

If you happen to have any issues are stuck in the process, please feel free to email me or post in comments.

【转帖】如何在redhat单机服务器上运行postgresql的多个实例(howto run multiple postgresql instance on one redhat server)的更多相关文章

  1. 如何在Ubuntu的idea上运行Hadoop程序

    如何在Ubuntu的idea上运行Hadoop程序 一.前言 在idea上运行Hadoop程序,需要使用Hadoop的相关库,Ubuntu为Hadoop的运行提供了良好的支持. 二.操作方法 首先我们 ...

  2. 将 java 项目打包成可运行的 jar 包(main 函数带参数),并上传到 linux 服务器上运行

    一.概述 java项目有两种架构,一种是 B/S 架构的,一种是 C/S 架构的. 对于 B/S 架构来说,我们常见的 java ee 即是 B/S 架构,通常,开发人员会在本地进行开发,然后将项目打 ...

  3. Visual Studio写的项目在 IIS 服务器上运行的两种简单方法

    首先需要PC上开启了IIS服务,相关方法网上很多,也很简单 第一种:直接在项目中操作 1.创建一个项目,然后右击选中项目,右击,单击属性,打开项目属性标签页面 如图,选择Web标签,在服务器栏目中选中 ...

  4. Linux 笔记 #03# 在 Debian远程服务器上运行 Java socket程序

    我试图做什么:把我的破代码放到服务器上运行,并成功与客户端进行 socket通信. 预备环境:刚安装好 MySQL 和 JVM 的 Linux远程服务器(Debian 8)一台. 主要有如下几个步骤: ...

  5. 在Linux服务器上运行Jupyter notebook server教程

    在Linux服务器上运行Jupyter notebook server教程 很多deep learning教程都推荐在jupyter notebook运行python代码,方便及时交互.但只在本地运行 ...

  6. 在服务器上运行db:seed数据填充时,出错的问题解决

    在服务器上运行db:seed数据填充时,出错的问题解决 运行composer  dump-autoload

  7. 在linux云服务器上运行Jar文件

    在linux服务器上运行Jar文件时通常的方法是: $ java -jar test.jar 这种方式特点是ssh窗口关闭时,程序中止运行.或者是运行时没法切出去执行其他任务,有没有办法让Jar在后台 ...

  8. 在服务器上运行Jar包

    在服务器上运行Jar包 并且该Jar包依赖其他的Jar文件的时候,采用如下格式 java -Djava.ext.dirs=你依赖的Jar文件路径 -jar 你要运行的Jar文件 包名+类名 例如: j ...

  9. Asp.Net终于可以在龙芯服务器上运行啦:Jexus成功完成对国产系列CPU的适配

    为了确保我国信息化建设“安全可靠”,使用国产关键系统.关键应用.关键软硬件替代国外信息技术产品,已经在党政部门.国营企事业单位得到了进一步落实.过去运行于 Windows 服务器的 Web 应用程序, ...

随机推荐

  1. 多 LDAP 目录服务器的 FileNet P8 系统介绍和配置实例

    摘抄笔记:http://www.ibm.com/developerworks/cn/data/library/techarticle/dm-1312multipldap/ 多 LDAP 目录服务器的 ...

  2. Dell 服务器阵列扩容【经验分享(转)】

    看到论坛有朋友发帖询问Dell服务器的扩容,索性整理下之前做的文档,发出来和大家做个分享. 做之前给大家提醒2个注意点:①请做好数据备份,相同于HP.IBM,该扩容过程是不可逆的.②本扩容方法支持同级 ...

  3. Vagrant (3) —— 复制/备份Vagrant Box

    Vagrant (3) -- 复制/备份Vagrant Box 摘要 介绍复制/备份Vagrant Box基本方法 版本 Vagrant版本: 1.8.1 内容 复制vagrant box并压缩 关闭 ...

  4. NHibernate 知识点整理

    1.实体bool类型属性与数据库映射.如实体中有bool属性IsDelete.配置如下 <property column="IsDelete" name="IsDe ...

  5. c# winform+wcf代理上网的处理

    程序是.net开发的winform工具,分服务器端和客户端,用wcf技术实现数据交互. 客户端是大型公司,内部统一使用代理服务器上网.具体描述为:在IE中设置lan代理服务器才能查询网络数据:登录QQ ...

  6. springboot读取resource下的文本文件

    https://blog.csdn.net/programmeryu/article/details/58002218 文本所在位置: 获取ZH.txt: File file = ResourceUt ...

  7. LDAP none、simple、strong 笔记

    // 该笔记仍在调研中!!不确保中有错误信息!最终目的是想用java实现这三种认证方式. 1.ldaps://  注意多了个s 参考:https://mail.python.org/pipermail ...

  8. webRTC源码下载 Windows Mac(iOS) Linux(Android)全

    webRTC源码下载地址:https://pan.baidu.com/s/18CjClvAuz3B9oF33ngbJIw  提取码:wl1e  Windows版:visual studio 2017工 ...

  9. css3动画属性系列之transform细讲scale缩放

    下面我们从3个方面开始介绍: 1.scale(x,y) 对元素进行缩放 X表示水平方向缩放的倍数 | Y表示垂直方向的缩放倍数 Y是一个可选参数,没有设置的话,则表示X,Y两个方向的缩放倍数是一样的. ...

  10. 【转】android中的数据存取-方式一:preference(配置)

    这种方式应该是用起来最简单的Android读写外部数据的方法了.他的用法基本上和J2SE(java.util.prefs.Preferences)中的用法一样,以一种简单. 透明的方式来保存一些用户个 ...