要使用快照从OpenStack工程到云迁移实例,完成如下步骤
在源项目:
到目标项目:
注解
某些云提供商仅允许管理员执行此任务。
为了保证所有的数据已经存储到硬盘,创建快照之前需要关闭源虚拟机。如果有必要,列出实例来浏览实例名称。
$ openstack server list
+--------------------------------------+------------+--------+------------------------------+------------+
| ID | Name | Status | Networks | Image Name |
+--------------------------------------+------------+--------+------------------------------+------------+
| c41f3074-c82a-4837-8673-fa7e9fea7e11 | myInstance | ACTIVE | private=10.0.0.3 | cirros |
+--------------------------------------+------------+--------+------------------------------+------------+
Use the openstack server stop command to shut down the instance:
$ openstack server stop myInstance
使用:command:openstack server list`命令来确保实例状态是``SHUTOFF`:
$ openstack server list
+--------------------------------------+------------+---------+------------------+------------+
| ID | Name | Status | Networks | Image Name |
+--------------------------------------+------------+---------+------------------+------------+
| c41f3074-c82a-4837-8673-fa7e9fea7e11 | myInstance | SHUTOFF | private=10.0.0.3 | cirros |
+--------------------------------------+------------+---------+------------------+------------+
Use the openstack server image create command to take a snapshot:
$ openstack server image create myInstance --name myInstanceSnapshot
The above command creates the image myInstance
by taking a snapshot
of a running server.
使用命令`openstack image list`来检查快照状态,直到状态是``active``:
$ openstack image list
+--------------------------------------+---------------------------------+--------+
| ID | Name | Status |
+--------------------------------------+---------------------------------+--------+
| 657ebb01-6fae-47dc-986a-e49c4dd8c433 | cirros-0.3.5-x86_64-uec | active |
| 72074c6d-bf52-4a56-a61c-02a17bf3819b | cirros-0.3.5-x86_64-uec-kernel | active |
| 3c5e5f06-637b-413e-90f6-ca7ed015ec9e | cirros-0.3.5-x86_64-uec-ramdisk | active |
| f30b204e-1ce6-40e7-b8d9-b353d4d84e7d | myInstanceSnapshot | active |
+--------------------------------------+---------------------------------+--------+
获得镜像标识:
$ openstack image list
+-------------------+-------------------+--------+
| ID | Name | Status |
+-------------------+-------------------+--------+
| f30b204e-1ce6... | myInstanceSnapshot| active |
+-------------------+-------------------+--------+
通过使用在上一步中返回的镜像标识下载快照:
$ openstack image save --file snapshot.raw f30b204e-1ce6-40e7-b8d9-b353d4d84e7d
注解
The openstack image save command requires the image ID or the image name. Check there is sufficient space on the destination file system for the image file.
通过HTTP或直接上传至机器(scp
)的方式使得镜像在新环境中可用。
在新项目或云环境导入快照
$ openstack image create NEW_IMAGE_NAME \
--container-format bare --disk-format qcow2 --file IMAGE_URL
在新的项目或环境中,使用快照创建新的云主机:
$ openstack server create --flavor m1.tiny --image myInstanceSnapshot myNewInstance
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.