流式复制 - 混淆副本?
我想在 PG9 中使用流复制进行 QA - 即,将数据从生产流传输到 QA。警告:我需要在 QA 中混淆数据(更改密码哈希、电子邮件等)。
是否可以通过流式复制来实现?如果没有,是否有任何替代方案可以通过动态混淆进行增量更新?
I would like to use streaming replication in PG9 for QA - that is, stream data from production to QA. Caveat: I need to obfuscate data in QA (change password hashes, emails etc.).
Is it possible to achieve it with streaming replication? If not, are there any alternatives for an incremental update with on-the-fly obfuscation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想你可能需要在这里推出一些自己的东西。我要做的是在真实的表上设置一个触发器,将混淆/任意值放在这些东西的位置,并将它们推入备用模式中具有相同名称的表中。然后我将复制数据库,并用这些表替换原始表。这样,安全数据就不会离开生产环境,并且您可以使用预构建的复制引擎 (slony),而无需自己滚动所有内容。如果您需要有关 slony 的帮助,请转到 slony 管理指南以开始使用。它看起来确实很复杂,但也不算太糟糕,一旦你掌握了它的窍门,你就可以用它做一些非常酷和令人惊奇的事情。
I think you're probably gonna have to roll something of your own here. What I'd do is setup a trigger on the real table that puts an obfuscated / arbitrary value in the place of such things and shoves them into a table with the same name in an alternate schema. then I'd replicate the db, with those tables substituted for the originals. This way, no secure data leaves production, and you can use a pre-built replication engine (slony) without having to roll everything yourself. If you need help on slony, go to the slony admin guide to get started. It seems really complex, but it's not too bad, and once you get the hang of it you can do some really cool and amazing things with it.
明确而简短的答案:不。
在 PostgreSQL 嵌入式流复制中,主服务器和从服务器必须相同。您不仅无法更改特定记录和字段,而且还无法更改数据库的数量。来自主服务器的完整“数据库集群”(及其所有数据库、表和数据)将被复制到从服务器。
您真正需要的是某种逻辑的、基于触发器的复制。我听说 pglink 可以做到这一点,但我从未尝试过。
Clear and short answer: NO.
In PostgreSQL embedded streaming replication master and slave have to be identical. Not only you can't change particular records and fields, but also you can't change number of databases for example. Complete "database cluster" from the master (with all its databases, tables, and data) will be copied to the slave.
What you actually need is some kind of logical, trigger based replication. I've heard that pglink can do this, but I've never tried.