zoukankan      html  css  js  c++  java
  • ceph对接OpenStack环境

    1. ceph保存OpenStack的数据

           镜像:glance中的image,/var/lib/glance/images/目录下;

           卷:cinder中的volume;

           虚拟机的磁盘:/var/lib/nova/instances目录下;

    2. 对接步骤

    1> 创建存储池,只需在一个ceph节点上执行即可

    保存镜像:ceph osd pool create images 1024
    保存虚拟机磁盘:ceph osd pool create vms 1024
    保存卷:ceph osd pool create volumes 1024

    查看pool列表

    ceph osd lspools

    2> 在ceph集群中创建glance和cinder用户,只需在一个节点上操作即可。OpenStack中用到ceph集群中的glance和cinder服务,因此要创建这两个用户。nova不需要单独创建用户,nova是单独调用底层的kvm libvirt 使得ceph集群直接对接libvirt。

    ceph auth get-or-create client.glance mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=images'
    
    ceph auth get-or-create client.cinder mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=volumes, allow rwx pool=vms, allow rx pool=images'

    3> 拷贝ceph-ring(令牌环文件)只需在一个ceph节点上操作即可

    ceph auth get-or-create client.glance > /etc/ceph/ceph.client.glance.keyring
    
    ceph auth get-or-create client.cinder > /etc/ceph/ceph.client.cinder.keyring

      使用scp拷贝到其他节点(ceph集群节点和openstack的要用ceph的节点比如compute-node和storage-node,本次对接的是一个all-in-one的环境,所以copy到controller节点即可 

    4> 更改文件的属主和属组,使得相应的用户可以访问文件。所有客户端节点都需要改, 没有用户则创建相应的用户再进行更改。

    chown glance:glance /etc/ceph/ceph.client.glance.keyring
    chown cinder:cinder /etc/ceph/ceph.client.cinder.keyring

    5> 更改libvirt权限,只需在nova-compute节点上操作即可,每个计算节点都做。生成uuid号码,libvirt通过uuid号码调用ceph存储。

    uuidgen
    940f0485-e206-4b49-b878-dcd0cb9c70a4

    6> 在/etc/ceph目录下创建文件secret.xml文件 (在什么目录没有影响,放到/etc/ceph目录方便管理)

    vim /etc/ceph/secret.xml
    <secret ephemeral='no' private='no'>
    <uuid>940f0485-e206-4b49-b878-dcd0cb9c70a4</uuid>
    <usage type='ceph'>
     <name>client.cinder secret</name>
    </usage>
    </secret>

      secret.xml文件相当于一个证书文件,nova利用ceph创建虚拟机,调用kvm虚拟化需要将secret证书创建出来。

    生成secret:
    virsh secret-define --file secret.xml
    
    导入cinder客户端到文件:
    ceph auth get-key client.cinder > ./client.cinder.key
    
    将uuid号码传入到文件:
    virsh secret-set-value --secret 940f0485-e206-4b49-b878-dcd0cb9c70a4 --base64 $(cat ./client.cinder.key)

    所有的计算节点都需要client.cinder.key和secret.xml,

    7> 配置glance镜像服务。

    因为已经更改了存储方式,先登录到OpenStack将以前的镜像删除,先删掉或解绑所有有关镜像的虚拟机或网络

    修改glance镜像配置

    vim /etc/glance/glance-api.conf
    ....
    [DEFAULT]
    default_store = rbd                         #默认存储方式改为rbd
    [glance_store] stores
    = rbd default_store = rbd rbd_store_pool = images rbd_store_user = glance rbd_store_ceph_conf = /etc/ceph/ceph.conf rbd_store_chunk_size = 8 ......

    重新启动glance-api服务

    systemctl restart openstack-glance-api.service
    systemctl status openstack-glance-api.service

    上传镜像

    openstack image create "cirros"   --file cirros-0.3.3-x86_64-disk.img   --disk-format qcow2 --container-format bare --public

    在存储池images查看上传的镜像

    rbd ls images

    8> 配置cinder服务,在存储节点进行修改

    vim /etc/cinder/cinder.conf
    [DEFAULT]
    .....
    enabled_backends = lvm,ceph                       #后端存储
    .....
    [ceph]                                             #ceph驱动
    volume_driver = cinder.volume.drivers.rbd.RBDDriver
    rbd_pool = volumes
    rbd_ceph_conf = /etc/ceph/ceph.conf
    rbd_flatten_volume_from_snapshot = false
    rbd_max_clone_depth = 5
    rbd_store_chunk_size = 4
    rados_connect_timeout = -1
    glance_api_version = 2
    rbd_user = cinder
    rbd_secret_uuid = 940f0485-e206-4b49-b878-dcd0cb9c70a4
    volume_backend_name=ceph

    重启cinder

           控制节点

    systemctl restart openstack-cinder-api.service openstack-cinder-scheduler.service 

           存储节点

    systemctl restart  openstack-cinder-volume.service

    在图形化创建一个卷,看是否能保存在ceph里面(rbd ls volumes)

    9> 配置每个计算节点的nova服务

    vim /etc/nova/nova.conf
    ....
    [libvirt]
    virt_type=qemu
    images_type = rbd                           #镜像类型
    images_rbd_pool = vms                       #存储池
    images_rbd_ceph_conf = /etc/ceph/ceph.conf  #存放位置
    rbd_user = cinder
    rbd_secret_uuid = 940f0485-e206-4b49-b878-dcd0cb9c70a4
    ......

    重启nova服务

      控制节点

    systemctl restart openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service  openstack-nova-compute.service

           计算节点

    systemctl restart openstack-nova-compute.service

    10> 验证

    创建新的虚拟机,选择不创建新卷

    查看块设备

    rdb ls vms

    再创建一台虚拟机,选择创建新卷

    在存储池volumes下查看块存储

    rbd ls volumes
  • 相关阅读:
    C++设计模式 ==> 装饰(者)模式
    基于路由器的VRRP技术--VRRP的应用
    基于路由器的VRRP技术--VRRP的应用
    C++设计模式 ==> 策略模式与简单工厂模式结合
    C++设计模式 ==> 简单工厂模式
    DVWA之Insecure Captcha
    DVWA之Insecure Captcha
    DVWA之File Inclusion
    DVWA之File Inclusion
    DVWA之XSS
  • 原文地址:https://www.cnblogs.com/ajunyu/p/11165873.html
Copyright © 2011-2022 走看看