External Ceph

Kolla Ansible 不提供直接配置和部署 Ceph 集群的支持。相反,管理员应使用专门为此目的而设计的工具,例如

所需的池(s)和密钥环应通过 Ceph CLI 或类似工具创建。

需求

  • 现有的 Ceph 安装

  • 现有的 Ceph 存储池

  • OpenStack 服务连接到 Ceph 的现有凭据 (Glance, Cinder, Nova, Gnocchi, Manila)

有关创建具有适当权限的池和密钥环的详细信息,请参阅 https://docs.ceph.net.cn/en/2025.2/rbd/rbd-openstack/

配置 External Ceph

Ceph 集成是为不同的 OpenStack 服务独立配置的。

注意

诸如 ceph config generate-minimal-conf 之类的命令会生成包含前导制表符的配置文件。这些制表符会破坏 Kolla Ansible 的 ini 解析器。请确保在以下部分中复制它们时删除 ceph.conf 文件中的前导制表符。

当 OpenStack 服务通过 Ceph 客户端访问 Ceph 时,Ceph 客户端会查找本地密钥环。Ceph 默认情况下使用四个密钥环名称预设密钥环设置。

  • 这四个默认密钥环名称如下

    • /etc/ceph/$cluster.$name.keyring

    • /etc/ceph/$cluster.keyring

    • /etc/ceph/keyring

    • /etc/ceph/keyring.bin

上述第一个和第二个默认密钥环名称中找到的 $cluster 元变量是 Ceph 配置文件名称定义的 Ceph 集群名称:例如,如果 Ceph 配置文件名为 ceph.conf,则 Ceph 集群名称为 ceph,并且上述第二个名称将是 ceph.keyring。上述 $name 元变量是用户类型和用户 ID:例如,给定用户 client.admin,上述第一个名称将是 ceph.client.admin.keyring。此原理应用于以下服务文档。

注意

有关用户配置和相关密钥环的更多信息,请参阅 Ceph 官方文档:https://docs.ceph.net.cn/en/2025.2/rados/operations/user-management/#keyring-management

注意

以下示例使用默认的 $cluster$user,这些可以通过 kolla-ansible 通过设置 ceph_cluster、``$user`` 每项目或在库存文件中的主机级别来配置。

Glance

Ceph RBD 可用作 Glance 镜像的存储后端。为 Ceph 配置 Glance 包括以下步骤

  • globals.yml 中启用 Glance Ceph 后端

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

    • ceph_glance_user (默认: glance)

    • ceph_glance_pool_name (默认: images)

  • 将 Ceph 配置文件复制到 /etc/kolla/config/glance/ceph.conf

    [global]
    fsid = 1d89fec3-325a-4963-a950-c4afedd37fe3
    keyring = /etc/ceph/ceph.client.glance.keyring
    mon_initial_members = ceph-0
    mon_host = 192.168.0.56
    auth_cluster_required = cephx
    auth_service_required = cephx
    auth_client_required = cephx
    
  • 将 Ceph 密钥环复制到 /etc/kolla/config/glance/ceph.client.glance.keyring

要配置具有 Glance 的多个 Ceph 后端,这对于多存储很有用

  • 使用不同的名称将 Ceph 配置文件复制到 /etc/kolla/config/glance/

    /etc/kolla/config/glance/ceph1.conf

    [global]
    fsid = 1d89fec3-325a-4963-a950-c4afedd37fe3
    keyring = /etc/ceph/ceph1.client.glance.keyring
    mon_initial_members = ceph-0
    mon_host = 192.168.0.56
    auth_cluster_required = cephx
    auth_service_required = cephx
    auth_client_required = cephx
    

    /etc/kolla/config/glance/ceph2.conf

    [global]
    fsid = dbfea068-89ca-4d04-bba0-1b8a56c3abc8
    keyring = /etc/ceph/ceph2.client.glance.keyring
    mon_initial_members = ceph-0
    mon_host = 192.10.0.100
    auth_cluster_required = cephx
    auth_service_required = cephx
    auth_client_required = cephx
    
  • globals.yml 中声明 Ceph 后端

    glance_ceph_backends:
      - name: "ceph1-rbd"
        type: "rbd"
        cluster: "ceph1"
        user: "glance"
        pool: "images"
        enabled: "{{ glance_backend_ceph | bool }}"
      - name: "ceph2-rbd"
        type: "rbd"
        cluster: "ceph2"
        user: "glance"
        pool: "images"
        enabled: "{{ glance_backend_ceph | bool }}"
    
  • 将 Ceph 密钥环复制到 /etc/kolla/config/glance/ceph1.client.glance.keyring 以及类似地复制到 /etc/kolla/config/glance/ceph2.client.glance.keyring

  • 对于写时复制,在 /etc/kolla/config/glance.conf 中设置以下内容

    [DEFAULT]
    show_image_direct_url = True
    

警告

show_image_direct_url 如果使用 Ceph 作为 Glance 后端,可能会带来安全风险。请参阅 Glance show_image_direct_url

Cinder

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

  • 在使用外部 Ceph 时,存储组中可能未定义任何节点。这将导致 Cinder 和依赖于此组的相关服务失败。在这种情况下,操作员应将一些节点添加到存储组,所有将运行 cinder-volumecinder-backup 的节点

    [storage]
    control01
    
  • globals.yml 中启用 Cinder Ceph 后端

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

    • ceph_cinder_user (默认: cinder)

    • ceph_cinder_pool_name (默认: volumes)

    • ceph_cinder_backup_user (默认: cinder-backup)

    • ceph_cinder_backup_pool_name (默认: backups)

  • 将 Ceph 配置文件复制到 /etc/kolla/config/cinder/ceph.conf

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

  • 将 Ceph 密钥环文件复制到

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

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

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

注意

cinder-backup 需要密钥环才能访问卷和备份池。

要配置 Cinder 的 多个 Ceph 后端,这对于与可用区一起使用很有用

  • 使用不同的名称将 Ceph 配置文件复制到 /etc/kolla/config/cinder/

    /etc/kolla/config/cinder/ceph1.conf

    [global]
    fsid = 1d89fec3-325a-4963-a950-c4afedd37fe3
    mon_initial_members = ceph-0
    mon_host = 192.168.0.56
    auth_cluster_required = cephx
    auth_service_required = cephx
    auth_client_required = cephx
    

    /etc/kolla/config/cinder/ceph2.conf

    [global]
    fsid = dbfea068-89ca-4d04-bba0-1b8a56c3abc8
    mon_initial_members = ceph-0
    mon_host = 192.10.0.100
    auth_cluster_required = cephx
    auth_service_required = cephx
    auth_client_required = cephx
    
  • globals.yml 中声明 Ceph 后端

    cinder_ceph_backends:
      - name: "ceph1-rbd"
        cluster: "ceph1"
        user: "cinder"
        pool: "volumes"
        enabled: "{{ cinder_backend_ceph | bool }}"
      - name: "ceph2-rbd"
        cluster: "ceph2"
        user: "cinder"
        pool: "volumes"
        availability_zone: "az2"
        enabled: "{{ cinder_backend_ceph | bool }}"
    
      cinder_backup_ceph_backend:
        name: "ceph2-backup-rbd"
        cluster: "ceph2"
        user: "cinder-backup"
        pool: "backups"
        type: rbd
        enabled: "{{ enable_cinder_backup | bool }}"
    
  • 复制所有 Ceph 后端的 Ceph 密钥环文件

    • /etc/kolla/config/cinder/cinder-volume/ceph1.client.cinder.keyring

    • /etc/kolla/config/cinder/cinder-backup/ceph1.client.cinder.keyring

    • /etc/kolla/config/cinder/cinder-backup/ceph2.client.cinder.keyring

    • /etc/kolla/config/cinder/cinder-backup/ceph2.client.cinder-backup.keyring

注意

cinder-backup 需要密钥环才能访问卷和备份池。

Nova 必须也配置为允许访问 Cinder 卷

  • 将 Ceph 配置文件和密钥环文件复制到

    • /etc/kolla/config/nova/ceph.conf

    • /etc/kolla/config/nova/ceph.client.cinder.keyring

要为 nova-compute 主机配置不同的 Ceph 后端,这对于与可用区一起使用很有用

  • 以以下方式编辑库存文件

    [compute]
    hostname1 ceph_cluster=ceph1
    hostname2 ceph_cluster=ceph2
    
  • 复制 Ceph 配置文件和密钥环文件

    • /etc/kolla/config/nova/<hostname1>/ceph1.conf

    • /etc/kolla/config/nova/<hostname1>/ceph1.client.cinder.keyring

    • /etc/kolla/config/nova/<hostname2>/ceph2.conf

    • /etc/kolla/config/nova/<hostname2>/ceph2.client.cinder.keyring

如果启用了 zun,并且希望使用 cinder 卷与 zun,则它也必须配置为允许访问 Cinder 卷

  • globals.yml 中启用 Cinder Ceph 后端

    zun_configure_for_cinder_ceph: "yes"
    
  • 将 Ceph 配置文件复制到

    • /etc/kolla/config/zun/zun-compute/ceph.conf

  • 将 Ceph 密钥环文件复制到

    • /etc/kolla/config/zun/zun-compute/ceph.client.cinder.keyring

Nova

Ceph RBD 可用作 Nova 实例临时磁盘的存储后端。这避免了计算节点上本地存储的要求。由于实例的临时磁盘不需要在超visor 之间复制,因此提高了迁移性能。

为 Ceph 配置 Nova 包括以下步骤

  • globals.yml 中启用 Nova Ceph 后端

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

    • ceph_nova_user (默认情况下,它与 ceph_cinder_user 相同)

    • ceph_nova_pool_name (默认: vms)

  • 将 Ceph 配置文件复制到 /etc/kolla/config/nova/ceph.conf

  • 将 Ceph 密钥环文件复制到

    • /etc/kolla/config/nova/ceph.client.nova.keyring

    注意

    如果使用为 Cinder 和 Nova 生成单独 Ceph 密钥的 Ceph 部署工具,则需要覆盖 ceph_nova_user 以匹配。

要为 nova-compute 主机配置不同的 Ceph 后端,这对于与可用区一起使用很有用

以以下方式编辑库存文件

[compute]
hostname1 ceph_cluster=ceph1
hostname2 ceph_cluster=ceph2
  • 复制 Ceph 配置文件和密钥环文件

    • /etc/kolla/config/nova/<hostname1>/ceph1.conf

    • /etc/kolla/config/nova/<hostname1>/ceph1.client.nova.keyring

    • /etc/kolla/config/nova/<hostname2>/ceph2.conf

    • /etc/kolla/config/nova/<hostname2>/ceph2.client.nova.keyring

Gnocchi

Ceph 对象存储可用作 Gnocchi 指标的存储后端。为 Ceph 配置 Gnocchi 包括以下步骤

  • globals.yml 中启用 Gnocchi Ceph 后端

    gnocchi_backend_storage: "ceph"
    
  • /etc/kolla/globals.yml 中配置 Ceph 身份验证详细信息

    • ceph_gnocchi_user (默认: gnocchi)

    • ceph_gnocchi_pool_name (默认: gnocchi)

  • 将 Ceph 配置文件复制到 /etc/kolla/config/gnocchi/ceph.conf

  • 将 Ceph 密钥环复制到 /etc/kolla/config/gnocchi/ceph.client.gnocchi.keyring

Manila

CephFS 可用作 Manila 共享的存储后端。为 Ceph 配置 Manila 包括以下步骤

  • globals.yml 中启用 Manila Ceph 后端

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

    • ceph_manila_user (默认: manila)

    注意

    Manila 用户所需的 Ceph 身份验证 caps 在 CephFS Native driver 中有记录。

  • 将 Ceph 配置文件复制到 /etc/kolla/config/manila/ceph.conf

  • 将 Ceph 密钥环复制到 /etc/kolla/config/manila/ceph.client.manila.keyring

要配置 Manila 的 多个 Ceph 后端,这对于与可用区一起使用很有用

  • 使用不同的名称将 Ceph 配置文件复制到 /etc/kolla/config/manila/

    /etc/kolla/config/manila/ceph1.conf

    [global]
    fsid = 1d89fec3-325a-4963-a950-c4afedd37fe3
    mon_initial_members = ceph-0
    mon_host = 192.168.0.56
    auth_cluster_required = cephx
    auth_service_required = cephx
    auth_client_required = cephx
    

    /etc/kolla/config/manila/ceph2.conf

    [global]
    fsid = dbfea068-89ca-4d04-bba0-1b8a56c3abc8
    mon_initial_members = ceph-0
    mon_host = 192.10.0.100
    auth_cluster_required = cephx
    auth_service_required = cephx
    auth_client_required = cephx
    
  • globals.yml 中声明 Ceph 后端

    manila_ceph_backends:
      - name: "cephfsnative1"
        share_name: "CEPHFS1"
        driver: "cephfsnative"
        cluster: "ceph1"
        enabled: "{{ enable_manila_backend_cephfs_native | bool }}"
        protocols:
          - "CEPHFS"
      - name: "cephfsnative2"
        share_name: "CEPHFS2"
        driver: "cephfsnative"
        cluster: "ceph2"
        enabled: "{{ enable_manila_backend_cephfs_native | bool }}"
        protocols:
          - "CEPHFS"
      - name: "cephfsnfs1"
        share_name: "CEPHFSNFS1"
        driver: "cephfsnfs"
        cluster: "ceph1"
        enabled: "{{ enable_manila_backend_cephfs_nfs | bool }}"
        protocols:
          - "NFS"
          - "CIFS"
      - name: "cephfsnfs2"
        share_name: "CEPHFSNFS2"
        driver: "cephfsnfs"
        cluster: "ceph2"
        enabled: "{{ enable_manila_backend_cephfs_nfs | bool }}"
        protocols:
          - "NFS"
          - "CIFS"
    
  • 复制所有 Ceph 后端的 Ceph 密钥环文件

    • /etc/kolla/config/manila/manila-share/ceph1.client.manila.keyring

    • /etc/kolla/config/manila/manila-share/ceph2.client.manila.keyring

  • 如果使用多个文件系统 (Ceph Pacific+),请在 /etc/kolla/globals.yml 中设置 manila_cephfs_filesystem_name 为 Manila 应使用的 Ceph 文件系统的名称。默认情况下,Manila 将使用 ceph fs volume ls 命令返回的第一个文件系统。

  • 以通常的方式设置 Manila

有关 Manila 设置的更多详细信息,例如创建共享类型 default_share_type,请参阅 Kolla 中的 Manila

有关 CephFS Native driver 的更多详细信息,请参阅 CephFS Native driver

RadosGW

从 Xena 13.0.0 版本开始,Kolla Ansible 支持与 Ceph RadosGW 集成。这包括

  • 在 Keystone 中注册与 Swift 兼容的端点

  • 使用 HAProxy 在 RadosGW API 服务器之间进行负载均衡

请参阅 Ceph 文档 以获取更多信息,包括必须应用于 Ceph 集群配置的更改。

启用 Ceph RadosGW 集成

enable_ceph_rgw: true

Keystone 集成

默认情况下会注册 Keystone 用户和端点,但是可以通过将 enable_ceph_rgw_keystone 设置为 false 来避免注册。如果启用了注册,则用户名通过 ceph_rgw_keystone_user 定义,默认值为 ceph_rgw。用于公共和内部端点的 hostname 默认值为 ceph_rgw_external_fqdnceph_rgw_internal_fqdn,分别。它们默认值为 kolla_external_fqdnkolla_internal_fqdn。端点使用的端口通过 ceph_rgw_port 定义,默认值为 6780。

默认情况下,RadosGW 同时支持 Swift 和 S3 API,但与 Swift API 并非完全兼容。选项 ceph_rgw_swift_compatibility 可以启用/禁用 RadosGW 与 Swift API 的完全兼容性。这应与 Ceph RadosGW 中使用的配置相匹配。更改值后,运行 kolla-ansible deploy 命令以启用。

默认情况下,RadosGW 端点 URL 不包含项目(帐户)ID。这可以防止跨项目和公共对象访问。可以通过将 ceph_rgw_swift_account_in_url 设置为 true 来解决此问题。这应与 Ceph RadosGW 中的 rgw_swift_account_in_url 配置选项相匹配。

负载均衡

警告

Ceph RadosGW 的用户可能会产生非常高的流量。对于除小型或轻度使用的 RadosGW 部署之外的任何部署,建议使用单独的负载均衡器,但是目前这超出了 Kolla Ansible 的范围。

默认情况下已启用负载均衡,但是可以通过将 enable_ceph_rgw_loadbalancer 设置为 false 来避免。如果使用负载均衡,则必须配置 RadosGW 主机和端口。每个条目应包含 hostport 键。 ipport 键是可选的。如果未指定 ip,则应可以从运行 HAProxy 的主机解析 host 值。如果未指定 port,则将使用默认 HTTP (80) 或 HTTPS (443) 端口。例如

ceph_rgw_hosts:
  - host: rgw-host-1
  - host: rgw-host-2
    ip: 10.0.0.42
    port: 8080

HAProxy 前端端口通过 ceph_rgw_port 定义,默认值为 6780。

Cephadm 和 Ceph 客户端版本

配置 Zun 使用 Cinder 卷时,kolla-ansible 会在 zun-compute 主机上安装一些 Ceph 客户端软件包。可以通过以下方式设置安装的 Ceph 软件包的版本:

  • /etc/kolla/globals.yml 中配置 Ceph 版本详细信息

    • ceph_version (默认值:pacific)