How to migrate instances between DreamCompute clusters

DreamCompute offers multiple clusters (also often called availability zones) which are independent OpenStack installations with their own servers, storage, and control panel. Some clusters have different features, such as SSD storage or different hardware that is useful for a given task. Migrating instances and data between clusters is not automated at this time, but this guide shows you how to accomplish this yourself.

This guide assumes that you are comfortable working with SSH as well as some command line utilities like dd and the OpenStack CLI. For more information about those utilities, see the articles below.

Things to keep in mind

Here are a few things to keep in mind and plan before a migration.

IP addresses will change

Each cluster has assigned blocks of IP addresses, therefore floating IPs, public IPv4, and public IPv6 addresses cannot be transferred between clusters. If you are using private networks (optional in US-East 2), the specific assigned 10.x.x.x address may also change.

SSH keys

Each cluster manages its SSH Keys separately, so if you have your keys already set up in the source cluster, you must set up the same keys (or new ones) in the destination cluster. You can grab the public key of any key pair in your project from the ('Project' > 'Compute' > 'Key Pairs') page of the DreamCompute dashboard.

To get to that page, just click on the key pair name.

Plan a maintenance window

To avoid open files causing corruption or other odd behavior, it is safest to move the data when the instance is not running. The copying of the data is generally fairly quick for smaller volumes, but for larger volumes it could take some time. Remember, the copy must complete before service can be restored.

Additionally, DNS must be updated from the old public IPs to the new ones. Depending on the time to live (TTL) of your DNS provider, this process can take a matter of minutes up to 24 hours. DNS zones managed by DreamHost can have the TTL changed from 4 hours to 5 minutes if you contact support at least 24 hours in advance of your changes. This can help minimize propagation time.

Ephemeral instances

Ephemeral instances cannot have their data accessed by other instances when they are shut off. These instances can only be migrated while running, so it is best to shut down as many services as possible to limit the possibility of corruption. Please see the last section below for instructions on migrating running instances.

Migrating a volume-backed instance using the OpenStack CLI

For this type of move, it is necessary to delete the instance so that it leaves behind a volume to migrate.

This method requires that you did not select "Yes" for the "Delete Volume on Instance Delete" option when you created your instance. If you did, please skip to the last section for instructions on migrating running instances. If you continue, you may permanently destroy and lose your data.

As an overview, here are the components involved in accomplishing this task:

 SOURCE CLUSTER         DESTINATION CLUSTER

+---------------+     +----------------------+     +-------------------+
| Temp Instance |---->| Glance Image Service |---->| Migrated Instance |
+---------------+     +----------------------+     +-------------------+
        |(mount)
+----------------+
| Volume To Copy |
+----------------+

Migration procedure

  1. Create a temporary "copy machine" by launching a new instance using the smallest available flavor. This guide uses Ubuntu 14.04, but the commands should be similar on any Ubuntu system. It is also recommended that you make the instance ephemeral since it will not be needed after the migration is complete.
  2. Install the needed software to access the Glance image service on this new instance:
    [user@server]$ sudo -i
    [root@server]# apt-get install python-dev python-pip
    [root@server]# pip install python-openstackclient
    
  3. Run openstack help and check for any other modules that it says are missing. Install them with:
    [root@server]# pip install MODULENAME
    
  4. Set up your openstack.rc file for the DESTINATION cluster on this new instance. View the following article for instructions on how to download this file: 
  5. After downloading the file, either upload it to your instance or copy/paste its contents into a file on the instance. In the example below, the contents have been saved into a file named 'dreamcompute-CLUSTER.sh', but you can name it anything you like. Once you finish, execute the file:
    [root@server]# . dreamcompute-CLUSTER.sh
    
  6. Enter your DreamCompute password at the "Please enter your OpenStack Password" prompt. This is the same password you use to log into the DreamCompute dashboard.
  7. Now that your shell session has the necessary authentication credentials to connect to the DESTINATION cluster, run the following command to see the OpenStack images currently in the DESTINATION cluster:
    [root@server]# openstack image list
    
  8. Delete the instance you wish to move, freeing up its volume so it can be attached to the newly-created instance.
  9. To attach the volume to the new instance, go to the Volumes menu, click on the drop-down box in the 'Actions' column on the right side, then click 'Edit Attachments'.
  10. Determine the drive letter of the new volume. Generally /dev/vda will be the boot drive of your instance, so it may be /dev/vdb or /dev/vdc. One way to check for it is with the fdisk command:

    [root@server]# fdisk -l /dev/vdb | grep Disk
    [root@server]# fdisk -l /dev/vdc | grep Disk
    

    The one that matches the size of the new volume is the one to use. Make note of the drive letter (the /dev/vdX part).

  11. Use dd to pipe the data directly into the glance image service. Don't forget to change the drive letter in the example below to the one you found above. You can also change any text in all CAPS to suit your taste.
    [root@server]# dd if=/dev/vdX | openstack image create \
                   --private --container-format bare \
                   --disk-format raw "INSTANCENAME"
    
  12. Wait for this command to finish running. If successful, it should output the info about the new image that was created.

You are now ready to go to the DESTINATION cluster to start up a new instance and to select the image that was just uploaded as the source. If the data is meant to be persistent, it is best to specify that you want to create a new volume in the "Source" tab when launching the new instance.

Migrating an ephemeral instance using the OpenStack CLI

This type of migration is not recommended. However it may be necessary in some situations and so is included here.

  1. Shut down as many services on the instance as possible (such as database servers, http servers, and so on), ideally leaving only default system tools and sshd running.
  2. Install the needed software to access the glance imaging service on the instance:
    [user@server]$ sudo -i
    [root@server]# apt-get install python-dev python-pip
    [root@server]# pip install python-openstackclient
    
  3. Run openstack help and check for any other modules that it says are missing. Install them with:
    [root@server]# pip install MODULENAME
    
  4. Set up your openstack.rc file for the DESTINATION cluster on this new instance. View the following article for instructions on how to download this file: 
  5. After downloading the file, either upload it to your instance or copy/paste its contents into a file on the instance. In the example below, the contents have been saved into a file named 'dreamcompute-CLUSTER.sh', but you can name it anything you like. Once you finish, execute the file:
    [root@server]# . dreamcompute-CLUSTER.sh
    
  6. Enter your DreamCompute password at the "Please enter your OpenStack Password" prompt. This is the same password you use to log into the DreamCompute dashboard.
  7. Now that your shell session has the necessary authentication credentials to connect to the DESTINATION cluster, run the following command to see the OpenStack images currently in the DESTINATION cluster:
    [root@server]# openstack image list
    
  8. Determine the drive letter by examining the output of df -h for the root (/) filesystem. Generally this is /dev/vda1.
  9. Use dd to pipe the data from the disk directly into the glance image service. Change any text in all CAPS to suit your taste.
    [root@server]# dd if=/dev/vda | openstack image create \
                   --private --container-format bare \
                   --disk-format raw "INSTANCENAME"
    
  10. Wait for the command to finish running. If successful, it should output the info about the new image that was created.

You are now ready to go to the DESTINATION cluster to start up a new instance and to select the image that was just uploaded as the source. If the data is meant to be persistent, it is best to specify that you want to create a new volume in the "Source" tab when launching the new instance.

Did this article answer your questions?

Article last updated PST.