简体   繁体   English

将数据库移动到另一台服务器

[英]Move database to another server

I am using mysqldump to move my database to another sever. 我正在使用mysqldump将数据库移动到另一个服务器。 But database has tables with million of rows and mysql restore takes too long(4 houres). 但是数据库具有具有数百万行的表,并且mysql恢复花费的时间太长(4小时)。
is there any way I do this faster? 有什么办法可以更快地做到这一点吗?

是的,您可以在源服务器上杀死mysqld,一旦它关闭,您可以将整个datadir复制到新服务器,并在复制完成后启动两个服务器。

Here's the way I have done this in the past using mysql replication 这是我过去使用mysql复制完成此操作的方式

Dump SQL on source machine with binary logging turned on (use the --master-data option) this will give you data at that point in time and allow you to import the data on your new server while new data is being populated on the old server. 在启用了二进制日志记录的源计算机上转储SQL(使用--master-data选项),这将在该时间点为您提供数据,并允许您在旧服务器上填充新数据的同时将数据导入新服务器上。服务器。

after the import (4 hours you said?) then you can START SLAVE on the new server and the new server will replay the binary logs and catch up to the old server and keep in sync until the actual switchover happens. 导入后(您说了4个小时?),您可以在新服务器上START SLAVE运行,新服务器将重播二进制日志并赶上旧服务器并保持同步,直到发生实际切换为止。

How to setup mysql replication 如何设置mysql复制

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM