Overview
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 of 5 minutes.
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
- Create a temporary "copy machine" by launching a new instance using the smallest available flavor. This guide uses Ubuntu commands. It is also recommended that you make the instance ephemeral since it will not be needed after the migration is complete.
- Install the needed software to access the Glance image service on this new instance:
[user@instance]$ sudo -i [root@instance]# apt-get install python-dev python-pip [root@instance]# pip install python-openstackclient
- Run openstack help and check for any other modules that it says are missing. Install them with:
[root@instance]# pip install MODULENAME
- 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:
- 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@instance]# . dreamcompute-CLUSTER.sh
- 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.
- After 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@instance]# openstack image list
- Delete the instance you wish to move, freeing up its volume so it can be attached to the newly-created instance.
- 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'.
-
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@instance]# fdisk -l /dev/vdb | grep Disk [root@instance]# 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).
- 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@instance]# dd if=/dev/vdX | openstack image create \ --private --container-format bare \ --disk-format raw "INSTANCENAME"
- 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.
- 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.
- Install the needed software to access the glance imaging service on the instance:
[user@instance]$ sudo -i [root@instance]# apt-get install python-dev python-pip [root@instance]# pip install python-openstackclient
- Run openstack help and check for any other modules that it says are missing. Install them with:
[root@instance]# pip install MODULENAME
- 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:
- 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@instance]# . dreamcompute-CLUSTER.sh
- 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.
- After 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@instance]# openstack image list
- Determine the drive letter by examining the output of df -h for the root (/) filesystem. Generally this is /dev/vda1.
- 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@instance]# dd if=/dev/vda | openstack image create \ --private --container-format bare \ --disk-format raw "INSTANCENAME"
- 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.