LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Moving to a new machine (https://www.linuxquestions.org/questions/linux-server-73/moving-to-a-new-machine-836565/)

yoachan 10-06-2010 11:46 AM

Moving to a new machine
 
Dear all,

We are planning to move our site to a new machine, with as little as down time as possible. The site is a small forum, so it can always changing every minutes.
As a note both machine are remote machine. We only have ssh tunnel and http connection.
So here is what we have for a plan:
  1. Copy all data (and database) from old machine to the new machine using rsync
  2. Make an announcement that at scheduled time, there will be a down time.
  3. Reduce TTL for DNS (www.mysite.com)
  4. Make a dummy name for testing (dummy.mysite.com)
  5. make dummy.mysite.com as a mirror copy (at certain point) of www.mysite.com
  6. At scheduled time, make both www.mysite.com and dummy.mysite.com offline, and point DNS www.mysite.com to new machine, pointing the same directory as dummy.mysite.com, and remove name for dummy.mysite.com
  7. re-rsync databases on both machine
  8. After rsync completed, turn www.mysite.com on new machine online

My question is:
  1. Will this plan works?
  2. Can rsync copy changed part of a file instead of copying whole file? Assuming mysql MYD file changed because of mysql transaction, can rsync copy only part of file that changed instead of copying whole file again? Copying over 100+ MB mysql file only because of mysql add a single record won't be a smart move...
  3. Does anyone have a better and easier plan to do this?

This is my first experience moving host on a live site.
Any help appreciated.

Thanks and regards,

yoachan

mago 10-06-2010 01:20 PM

yes rsync will sync up the changes once the bulk has been copied over.

man rsync will show you all you need.

yoachan 10-06-2010 09:05 PM

@Mago: Thanks, Man! This bring me a relief :)

Blue_Ice 10-07-2010 01:17 AM

I wouldn't use rsync on the databases. I would do a backup and restore or set up mysql replication. rsync'ing databases can cause problems with the integrity of the database.

quanta 10-07-2010 02:32 AM

Agree with Blue Ice. I would like to suggest you use mysqldump.

yoachan 10-09-2010 08:56 PM

The problem is dumped database will takes time to be copied over.
For this two machines were thousands mile away. One in US and one in Asia.

Any other solution(s)?

mago 10-09-2010 09:06 PM

How big is the dump?.
How much does it weight compress?.
How long is the maintenance window?

Which engine are you using for MySQL?

There are lots of ways to skin a cat, one just need some info.

yoachan 10-09-2010 09:29 PM

The biggest chunk is 550MB, and will take transfer time 30-60 minutes.
Other databases are smaller. To move everything will takes approximately two hours...
I didn't do compression, but I'm using on the fly compression during rsync/scp.

Just thinking that direct rsync will be easier, faster, and fail-proof :) :)
We just want our down time as short as it can, just for user's comfort :)

mago 10-09-2010 09:39 PM

Well if you use InnoDB and you can enable binary logs, upload the dump of the day before and sync up the logs of the day, then import from the logs up to the date.

Another way to go is to compress on the fly the same day:
Code:

mysqldump --opt --single-transaction -uuser -ppassword database | gzip -9 | ssh user@remoteserver "dd of=/path/for/dump/backup-`date +%Y%m%d`.sql.gz"
Or you can dump all databases at once, compress and transfer them with the same method, usually the compression rate is 8/9 to 1.

So if 550MB is the largest this way you transfer about 60MB then uncompress on destination server and import it.

Let me know how it goes.

yoachan 10-10-2010 10:23 PM

Tomorrow will be the D-Day
Today we prepare everything that needed. :)

yoachan 10-15-2010 05:04 AM

Huff... huff...
All data moved.
rsync home directories and document_roots,
dump and zip databases than transfers.

Still waiting for DNS to propagate. :)

Thanks for everyone's help :)


All times are GMT -5. The time now is 09:17 PM.