openstack 利用ceph存储之---备份还原虚拟机
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了openstack 利用ceph存储之---备份还原虚拟机相关的知识,希望对你有一定的参考价值。
本次环境为openstack K版本。ceph 版本为0.94.5
我们的虚拟机都是建立在ceph中的。
备份虚拟机:
打开openstack控制台,点击要备份的虚拟机:
获取虚拟机的id信息:
在控制节点获取,虚拟机对应的ceph中的volume id
[[email protected] ceph]# nova show 1d77b49b-4263-477e-acc8-4242a3a998b3
[[email protected] ceph]# rbd ls volumes | grep 2ccd04fd-3a28-4d40-b226-cab0af159257
volume-2ccd04fd-3a28-4d40-b226-cab0af159257
导出虚拟机到一个位置
[[email protected] ~]# rbd export -p volumes volume-2ccd04fd-3a28-4d40-b226-cab0af159257 /tmp/vm1.bk
Exporting image: 100% complete...done.
[[email protected] ~]# ll /tmp/vm1.bk -h
-rw-r--r--. 1 root root 1.0G Jun 26 10:39 /tmp/vm1
可以看到虚拟机已经导出了,并且大小也是1G
============导入========
下面我们来做下导入,我们首先把刚刚备份的虚拟机删除
[[email protected] ~]# nova list
+--------------------------------------+------+--------+------------+-------------+------------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+------+--------+------------+-------------+------------------------------+
| 1d77b49b-4263-477e-acc8-4242a3a998b3 | 11 | ACTIVE | - | Running | net=10.0.0.7 |
| 17e0220e-e9b5-4b6a-8001-6ce84c7b1385 | vm1 | ACTIVE | - | Running | net=10.0.0.3, 192.168.253.43 |
+--------------------------------------+------+--------+------------+-------------+------------------------------+
[[email protected] ~]# nova delete 1d77b49b-4263-477e-acc8-4242a3a998b3
Request to delete server 1d77b49b-4263-477e-acc8-4242a3a998b3 has been accepted.
[[email protected] ~]# nova list
+--------------------------------------+------+--------+------------+-------------+------------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+------+--------+------------+-------------+------------------------------+
| 17e0220e-e9b5-4b6a-8001-6ce84c7b1385 | vm1 | ACTIVE | - | Running | net=10.0.0.3, 192.168.253.43 |
+--------------------------------------+------+--------+------------+-------------+------------------------------+
ok,已经把虚拟机删除了。此我们需要创建一个同等规格的虚拟机。名为‘Erick’
使用同样的方法,获取虚拟机的id、在ceph中的volume对应的id
[[email protected] ~]# nova show 362151d7-84f7-4043-a723-a852e48922a7
+--------------------------------------+----------------------------------------------------------+
| Property | Value |
+--------------------------------------+----------------------------------------------------------+
| OS-DCF:diskConfig | AUTO |
| OS-EXT-AZ:availability_zone | nova |
| OS-EXT-SRV-ATTR:host | compute |
| OS-EXT-SRV-ATTR:hypervisor_hostname | compute |
| OS-EXT-SRV-ATTR:instance_name | instance-0000000c |
| OS-EXT-STS:power_state | 1 |
| OS-EXT-STS:task_state | - |
| OS-EXT-STS:vm_state | active |
| OS-SRV-USG:launched_at | 2016-06-26T14:45:35.000000 |
| OS-SRV-USG:terminated_at | - |
| accessIPv4 | |
| accessIPv6 | |
| config_drive | |
| created | 2016-06-26T14:45:04Z |
| flavor | m1.tiny (1) |
| hostId | e111131d0ba1d28eaf1195847c1538b8e7b791cbdd6f7666083ab383 |
| id | 362151d7-84f7-4043-a723-a852e48922a7 |
| image | Attempt to boot from volume - no image supplied |
| key_name | - |
| metadata | {} |
| name | Erick |
| net network | 10.0.0.9 |
| os-extended-volumes:volumes_attached | [{"id": "cc9c8141-c70c-4a72-91d5-5fa9e15e21d8"}] |
| progress | 0 |
| security_groups | default |
| status | ACTIVE |
| tenant_id | dce7915317f14e6aacad0b6ef84c4483 |
| updated | 2016-06-26T14:45:29Z |
| user_id | 9d20f58520ad43658dceda03cf4e266c |
+--------------------------------------+----------------------------------------------------------+
[[email protected] ~]# rbd ls volumes | grep cc9c8141-c70c-4a72-91d5-5fa9e15e21d8
volume-cc9c8141-c70c-4a72-91d5-5fa9e15e21d8
下面对虚拟机进行关机(必须关机),并删除pool中的内容
[[email protected] ~]# rbd rm -p volumes volume-cc9c8141-c70c-4a72-91d5-5fa9e15e21d8
Removing image: 100% complete...done.
把刚刚备份的虚拟机上传到这个虚拟机中
[[email protected] ~]# rbd import -p volumes /tmp/vm1.bk volume-cc9c8141-c70c-4a72-91d5-5fa9e15e21d8
Importing image: 100% complete...
还原完成!
登入虚拟机查看有无异常
虚拟机可以上网!在此还原完成!
本文出自 “完美世界!” 博客,请务必保留此出处http://shyln.blog.51cto.com/6890594/1795526
以上是关于openstack 利用ceph存储之---备份还原虚拟机的主要内容,如果未能解决你的问题,请参考以下文章