开发者

Moving Rails 3 Application Development Environment to Another Machine

I have a Rails 3 development environment that I need to move to another machine. I would like to know 开发者_StackOverflow社区the best way to move the application code, mysql database, and gems with the least amount of disruption?


In development:

  1. Make sure Ruby version is the same. Copy all gems.
  2. Copy application
  3. Make dump of database and load it to new DB. If DB is exactly same version and OS as well copying binary data files may be enough.

In production the worst part is syncing DB and DNS.

  1. If you can lower TTL (to 1 hour) on DNS entry of your domain - to have DNS propagation respond better.
  2. Wait previous TTL + new TTL to be sure all clients and proxies updated - in a meantime you can prepare Rails 3 app on new machine.
  3. Setup TCP/IP forwarding on new machine 80 port to old machine 80 port, with exception for your workstation (to have access to app instance on new machine).
  4. Finish preparing app, gems, with copy of db, test it.
  5. If everything is ok, change DNS A entry to new host IP - in this case within 1 hour all clients will be connecting to old instance via new one (forwarding). Wait 1 hour.
  6. Now offline: Stop old instance with maintenance message
  7. Make db dump and load it on new instance
  8. Restart new app instance
  9. Turn off forwarding. End of offline.


Are you using a revision control system such as git or svn? If yes then you simply need to checkout your code onto the new machine. If no, then I wouldn't do anything until you get it into git / svn / your revision control software of choice.

Gems should be taken care of by bundler. Just run bundle install inside the source directory on your new machine once the source code has been moved over.

To move the database you can either rebuild it from scratch if you don't have any important data with rake db:create db:migrate. Otherwise use mysqldump database_name > database_name.sql to dump your database to an SQL file which you can import on the new machine (cat database_name.sql | mysql new_database_name).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜