kolla-ansible使用OpenStack接入Ceph

半兽人 发表于: 2023-02-16   最后更新时间: 2023-02-22 11:46:55  
{{totalSubscript}} 订阅, 1,185 游览

本教程将介绍如何使用基于Kolla Ansible工具安装的OpenStack集群,接入Ceph的方法。

先决条件

已经部署完成的 OpenStack 和 Ceph 集群

Ceph 设置

RBD Pool

OpenStack Nova, Cinder (Cinder Backup), Glance 都可以使用 RBD 作为存储Backend,所以需要为这三个 service 创建其使用的 RBD Pool:

ceph osd pool create volumes
ceph osd pool create images
ceph osd pool create backups
ceph osd pool create vms

新创建的 Pool 必须在使用前进行初始化,使用 rbd 工具初始化:

rbd pool init volumes
rbd pool init images
rbd pool init backups
rbd pool init vms

设置 Ceph 客户端身份验证

Ceph是通过Keyring做认证的,所以同样的,需要为这3个service创建对应的Keyring,并给其赋对应Pool的权限:

ceph auth get-or-create client.glance mon 'profile rbd' osd 'profile rbd pool=images' mgr 'profile rbd pool=images'

ceph auth get-or-create client.cinder mon 'profile rbd' osd 'profile rbd pool=volumes, profile rbd pool=vms, profile rbd-read-only pool=images' mgr 'profile rbd pool=volumes, profile rbd pool=vms'

ceph auth get-or-create client.cinder-backup mon 'profile rbd' osd 'profile rbd pool=backups' mgr 'profile rbd pool=backups'

以上执行完成后,可以通过以下命令,查看创建好的权限信息:

ceph auth list

参考 openstack集成ceph 以了解有关为每个服务创建具有适当权限池和密钥的详细介绍。

Glance

  1. globals.yml 中启用 Glance Ceph Backend,编辑 /etc/kolla/globals.yml,加入:

    glance_backend_ceph: "yes"
    
  2. /etc/kolla/globals.yml 中配置 Ceph 身份验证(如果默认的,不用配置,可跳过):

    • ceph_glance_keyring (默认: ceph.client.glance.keyring)
    • ceph_glance_user (默认: glance)
    • ceph_glance_pool_name (默认: images)
  3. 复制 ceph.conf 文件到 /etc/kolla/config/glance/ceph.conf

  4. 复制 Ceph keyring

    ceph auth get-or-create client.glance
    

    将输出结果存入:/etc/kolla/config/glance/ceph.client.glance.keyring

  5. /etc/kolla/config/glance.conf 中的启动写时复制:

    [GLOBAL]
    show_image_direct_url = True
    

    警告
    show_image_direct_url 如果不仅仅使用 Ceph 作为 Glance 后端话,可能会带来安全风险。

Cinder

Ceph RBD 可用作 Cinder 卷的存储后端,配置 Cinder 包括以下步骤:

  1. 当使用外部Ceph时,存储组中可能没有定义节点。这将导致依赖该组的 Cinder 和相关服务失败。在这种情况下,你应该添加一些节点到存储组,所有的节点都要运行cinder-volumecinder-backup

    [storage]
    control01
    
  2. 在 globals.yml 中启用 Cinder Ceph backend:

    cinder_backend_ceph: "yes"
    
  3. 在 /etc/kolla/globals.yml 中配置Ceph认证(如果不自定义,则跳过):

    • ceph_cinder_keyring (默认: ceph.client.cinder.keyring)
    • ceph_cinder_user (默认: cinder)
    • ceph_cinder_pool_name (默认: volumes)
    • ceph_cinder_backup_keyring (默认: ceph.client.cinder-backup.keyring)
    • ceph_cinder_backup_user (默认: cinder-backup)
    • ceph_cinder_backup_pool_name (默认: backups)
  4. 复制 ceph.conf 文件到 /etc/kolla/config/cinder/ceph.conf

    通过将 ceph.conf 文件分别添加到 /etc/kolla/config/cinder/cinder-volume/etc/kolla/config/cinder/cinder-backup,可以为 cinder-volumecinder-backup 配置单独的配置选项。最后,它们将和 /etc/kolla/config/cinder/ceph.conf 进行合并。

  5. 复制 Ceph keyring

    同样,在ceph中获取秘钥:

    ceph auth get-or-create client.cinder-backup
    

    将输出结果存入:/etc/kolla/config/cinder/cinder-backup/ceph.client.cinder-backup.keyring

    获取client秘钥:

    ceph auth get-or-create client.cinder
    

    将输出结果存入:

    • /etc/kolla/config/cinder/cinder-backup/ceph.client.cinder.keyring
    • /etc/kolla/config/cinder/cinder-volume/ceph.client.cinder.keyring

    注意:cinder-backup 需要两个密钥分别来访问backup pool

Nova

Ceph RBD 可用作 Nova 实例临时磁盘的存储后端。 这避免了对计算节点上实例的本地存储的要求。它提高了迁移性能,因为实例的临时磁盘不需要在管理程序之间复制。

为 Ceph 配置 Nova 包括以下步骤:

  1. 在 globals.yml 启用 Nova Ceph backend:

    nova_backend_ceph: "yes"
    
  2. 在 /etc/kolla/globals.yml 中配置 Ceph 身份验证详细信息:

    • ceph_nova_keyring (默认,与 ceph_cinder_keyring 相同)
    • ceph_nova_user (默认与 ceph_cinder_user 相同)
    • ceph_nova_pool_name (默认: vms)
  3. 复制 ceph.conf 到 /etc/kolla/config/nova/ceph.conf

  4. 复制 Ceph keyring:

    ceph auth get-or-create client.cinder
    

    将输出结果存入:/etc/kolla/config/nova/ceph.client.cinder.keyring

如果你用到了zun、Gnocchi、Manila、RadosGW,则相关配置参考文章最后的原文链接。

配置

Glance 配置

编辑 /etc/kolla/config/glance/glance-api.conf,在 [DEFAULT][glance_store]部分下添加:

[DEFAULT]
show_image_direct_url = True

[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

Cinder 配置

编辑 /etc/kolla/cinder/cinder.conf,增加:

[DEFAULT]
...
enabled_backends = ceph
glance_api_version = 2
...
[ceph]
rbd_user = cinder
rbd_secret_uuid = 457eb676-33da-42ec-9a8c-9293d545c337
volume_driver = cinder.volume.drivers.rbd.RBDDriver
volume_backend_name = ceph
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

注意你的rbd_userrbd_secret_uuid账密别错了。

Cinder Backup 配置

OpenStack Cinder Backup 需要一个特定的守护进程,所以不要忘记安装它。在你的 Cinder 备份节点上,编辑/etc/cinder/cinder.conf并添加:

[DEFAULT]
backup_driver = cinder.backup.drivers.ceph.CephBackupDriver
backup_ceph_conf = /etc/ceph/ceph.conf
backup_ceph_user = cinder-backup
backup_ceph_chunk_size = 134217728
backup_ceph_pool = backups
backup_ceph_stripe_unit = 0
backup_ceph_stripe_count = 0
restore_discard_excess_bytes = true

Nova 附加 Ceph RBD 块设备配置

[libvirt]
rbd_user = cinder
rbd_secret_uuid = 457eb676-33da-42ec-9a8c-9293d545c337

执行

kolla-ansible -i multinode reconfigure

重启容器。

(完)

相关

https://docs.openstack.org/kolla-ansible/latest/reference/storage/external-ceph-guide.html

更新于 2023-02-22

查看OpenStack更多相关的文章或提一个关于OpenStack的问题,也可以与我们一起分享文章