我可以在RDS上的只读副本中创建主服务器上不存在的表吗? [英] On RDS can I create Tables in a Read Replica that are not present on the Master?

查看:91
本文介绍了我可以在RDS上的只读副本中创建主服务器上不存在的表吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个单独的RDS实例来处理会话状态表,但是发现会话数据库负载非常低.如果我们可以将实例处理会话转换为主数据库的只读副本,那么我们就可以将其用于即使在复制时滞后也很安全的只读任务.

We have a separate RDS Instance to handle session state tables, however found that the session DB load is very low. if we can convert the instance handling session as a Read Replica of the main DB, then we can use it for read-only tasks that are safe even with a large lag in the copy.

有人在RDS上做过这样的事情吗(是否可能且安全)?我应该注意任何严重的副作用吗?任何链接或有助于更好地理解这一点将有所帮助.

Has anyone done something like this on RDS (Is it possible and safe)? Should I watch out for any serious side effects? Any links or help in understanding this better would help.

http://aws.amazon.com/rds/faqs/#95试图回答问题,但正在寻求更多见识.

http://aws.amazon.com/rds/faqs/#95 attempts to answer the question but am looking for more insights.

推荐答案

是的,有可能.对于本地缓存的特定情况,我已成功使用RDS成功使用它.

Yes, it is possible. I am using it with success using RDS, for specific case of a local cache.

您需要将副本上的read_only参数设置为0.为了使该参数正常工作,我不得不重新启动服务器.

You need to set the read_only parameter on your replica to 0. I've had to reboot my server in order for that parameter to work.

如果使用不同的表名,它将很好地工作,因为RDS不允许您设置:replicate-ignore-table参数.

It's going to work nicely if use different table names, as RDS doesn't allow you to set: replicate-ignore-table parameter.

请记住,主从机之间不存在任何数据冲突.如果有一条语句在MASTER上正常运行,但在SLAVE上失败,则说明您刚刚中断了复制.那可能会发生当您首先在SLAVE上创建表时,然后在一段时间后将该表添加到MASTER. CREATE语句在MASTER上可以正常使用,但在SLAVE上失败,因为表已经存在.

Remember there musn't be any data collision between master<>slave. If there is a statement which works ok on MASTER, but fails on SLAVE, then you've just broke your replication. That might happen e.g. when you've created table on SLAVE first then after some time you've added that table to MASTER. The CREATE statement will work clean on MASTER, but fail on SLAVE, as table already exist.

假设,您需要非常小心,允许您的应用程序写入SLAVE.如果您忘记/或犯了一个错误,然后开始写一些其他数据来读取副本,那么最终您可能会丢失数据或遇到难以调试的问题.

Assuming, you need to be really careful, allowing your application to write to SLAVE. If you forget / or make a mistake and start writing to read replica for some of your other data, in the end you might lose data or experience hard to debug issues.

这篇关于我可以在RDS上的只读副本中创建主服务器上不存在的表吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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