天天看点

CentOS 6.5下配置Ceph作为KVM后端存储配置环境配置步骤

配置环境

Centos 6.5 X86_64 Ceph 0.80.7 Qemu-kvm 0.12.1.2

配置步骤

ceph的安装步骤不在这里说明,网上有太多,这里仅介绍如何配置ceph作为kvm的后端存储使用。

qemu安装

#git clone git://git.qemu-project.org/qemu.git
#cd qemu
#./configure –enable-rbd –enable-glusterfs
#make
#make install
           

配置ceph

 编写密钥文件secret.xml

<secret ephemeral='no' private='no'>
   <usage type='ceph'>
     <name>client.admin secret</name>
   </usage>
</secret>
           

生成密钥

virsh secret-define --file secret.xml
           

将密钥文件与ceph密钥文件进行匹配

virsh secret-set-value  76e3a541-b997-58ac-f7bd-77dd7d4347cb AQAREH1QkNDNCBaac03ZICi/CePnRDS+vGyrqQ==
           

创建rbd用于kvm使用

#rbd create rbd-vol1 --size 20480
           

创建VM

编写xml文件如下

<domain type='kvm'>
    <name>ceph-linux</name>
    <os>
    <type arch='x86_64' machine='pc'>hvm</type>
    <boot dev='hd'/>
   </os>
    <features>
        <acpi/>
    </features>
    <memory>4096000</memory>
    <vcpu>4</vcpu>
    <devices>
        <emulator>/root/qemu/x86_64-softmmu/qemu-system-x86_64</emulator>
<disk type='network' device='disk'>
   <driver name='qemu' type='raw' cache='none'/>
   <auth username='admin'>
        <secret type='ceph' uuid='76e3a541-b997-58ac-f7bd-77dd7d4347cb' />
   </auth>
   <source protocol='rbd' name='rbd/rbd-vol1'>
        <host name='10.10.200.61' port='6789'/>
        <host name='10.10.200.62' port='6789'/>
    </source>
   <target dev='vda' bus='virtio'/>
   <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>
<disk type='file' device='cdrom'>
            <source file='/var/lib/libvirt/images/CentOS-6.0-x86_64-bin-DVD1.iso'/>
            <target dev='hdc'/>
            <readonly/>
        </disk>
        <interface type='bridge'>
            <source bridge='br0'/>
            <model type='rtl8139'/>
        </interface>
        <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'/>
    </devices>
</domain>
           

启动VM

#virsh create ceph-centos.xml
           

通过以上操作就完成了配置ceph作为kvm的后端存储使用

继续阅读