postgresql 数据库镜像/Postgres 流复制

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6207603/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-20 23:03:31  来源:igfitidea点击:

Database Mirroring / Postgres Streaming Replication

postgresqlstreamingreplicationdatabase-backups

提问by TrevorB

I am not a DBA; I'm the primary developer of an enterprise database based application.

我不是 DBA;我是基于企业数据库的应用程序的主要开发人员。

I'm currently specing out some new machines to upgrade our existing enterprise database. Currently we're running Postgres 8.4 with a database at our DR site that receives updates at intervals via some custom rsync work a former employee performed.

我目前正在指定一些新机器来升级我们现有的企业数据库。目前,我们在 DR 站点运行带有数据库的 Postgres 8.4,该数据库通过前雇员执行的一些自定义 rsync 工作每隔一段时间接收更新。

One of the major issues we're trying to tackle is latency between two global offices. We have staff in NY and staff in London. Currently, the London staffers suffer the fate of our VPN pipe. I'm not really in a position to change that infrastructure.

我们试图解决的主要问题之一是两个全球办事处之间的延迟。我们在纽约有员工,在伦敦有员工。目前,伦敦的工作人员正在遭受我们 VPN 管道的命运。我真的没有能力改变那个基础设施。

What I'd like to do is move to Postgres 9 and setup streaming replication. The slave would be in the London office, which would alleviate read problems for users. The problem I foresee is writes to the slave (not sure how PG handles this, my understanding is the slave is in read-only mode). Ideally, writes would be sent to the master in NY (writes are very infrequent from London, but necessary) by the database itself. Furthermore, I can setup fallover to have it act as a hot swappable backup (replacing the DR). Again, all contained within Postgres configuration with no additional code.

我想做的是迁移到 Postgres 9 并设置流复制。奴隶将在伦敦办公室,这将减轻用户的阅读问题。我预见的问题是写入从站(不确定 PG 如何处理这个问题,我的理解是从站处于只读模式)。理想情况下,写入将由数据库本身发送到纽约的主服务器(从伦敦写入的情况很少,但很有必要)。此外,我可以设置失败转移以使其充当热插拔备份(替换 DR)。同样,所有都包含在 Postgres 配置中,没有额外的代码。

That's my idealized solution. How far off am I? Is this at all possible?

这是我理想化的解决方案。我离我有多远?这是可能吗?

I'm a little overwhelmed by the breadth of this topic and Google is not really helping me. I would appreciate any advice from some experienced DBAs, with anecdotes, relevant documentation or examples.

这个话题的广度让我有点不知所措,谷歌并没有真正帮助我。我会感谢一些有经验的 DBA 的任何建议,包括轶事、相关文档或示例。

Currently we're using SQLAlchemy as the primary interface to the database, if that's relevant. It does mean we're not tied to Postgres.

目前我们使用 SQLAlchemy 作为数据库的主要接口,如果相关的话。这确实意味着我们与 Postgres 无关。

Thanks everyone.

感谢大家。

采纳答案by Frank Heikens

pgpool-IIcan handle this for your: enter image description here

pgpool-II可以为您处理这个: 在此处输入图片说明

Check this example.

检查这个例子

回答by Imraan

The PostgreSQL 9 documentation gives a nice overview of the options available.

PostgreSQL 9 文档很好地概述了可用选项。

http://www.postgresql.org/docs/9.0/static/different-replication-solutions.html

http://www.postgresql.org/docs/9.0/static/different-replication-solutions.html

You might want to look at Slony if you do not mind having to write to the master and not the slave, or if you want, check out any of the multi-master replication technologies available.

如果您不介意写入主服务器而不是从服务器,或者如果您愿意,可以查看任何可用的多主复制技术,您可能想查看 Slony。