如何让我的MySQL数据库随时可用?需要一些专家数据库建议!
我一直在做大量的研究,阅读复制等,但只是不确定什么 mysql 解决方案会起作用。
这就是我正在查看的内容:
当我的 mysql 由于某种原因失败或者某些查询需要很长时间才能执行并锁定某些表时,我希望其他插入/更新/选择查询仍然可以运行正常速度,无需等待锁释放或主数据库备份。我认为应该有第二个mysql服务器来实现这一点,但是即使有,我提到的是否可能,并且它会涉及我现有的编程逻辑的大量变化吗?
当我的数据库正在备份时,我仍然希望我的网站能够正常运行,所有插入/选择/更新都应该正常运行。
当我需要更改一个大表时,我不希望它影响我的应用程序,应该有一个备份服务器可以工作。
那么我需要做什么才能完成这一切,是否需要更改大量现有编码以适应新设置? [我的网站有大量的读写]
I've been doing a lot of research, reading on replication, etc but just not sure as to what mysql solution would work.
This is what I'm looking at:
when my mysql fails for some reason or there are certain queries that are taking really long to execute and locking some tables, I want the other insert/update/select queries to still function at normal speed without having to wait for locks to be released or for the main database to be back up. I'm thinking there should be a second mysql server for this to happen, but is what I mentioned possible even if there is and would it involve a lot of change in my existing programming logic?
when my database is being backed up, I would still like my site to function normally, all inserts/selects/updates should function as normal.
when I need to alter a large table, I wouldn't like it to affect my application, there should be a backup server to work from.
So what do I need to do to get all this done and also would it require changing plenty of existing coding to suit the new set up? [My site has a lot of reads and writes]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有简单的方法。您需要一个基于 MySQL 的高可用性设置,这需要在服务器和客户端进行大量工作。
一些问题,例如:
如果您要更改表,则无法轻松创建一个副本以供更新期间使用。第一次更新时对您的副本所做的更改怎么样?
搜索“高可用性 MySQL”。这基本上是一个已解决的问题,但解决方案在很大程度上取决于您的具体要求。你不能只是要求“我希望我的 SQL 服务器永远全速运行,无论我向它扔什么”。
There's no easy way. You're asking for a highly-available MySQL-based setup, and that requires a lot of work at the server and client ends.
Some issues, for example:
If you're altering the table, you can't trivially create a copy to work from during the update. What about the changes that are made to your copy while the first update is taking place?
Have a search for "High Availability MySQL". It's mostly a solved problem, but the solution depends heavily on your exact requirements. You cannot just ask for "I want my SQL server to run at full speed always forever no matter what I throw at it".
不是 MySQL 特定的答案,而是通用的答案。拥有数据库的只读副本以供站点渲染,该副本将定期同步到主数据库。这样,即使主数据库由于插入/删除而处于加载/锁定状态,您也可以保持站点正常运行。为了提高效率,请尽可能保持此副本非规范化。
Not a MySQL specific answer, but a general one. Have a read only copy of your DB for site to render, which will be synced to the master DB regularly. This way, you can keep your site working even if the master DB is under load/lock due to insert/delete. For efficiency, keep this copy as denormalized as you can.