如果要用快照将实例从OpenStack Project迁移到云中,请使用如下方法。
在源Project中:
在目的Project中:
注意: 有些云提供商只允许管理员来进行这项操作。
$ nova list
+--------------------------------------+------------+--------+------------------------------+
| ID | Name | Status | Networks |
+--------------------------------------+------------+--------+------------------------------+
| c41f3074-c82a-4837-8673-fa7e9fea7e11 | myInstance | ACTIVE | private=10.0.0.3 |
+--------------------------------------+------------+--------+------------------------------+
$ nova stop example
nova list
再列出实例,确定您要迁移的实例已经是SHUTOFF
的状态了:$ nova list
+--------------------------------------+------------+---------+------------------+
| ID | Name | Status | Networks |
+--------------------------------------+------------+---------+------------------+
| c41f3074-c82a-4837-8673-fa7e9fea7e11 | myInstance | SHUTOFF | private=10.0.0.3 |
+--------------------------------------+------------+---------+------------------+
nova image-create
命令来创建新快照:$ nova image-create --poll myInstance myInstanceSnapshot
Instance snapshotting... 50% complete
nova image-list
命令检查镜像的状态,直到状态变为ACTIVE
:$ nova image-list
+--------------------------------------+---------------------------------+--------+--------+
| ID | Name | Status | Server |
+--------------------------------------+---------------------------------+--------+--------+
| 657ebb01-6fae-47dc-986a-e49c4dd8c433 | cirros-0.3.2-x86_64-uec | ACTIVE | |
| 72074c6d-bf52-4a56-a61c-02a17bf3819b | cirros-0.3.2-x86_64-uec-kernel | ACTIVE | |
| 3c5e5f06-637b-413e-90f6-ca7ed015ec9e | cirros-0.3.2-x86_64-uec-ramdisk | ACTIVE | |
| f30b204e-1ce6-40e7-b8d9-b353d4d84e7d | myInstanceSnapshot | ACTIVE | |
+--------------------------------------+---------------------------------+--------+--------+
$ nova image-list
+-------------------+-------------------+--------+--------------------------------------+
| ID | Name | Status | Server |
+-------------------+-------------------+--------+--------------------------------------+
| f30b204e-1ce6... | myInstanceSnapshot| ACTIVE | c41f3074-c82a-4837-8673-fa7e9fea7e11 |
+------------------+-------------------+--------+---------------------------------------+
$ glance image-download --file snapshot.raw
f30b204e-1ce6-40e7-b8d9-b353d4d84e7d
注意:
glance image-download
这个命令要求必须使用镜像ID,不能使用镜像名。此外,您还要确保您的目标文件夹有足够的空间来存储这个镜像文件。
在新的Project或者云环境中,导入快照:
$ glance image-create --copy-from IMAGE_URL
在新的Project或者云环境中,用新的快照启动实例:
$ nova boot --flavor m1.tiny --image myInstanceSnapshot myNewInstance