5

We host a Rails app on AWS which uses mysql on the amazon-rds database. We have a giant table in the database which we want to migrate, but it takes days to make the migration because of the millions of rows. Specifically we're moving a VARCHAR to a TEXT column

How do I migrate this large production database without users experiencing downtime?

One idea I've heard is to setup a copy of the database, and make the migration there and switching it to be the main database when that's done. However I'm not sure how this would take account of user data entered while the migration is ongoing.

Update: This may be relevant: amazon-rds offers read replicas and Multi-AZ deployments which seem like they might be made for this type of thing. First time doing this, though, so would welcome guidance on any method whether it be this or another.

4

1 回答 1

2

我不知道您使用的托管选项是否可行,但我会以这种方式解决问题:

  1. 将数据复制到新服务器(并记录旧数据库服务器上的二进制日志位置)
  2. 打开从旧服务器到新服务器的复制(并等待它赶上)
  3. 重新配置 Rails 应用程序以指向新服务器

如果“写入停机时间”比“完全停机时间”更容易接受(显然取决于应用程序),只读模式是另一种可能的选择。

于 2013-08-23T00:45:16.593 回答