如何在共享主机上持续克隆 mySQL
我在共享服务器上安装了 MySQL,并可以通过 phpMyAdmin 进行访问。我想将该数据库连续、实时克隆到云 mySQL 数据库(我们专门为此数据库创建了一个支持 Nginx 的 MySQL 服务器) 我想创建旧数据库的实时克隆,然后将代码更新为指向新数据库...
I have a MySQL install on a shared server and have access through phpMyAdmin. I want to make a continuous, real time clone of that database to a cloud mySQL database (we have created an Nginx-ready MySQL server specially for this database) I want to create a real time clone of the old one, then update code to point to the new database...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在寻找的是复制。它有很多选项可以在一篇文章中介绍。
http://dev.mysql.com/doc/refman/5.5/en /replication.html
如果您要通过互联网进行复制,您需要保护它的安全。您的主机可能允许虚拟局域网,因此这不会耗尽您的带宽资源。
你应该看看 percona 提供的一组很棒的工具,它们是 maatkit
https://launchpad.net/percona-toolkit
文档和使用示例
http://www.maatkit.org/doc/
它对于其他任务很有用,但它也允许您快速复制实时数据库。
当您使用实时数据库时,请确保您的备份是最新的。
What you're looking for is replication. It has far to many options to cover here in a single post.
http://dev.mysql.com/doc/refman/5.5/en/replication.html
If your going to do replication over the internet you'll want to secure it.Your host might allow a virtual local area network So this doesn't use up your bandwidth resources.
A great set of tools from percona you should look at are maatkit
https://launchpad.net/percona-toolkit
Documentation and usage examples
http://www.maatkit.org/doc/
It's good for other tasks but it also allows you to replicate a live database quickly.
When your working with live databases make sure your backups are upto date.
我认为在共享服务器环境中进行 MySQL 的实时复制会遇到困难。由于您似乎正在移动数据库服务器,因此我倾向于对您的数据进行热复制,并将其安装在新的数据库服务器上。在获取该副本的同时,您应该在应用程序上打开查询日志记录。
然后,您的切换将包括针对新数据库运行记录的查询(比记录的速度更快!),最后,在所有记录的查询都已运行时,切换应用程序的配置以便使用新数据库。
编辑:热复制的问题是数据在复制的同时写入数据库。这意味着每个表的“上次更新”时间都会不同。在此基础上,是否可以在您的应用程序中为每一行设置“last_updated”列?如果是这样,您将能够告诉每个表哪些记录的查询仍需要复制。
I think you will have difficulty doing real-time replication of a MySQL in a shared server environment. Since you appear to be moving db servers, I would be inclined to do a hot copy of your data, and install that on the new db server. At the same time as taking that copy, you should switch on query logging on your application.
Your switch over would then consist of running logged queries against the new database (faster than they were logged!) and finally, at a point that all logged queries have been run, switching the configuration of the app so that the new db is used.
Edit: the problem with a hot copy is that data is being written to the db at the same time as it is being copied. That means that the 'last updated' time will be different for each table. On that basis, is it possible in your application to set up a 'last_updated' column for each row? If so you will be able to tell for each table which logged queries still need to be copied.