温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何配置Ceph rbd为虚拟机提供块设备

发布时间:2021-12-07 14:27:11 来源:亿速云 阅读:255 作者:小新 栏目:云计算

小编给大家分享一下如何配置Ceph rbd为虚拟机提供块设备,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

###安装qemu(高版本)

# tar –jxvf qemu2.1.3.tar.bz
# cd qemu 2.1.3
# ./configure --enable-rbd #这里很重要,不然qemu无法识别rbd
# make
# make install

###安装 libvirt

# yum install libvirt

创建rbd镜像

命令:qemu-img create -f raw rbd:{pool-name}/{image-name} {size}

# qemu-img create -f raw rbd:data/foo 1G

##利用libvirt创建虚拟机

创建虚拟机配置文件

# vim linux.xml

编辑内容如下

<domain type='qemu'>
<name>myos</name> #虚拟机domain
<uuid></uuid>
<memory>512000</memory>
<currentMemory>512000</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='cdrom'/>
<boot dev='hd'/>
</os>
<devices>
<emulator>/usr/local/bin/qemu-system-x86_64</emulator>
<disk type='file' device='cdrom'>
<source file='/usr/src/ubuntu-10.04-desktop-i386.iso'/>
<target dev='hdc'/>
<readonly/>
</disk>
# 配置ceph rbd
<disk type='network' device='disk'>
<auth username='data'>
<secret type='ceph' uuid='2d833661-e55a-de95-bf0e-6d7d30e329c7'/>
</auth>
<source protocol='rbd' name='data/foo'>
<host name='10.20.15.156' port='6789'/> #mon ip 和port
</source>
# 为虚拟机提供的块设备名称
<target dev='vda' bus='virtio'/>
</disk>
# end
<graphics type='vnc' port='5901' listen='127.0.0.1'/>
</devices>
</domain>

创建虚拟机

# virsh define linux.xml  //创建虚拟机
# virsh start myos        //启动虚拟机 
# virsh vncdisplay 5901   //通过vnc查看虚拟机,完成安装
# fdisk -l                //查看块设备

看完了这篇文章,相信你对“如何配置Ceph rbd为虚拟机提供块设备”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI