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

[经验分享] Openstack 集成 Ceph 基础篇(一)

[复制链接]

尚未签到

发表于 2017-6-26 20:58:39 | 显示全部楼层 |阅读模式
  详细配置也可以参考Ceph官方文档:http://docs.ceph.org.cn/rbd/rbd-openstack/
  环境介绍:
  Openstack   controller+compute
  Openstack-compute   compute
  ceph001 OSD+Mon+MDS
  ceph002 OSD+MDS
  以上环境已提前准备完成,下面正式开始。

Ceph 中的配置
  (1) 在 ceph 中创建三个 pool 分别给 Cinder,Glance 和 nova 使用



cephadmin@ceph001:~$ ceph osd pool create volumes 64
pool 'volumes' created
cephadmin@ceph001:~$ ceph osd pool create images 64
pool 'images' created
cephadmin@ceph001:~$ ceph osd pool create vms 64
pool 'vms' created

  (2) 将Ceph配置文件Copy到Openstack各节点中
  The nodes running glance-api, cinder-volume, nova-compute and cinder-backup act as Ceph clients. Each requires the ceph.conffile:



root@ceph001:~# ssh openstack tee /etc/ceph/ceph.conf < /etc/ceph/ceph.conf
root@openstack's password:
[global]
fsid = 4f1100a0-bc37-4472-b0b0-58b44eabac97
mon_initial_members = ceph001
mon_host = 192.168.20.178
auth_cluster_required = cephx
auth_service_required = cephx
auth_client_required = cephx
filestore_xattr_use_omap = true
osd_pool_default_size = 2
root@ceph001:~# ssh openstack-compute tee /etc/ceph/ceph.conf < /etc/ceph/ceph.conf
The authenticity of host 'openstack-compute (192.168.20.182)' can't be established.
ECDSA key fingerprint is b7:bf:c5:81:0d:a0:2a:2d:94:2f:c1:16:78:f3:9f:b2.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'openstack-compute,192.168.20.182' (ECDSA) to the list of known hosts.
root@openstack-compute's password:
[global]
fsid = 4f1100a0-bc37-4472-b0b0-58b44eabac97
mon_initial_members = ceph001
mon_host = 192.168.20.178
auth_cluster_required = cephx
auth_service_required = cephx
auth_client_required = cephx
filestore_xattr_use_omap = true
osd_pool_default_size = 2

  (3) 在各节点上安装ceph 客户端
  http://docs.ceph.com/docs/master/rbd/rbd-openstack/
  On the glance-api node, you’ll need the Python bindings for librbd:
  #apt-get install python-ceph   //好像N版openstack已经自带了,并且官方介绍的是安装python-rbd 各种源都找不到这个包,手动下载也无法安装提示和python-ceph有冲突
  On the nova-compute, cinder-backup and on the cinder-volume node, use both the Python bindings and the client command line tools:
  #apt-get install ceph-common
  (4) SETUP CEPH CLIENT AUTHENTICATION
  If you have cephx authentication enabled, create a new user for Nova/Cinder and Glance. Execute the following:



#cinder 用户会被 cinder 和 nova 使用,需要访问三个pool: volumes,vms 为rwx权限,images为rx权限



#glance 用户只会被 Glance 使用,只需要访问 images 这个 pool



root@ceph001:~# 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'
[client.cinder]
key = AQBJg5hYuD0gHBAAproupKDYIuq0QemTnPMYdA==
root@ceph001:~# ceph auth get-or-create client.glance mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=images'
[client.glance]
key = AQC4g5hYMEVgGxAAoaVq50KgWV/y6YPzeHteGA==
root@ceph001:~#

  (5) 将 client.cinder 和 client.glance 的 keystring 文件拷贝到各节点并设置访问权限



ceph auth get-or-create client.glance | ssh openstack sudo tee /etc/ceph/ceph.client.glance.keyring
ssh openstack  sudo chown glance:glance /etc/ceph/ceph.client.glance.keyring    //我这里的openstack环境是devstack,所以应该将glance用户替换为stack
ceph auth get-or-create client.cinder | ssh openstack  sudo tee /etc/ceph/ceph.client.cinder.keyring
ssh openstack sudo chown cinder:cinder /etc/ceph/ceph.client.cinder.keyring  //我这里的openstack环境是devstack,所以应该将cinder用户替换为stack
ceph auth get-or-create client.cinder | ssh openstack-compute sudo tee /etc/ceph/ceph.client.cinder.keyring
  Create a temporary copy of the secret key on the nodes running nova-compute:



ceph auth get-key client.cinder | ssh openstack tee client.cinder.key
ceph auth get-key client.cinder | ssh openstack-compute tee client.cinder.key

  Then, on the compute nodes, add the secret key to libvirt and remove the temporary copy of the key:



root@openstack:~# uuidgen
2862d317-e8df-4a5c-af7a-387ab2bc7ef5
root@openstack:/etc/ceph# ls
ceph.client.cinder.keyring  ceph.client.glance.keyring  ceph.conf
root@openstack:/etc/ceph# cat > secret.xml <<EOF
> <secret ephemeral='no' private='no'>
>  <uuid>2862d317-e8df-4a5c-af7a-387ab2bc7ef5</uuid>
>  <usage type='ceph'>
>   <name>client.cinder secret</name>
>  </usage>
> </secret>
>
> EOF
root@openstack:~#  virsh secret-define --file secret.xml
Secret 2862d317-e8df-4a5c-af7a-387ab2bc7ef5 created
root@openstack:~# virsh secret-set-value --secret 2862d317-e8df-4a5c-af7a-387ab2bc7ef5 --base64 $(cat client.cinder.key) && rm client.cinder.key secret.xml
Secret value set
root@openstack:~#
//在所有nova-compute节点都需要执行以上操作
//openstack-compute uuid c0f5d1a4-b086-4c0c-984e-2f4e84f0f9c5
//Important: You don’t necessarily need the UUID on all the compute nodes. However from a platform consistency perspective, it’s better to keep the same UUID.
CONFIGURE OPENSTACK TO USE CEPH
  (1) CONFIGURING GLANCE
  Edit /etc/glance/glance-api.conf and add under the [DEFAULT] section:



[glance_store]
stores = glance.store.rbd.Store
default_store = rbd
rbd_store_pool = images
rbd_store_user = glance
rbd_store_ceph_conf = /etc/ceph/ceph.conf
rbd_store_chunk_size = 8
If you want to enable copy-on-write cloning of images, also add under the [DEFAULT] section:
show_image_direct_url = True

  (2) CONFIGURING CINDER
  OpenStack requires a driver to interact with Ceph block devices. You must also specify the pool name for the block device. On your OpenStack node, edit /etc/cinder/cinder.conf by adding:



[DEFAULT]
...
enabled_backends = 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 = stack
rbd_secret_uuid = 2862d317-e8df-4a5c-af7a-387ab2bc7ef5

  (3) CONFIGURING NOVA



在每个计算节点上的 /etc/nova/nova.conf 文件中做如下修改:
[libvirt]
images_type = rbd #只有在 boot disk 放在 ceph 中才需要配置这个,否则,设置为 qcow2
images_rbd_pool = vms
images_rbd_ceph_conf = /etc/ceph/ceph.conf
rbd_user = cinder
rbd_secret_uuid = e21a123a-31f8-425a-86db-7204c33a6161
disk_cachemodes="network=writeback"
hw_disk_discard = unmap
inject_password = false
inject_key = false
inject_partition = -2
live_migration_flag="VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_PERSIST_DEST,VIR_MIGRATE_TUNNELLED"
  重启服务

glance,cinder,nova


环境验证



  未完待续...

运维网声明 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-388387-1-1.html 上篇帖子: OpenStack+Ceph存储空间回收《转》 下篇帖子: openstack的glance、nova、cinder使用ceph做后端存储
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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