设为首页 收藏本站
查看: 1265|回复: 0

[经验分享] Ceph与OpenStack整合(仅为云主机提供云盘功能)

[复制链接]

尚未签到

发表于 2017-6-24 19:11:11 | 显示全部楼层 |阅读模式
1. Ceph与OpenStack整合(仅为云主机提供云盘功能)                           

  •   创建: linhaifeng,最新修改: 大约1分钟以前

  •   ceph

    •   ceph osd pool create volumes 128 128
    •   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' -o /etc/ceph/ceph.client.cinder.keyring

  •   部署一个cinder-volume节点。部署过程中可能报错(部署过程请参考官方文档)
    报错内容:
    2016-05-25 08:49:54.917 24148 TRACE cinder RuntimeError: Could not bind to 0.0.0.0:8776 after trying for 30 seconds
    问题分析:
    RuntimeError->访问违例,这种情况是由于0.0.0.0:8776端口冲突的问题,如果你讲cinder-api和cinder-schduler,cinder-volume部署在同一台机器
    就会有这个端口冲突的问题,我遇到的情况是haproxy的端口和cinder-api的端口都是8776
    解决方法:
    vim /etc/cinder/cinder.conf
    新增如下两行:
    osapi_volume_listen=172.16.209.17
                                          osapi_volume_listen_port=8776
  •   在ceph的monitor节点创建pool,创建对这个pool有rwx权限的账号,导出该账号的秘钥文件拷贝给cinder-volume节点和需要使用该pool的计算节点,只发送配置文件给cinder-volume节点(计算节点要想获取ceph集群信息由cinder-volume节点告诉他,所以不需要配置文件)

    •   创建存储池volume-pool,请记池的名字,cinder-volume和compute节点都需要在配置文件中指定这个池
    •   创建访问volume-pool这个池的账号,注意:下面我标红的部分 ,账号名字必须是client. 开头(client.cinder其中cinder就是你的账号名,client代表你的角色是客户端,),导出的账号秘钥文件命名规则为ceph.client.账号名.keyring(这个文件必须放到ceph客户端的/etc/ceph目录下)
    •   将ceph集群的配置文件和上一步创建的秘钥文件一并发送给客户端(cinder-volume节点,compute节点),注意:一定要将这两个文件拷贝到ceph客户端的/etc/ceph目录下(cinder.conf中有很多缺省配置,寻找ceph配置文件的路径默认/et/ceph)
    •   scp -r /etc/ceph/ceph.conf  cinder-volume节点ip:/etc/ceph
    •   scp -r /etc/ceph/ceph.client.cinder.keyring cinder-volume节点ip:/et/ceph
    •   scp -r /etc/ceph/ceph.conf  compute节点ip:/etc/ceph
    •   scp -r /etc/ceph/ceph.client.cinder.keyring compute节点ip:/etc/ceph

  •   配置cinder-volume节点

    •   
    •   yum install ceph-common -y
    •   修改 /etc/cinder/cinder.conf:
      [DEFAULT]
      volume_driver = cinder.volume.drivers.rbd.RBDDriver
      storage_availability_zone=blockstrage03-ceph
      rbd_pool = volume-pool
      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
    •   /etc/init.d/openstack-cinder-volume restart
    •   tail -f /var/log/cinder/volume.log
      报错:Unable to update stats, RBDDriver -1.1.0  driver is uninitialized.
      问题分析:cinder-volume无法连接ceph集群导致驱动无法正常初始化,请看2->b->i和2->c 标红部分
      解决方法:参照2->b-i和2->c标红部分指示的命名规则重新命名你的文件,以及文件在客户端的存放路径,重启openstack-cinder-volume服务

  •   配置compute节点,升级qemu-*包,重启libvirtd,制作秘钥文件导入libvirt

    •   [iyunv@compute04 ~]# rpm -qa |grep qemu
      qemu-kvm-tools-0.12.1.2-2.415.el6.3ceph.x86_64
      qemu-kvm-0.12.1.2-2.415.el6.3ceph.x86_64
      gpxe-roms-qemu-0.9.7-6.14.el6.noarch
      qemu-img-0.12.1.2-2.415.el6.3ceph.x86_64
      qemu-guest-agent-0.12.1.2-2.415.el6.3ceph.x86_64
    •   [iyunv@compute04 ~]# virsh version
      Compiled against library: libvirt 0.10.2
      Using library: libvirt 0.10.2
      Using API: QEMU 0.10.2
      Running hypervisor: QEMU 0.12.1
    •   [iyunv@compute04 ~]# /usr/libexec/qemu-kvm -drive format=?
      Supported formats: raw cow qcow vdi vmdk cloop dmg bochs vpc vvfat qcow2 qed vhdx parallels nbd blkdebug host_cdrom host_floppy host_device file gluster gluster gluster gluster rbd
    •   [iyunv@compute04 ~]# /usr/libexec/qemu-kvm -M ?
      Supported machines are:
      pc         RHEL 6.5.0 PC (alias of rhel6.5.0)
      rhel6.5.0  RHEL 6.5.0 PC (default)
      rhel6.4.0  RHEL 6.4.0 PC
      rhel6.3.0  RHEL 6.3.0 PC
      rhel6.2.0  RHEL 6.2.0 PC
      rhel6.1.0  RHEL 6.1.0 PC
      rhel6.0.0  RHEL 6.0.0 PC
      rhel5.5.0  RHEL 5.5.0 PC
      rhel5.4.4  RHEL 5.4.4 PC
      rhel5.4.0  RHEL 5.4.0 PC
      如果升级后新建虚拟机碰到上述提示信息,可以修改虚拟机的xml配置文件,machine=‘rhel6.5.0’或者干脆删掉machine,然后用virsh define 虚拟机名字.xml
      <os>
          <type arch='x86_64' machine='rhel6.5.0'>hvm</type>
          <boot dev='hd'/>
          <smbios mode='sysinfo'/>
        </os>
    •   
    •   yum install ceph-common -y
    •   注意:目前生产环境是基于centos6.5构建openstack I版本,openstack-nova-compute-2014.1.5-1.el6.noarch->libvirt-python-0.10.2-54->libvirt 0.10.2-> QEMU 0.12.1,而这个版本的QEMU不支持rbd协议,openstack-nova-compute-2014.1.5-1只支持ibvirt-python-0.10.2-54,如果你升级
      libvirt那么相应的libvirt-python也要升级,进而openstack-nova-compute也要升级,其实你只需要用同一版本的qemu带ceph支持的包替换原来的qemu版本就可以了。
    •   查看命令(升级后的结果应该是这样)
    •   升级方法:          Supported formats: raw cow qcow vdi vmdk cloop dmg bochs vpc vvfat qcow2 qed vhdx parallels nbd blkdebug host_cdrom host_floppy host_device file gluster gluster gluster gluster rbd --------------->看到这个证明升级成功
    •   制作secret.xml文件,注意标红部分必须是2->b->i指定的名字
    •   virsh secret-define --file secret.xml
    •   找到刚刚定义的client.cinder用户的uuid
    •   找到ceph提供的秘钥文件的秘钥
    •   virsh secret-set-value $(virsh secret-list |grep client.cinder |awk '{print $1}') --base64  $(cat /etc/ceph/ceph.client.cinder.keyring |awk 'NR==2{print $3}')
    •   vim /etc/nova/nova.conf
      rbd_user=cinde
      rbd_secret_uuid=dda10a4e-c03c-b029-ef07-ce86e7a07bdd        ------------------>值为:virsh secret-list |grep client.cinder |awk '{print $1}
    •   /etc/init.d/openstack-nova-compute restart
    •   cat /etc/ceph/ceph.client.cinder.keyring
    •   virsh secret-list
    •   cat > secret.xml <<EOF
      <secret ephemeral='no' private='no'>
        <usage type='ceph'>
          <name>client.cinder secret</name>
        </usage>
      </secret>
      EOF
    •   链接:http://172.16.201.36/qemu-kvm-for-ceph/或者http://apt-mirror.sepia.ceph.com/centos6-qemu-kvm/
    •   下载qemu-开头的包,放到本地路径
    •   切换到本地路径下执行rpm -Uvh qemu-* --force
    •   service libvirtd restart
    •   /usr/libexec/qemu-kvm -drive format=?

  延伸:cinder为云主机提供云盘,在计算节点的映射关系
  分析:在为云主机添加完云盘后,进入该云主机所在的计算机点
  进入云主机fdisk -l,可以发现新增了一块硬盘
  进入云主机所在的计算节点,发现同样新增了一块硬盘
  问题就是,cinder服务其实就是把硬盘映射给了计算节点,读写请求都交给计算节点去做,然后计算节点负责把该硬盘映射给自己虚拟出来的云主机
  在计算节点:
  一:                                     1.
  [iyunv@compute03 by-path]# ll /dev/disk/by-path/ip-10.5.0.20\:3260-iscsi-iqn.2010-10.org.openstack\:volume-26f04424-7ddb-4756-9648-e023b84bcd5e-lun-1
  lrwxrwxrwx. 1 root root 9 May 25 18:43 /dev/disk/by-path/ip-10.5.0.20:3260-iscsi-iqn.2010-10.org.openstack:volume-26f04424-7ddb-4756-9648-e023b84bcd5e-lun-1 -> ../../sdb
  二:
  [iyunv@compute03 by-path]# cat /etc/libvirt/qemu/instance-00000031.xml |grep disk
<disk type='file' device='disk'>
<source file='/var/lib/nova/instances/db14cd53-b791-4f0b-91cd-0e160dd7b794/disk'/>
</disk>
<disk type='block' device='disk'>
<source dev='/dev/disk/by-path/ip-10.5.0.20:3260-iscsi-iqn.2010-10.org.openstack:volume-26f04424-7ddb-4756-9648-e023b84bcd5e-lun-1'/>
</disk>

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-387660-1-1.html 上篇帖子: 文章汇总(包括NVMe SPDK vSAN Ceph xfs等) 下篇帖子: ceph rbd扩容
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表