在同一台机器上创建多个Postgres实例 [英] Create multiple Postgres instances on same machine

查看:90
本文介绍了在同一台机器上创建多个Postgres实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要测试流复制,我想在同一台计算机上创建另一个Postgres实例。这个想法是,如果可以在测试服务器上完成,那么在两个生产服务器上进行设置应该是微不足道的。

To test streaming replication, I would like to create a second Postgres instance on the same machine. The idea is that if it can be done on the test server, then it should be trivial to set it up on the two production servers.

实例应该使用不同的配置文件和不同的数据目录。我尝试按照此处的说明 http://ubuntuforums.org/showthread.php?t=1431697,但我还没有弄清楚如何让Postgres使用其他配置文件。如果我复制init脚本,则这些脚本只是同一Postgres实例的别名。

The instances should use different configuration files and different data directories. I tried following the instructions here http://ubuntuforums.org/showthread.php?t=1431697 but I haven't figured out how to get Postgres to use a different configuration file. If I copy the init script, the scripts are just aliases to the same Postgres instance.

我使用的是Postgres 9.3,Postgres帮助页面说要指定配置文件在 postgres 命令行上。我不太确定这是什么意思。我是否应该安装一些客户端才能正常工作?谢谢。

I'm using Postgres 9.3 and the Postgres help pages say to specify the configuration file on the postgres command line. I'm not really sure what this means. Am I supposed to install some client for this to work? Thanks.

推荐答案

我认为您可以尝试使用Postgresql实用程序。

I assume you can work your way out on using postgresql utilities.

创建集群

$ initdb -D /path/to/datadb1
$ initdb -D /path/to/datadb2

运行实例

$ pg_ctl -D /path/to/datadb1 -o "-p 5433" -l /path/to/logdb1 start
$ pg_ctl -D /path/to/datadb2 -o "-p 5434" -l /path/to/logdb2 start

测试流

现在,您有两个实例在端口5433和5434上运行。它们位于 initdb 指定的数据目录中。调整它们以进行流复制。

您的默认安装在端口5432上保持不变。

Now you have two instances running on ports 5433 and 5434. Configuration files for them are in data dirs specified by initdb. Tweak them for streaming replication.
Your default installation remains untouched in port 5432.

这篇关于在同一台机器上创建多个Postgres实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆