Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Migrate to new server with near 0 downtime.

  1. #1
    Join Date
    Feb 2008
    Beans
    39

    Migrate to new server with near 0 downtime.

    I'm needing to move a production website to a new server with near 0 downtime. The website is php and mysql based with sessions handled in the mysql database. I assume the best way to do it would be to have the php website on both servers use just the one mysql server on the new server until the DNS is done dancing around? (One remotely and one localhost)

    I don't like the idea of having a mysql server open to remote connections, but I don't know of any other way to do it and it will only be open for a few days.

  2. #2
    Join Date
    Nov 2007
    Location
    Newry, Northern Ireland
    Beans
    1,258

    Re: Migrate to new server with near 0 downtime.

    Are the two servers going to be in the same location, on the same subnet? Or will they both have public IPs?
    Can't think of anything profound or witty.
    My Blog: http://gonzothegeek.blogspot.co.uk/

  3. #3
    Join Date
    Feb 2008
    Beans
    39

    Re: Migrate to new server with near 0 downtime.

    Public IPs on two different hosts in two different geographical locations.

  4. #4
    Join Date
    Nov 2007
    Location
    Newry, Northern Ireland
    Beans
    1,258

    Re: Migrate to new server with near 0 downtime.

    Ouch.

    How latency sensitive is the connection to the mysql server going to be?

    Will access to the mysql database be required from the old server when the new one is up? I guess it will, but confirmation would be good.

    I would suggest as one possibility creating a point-to-point VPN tunnel between the two servers and using this for the mysql queries from the old to the new server. You will need to make mysqld listen on all interfaces rather than just on localhost, but you could then block all inbound connections from eth0 using IPtables so there is still no access to it from outside, other than through the tunnel.

    Might have some latency issues though, hence my question...
    Can't think of anything profound or witty.
    My Blog: http://gonzothegeek.blogspot.co.uk/

  5. #5
    Join Date
    Feb 2008
    Beans
    39

    Re: Migrate to new server with near 0 downtime.

    If I do the transfer at night when the traffic is low I think I can live with a slow website over no website for some of our customers. DNS changes seems to happen pretty quickly, usually within a few hours.

  6. #6
    Join Date
    Feb 2007
    Location
    West Hills CA
    Beans
    10,044
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Migrate to new server with near 0 downtime.

    Be upfront with your customers. You will need to plan for downtime and if you are up before the end of the scheduled outage, then you will add to your reliability/credibility. Trying to perform this switchover without a true live migration will result in some downtime and some services that need tweaking.

    Planning is key. It's the difference between changing a tire on the family car in an hour, versus 5 seconds for an Indy race car. Fill out a matrix: Known problems, Known consequences; Known problems, Unknown consequences; Unknown problems, Known consequences; Unknown problems, Unknown consequences. The last one, Unk-Unk's are usually what throws you.
    Last edited by tgalati4; February 5th, 2013 at 05:21 PM.
    -------------------------------------
    Oooh Shiny: PopularPages

    Unumquodque potest reparantur. Patientia sit virtus.

  7. #7
    Join Date
    Nov 2007
    Location
    Newry, Northern Ireland
    Beans
    1,258

    Re: Migrate to new server with near 0 downtime.

    Quote Originally Posted by tgalati4 View Post
    Be upfront with your customers. You will need to plan for downtime and if you are up before the end of the scheduled outage, then you will add to your reliability/credibility. Trying to perform this switchover without a true live migration will result in some downtime and some services that need tweaking.

    Planning is key. It's the difference between changing a tire on the family car in an hour, versus 5 seconds for an Indy race car. Fill out a matrix: Known problems, Known consequences; Known problems, Unknown consequences, Uknown problems, Known consequences; Unknown problems, Unknown consequences. The last one, Unk-Unk's are usually what throws you.
    Definitely true, Scheduled downtime is better than unscheduled downtime, and DNS propagation is normally pretty fast. Might be the safest option to do a clean migration during a planned Maintenance Window.
    Can't think of anything profound or witty.
    My Blog: http://gonzothegeek.blogspot.co.uk/

  8. #8
    Join Date
    Sep 2011
    Location
    Behind you!
    Beans
    1,689
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: Migrate to new server with near 0 downtime.

    Can you get the database running @ the new location and then point the old website to the new database location? This can be near 0 downtime for a 1/2 switch like that since everything would be immediate and under your direct control. Then you can bring up the new website with it connected to the new database. Both websites using the same DB at the same time. Then update the DNS. At one point, some people in the world will be using the old web server, others the new web server. Once DNS is fully propagated and no more users connected to old website, you can then shutdown the old web server.

    LHammonds

  9. #9
    Join Date
    Nov 2007
    Location
    Newry, Northern Ireland
    Beans
    1,258

    Re: Migrate to new server with near 0 downtime.

    Quote Originally Posted by LHammonds View Post
    Can you get the database running @ the new location and then point the old website to the new database location? This can be near 0 downtime for a 1/2 switch like that since everything would be immediate and under your direct control. Then you can bring up the new website with it connected to the new database. Both websites using the same DB at the same time. Then update the DNS. At one point, some people in the world will be using the old web server, others the new web server. Once DNS is fully propagated and no more users connected to old website, you can then shutdown the old web server.

    LHammonds
    This is essentially what I was suggesting with my point-to-point VPN tunnel suggestion, although getting the downtime over with at the start of the migration is probably a better idea as all the users migrating to the new web server would no longer be subjected to any latency associated with a remote MySQL query.

    This could be achieved within a Maintenance Window of less than an hour using mysqldump on the old server and restoring the DB on the new one and making the changes in the sqlconnect code, assuming the tunnel has been set up previously.
    Can't think of anything profound or witty.
    My Blog: http://gonzothegeek.blogspot.co.uk/

  10. #10
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: Migrate to new server with near 0 downtime.

    Quote Originally Posted by rs2k View Post
    I don't like the idea of having a mysql server open to remote connections, but I don't know of any other way to do it and it will only be open for a few days.
    That's easily solved with an iptables rule on the MySQL server. From the command prompt you could enter:

    Code:
    /sbin/iptables -I INPUT -p tcp ! -s 127.0.0.0/8 --dport 3306 -j REJECT
    /sbin/iptables -I INPUT -p tcp -s ip.of.remote.server --dport 3306 -j ACCEPT
    The rules appear in reverse order here because I'm using the -I switch to insert these records above any others you may already by using. When those commands are done, the rules will be in the reverse order at the top of the ruleset. (If you are adding these to an existing ruleset, reverse their order and use the -A switch. Put them ahead of any default deny rule you may have at the bottom of the INPUT chain.)

    The "! -s 127.0.0.0/8" is only needed if there is not a default ACCEPT rule for localhost above where these rules would be entered.
    Last edited by SeijiSensei; February 5th, 2013 at 10:44 PM.
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •