配置块(cinder)存储服务(可选)

默认情况下,块(cinder)存储服务使用 LVM 后端安装在主机本身上。

注意

虽然这是 cinder 的默认设置,但使用 LVM 后端会导致单点故障。

LVM 后端需要在主机上运行,但是大多数其他后端可以部署在容器内部。如果您的环境中部署的存储后端能够在容器内运行,建议在 env.d/cinder.yml 文件中设置 is_metal: False

注意

由于 容器系统的一个限制,在使用依赖于 iSCSI 的后端时,必须将卷服务直接部署到主机上。例如,对于配置为使用 iSCSI 协议的存储设备而言就是如此。

NFS 后端

如果 NetApp 后端配置为使用 NFS 存储协议,请编辑 /etc/openstack_deploy/openstack_user_config.yml 并配置每个存储节点上的 NFS 客户端。

  1. 对于每个存储节点,在新的 container_vars 部分下添加一个 cinder_backends 块。container_vars 用于允许容器/主机个性化配置。每个 cinder 后端都使用唯一的键定义。例如,nfs-volume1。这后来代表一个唯一的 cinder 后端和卷类型。

    container_vars:
      cinder_backends:
        nfs-volume1:
    
  2. 配置适当的 cinder 卷后端名称

    volume_backend_name: NFS_VOLUME1
    
  3. 配置适当的 cinder NFS 驱动程序

    volume_driver: cinder.volume.drivers.nfs.NfsDriver
    
  4. 配置列出对块存储服务可用的共享的文件的位置。此配置文件必须包含 nfs_shares_config

    nfs_shares_config: FILENAME_NFS_SHARES
    

    FILENAME_NFS_SHARES 替换为共享配置文件位置。例如,/etc/cinder/nfs_shares_volume1

  5. 配置 NFS 挂载的挂载选项。例如

    nfs_mount_options: "rsize=65535,wsize=65535,timeo=1200,actimeo=120"
    
  6. 配置一个或多个 NFS 共享

    shares:
       - { ip: "HOSTNAME", share: "PATH_TO_NFS_VOLUME" }
    

    HOSTNAME 替换为 NFS 服务器的 IP 地址或主机名,并将 PATH_TO_NFS_VOLUME 替换为现有且可访问的 NFS 共享的绝对路径(不包括 IP 地址或主机名)。

以下是名为 NFS1 的 cinder NFS 后端的完整配置示例。cinder playbook 将自动添加一个自定义 volume-typenfs-volume1,如本例所示

container_vars:
  cinder_backends:
    nfs-volume1:
      volume_backend_name: NFS_VOLUME1
      volume_driver: cinder.volume.drivers.nfs.NfsDriver
      nfs_shares_config: /etc/cinder/nfs_shares_volume1
      nfs_mount_options: "rsize=65535,wsize=65535,timeo=1200,actimeo=120"
      shares:
      - { ip: "1.2.3.4", share: "/vol1" }

备份

您可以配置 cinder 将卷备份到对象存储(swift)。启用默认配置以将卷备份到您环境中可访问的 swift 安装。或者,您可以设置 cinder_service_backup_swift_url 和其他变量以备份到外部 swift 安装。

  1. /etc/openstack_deploy/user_variables.yml 文件中添加或编辑以下行,并将值设置为 True

    cinder_service_backup_program_enabled: True
    
  2. 默认情况下,cinder 使用发起备份的用户访问凭据。默认值设置在 /opt/openstack-ansible/playbooks/roles/os_cinder/defaults/main.yml 文件中。您可以通过在 /etc/openstack_deploy/user_variables.yml 中设置变量来覆盖这些默认值,以更改 cinder 执行备份的方式。将以下任何变量添加到 /etc/openstack_deploy/user_variables.yml 文件

    ...
    cinder_service_backup_swift_auth: per_user
    # Options include 'per_user' or 'single_user'. We default to
    # 'per_user' so that backups are saved to a user's swift
    # account.
    cinder_service_backup_swift_url:
    # This is your swift storage url when using 'per_user', or keystone
    # endpoint when using 'single_user'.  When using 'per_user', you
    # can leave this as empty or as None to allow cinder-backup to
    # obtain a storage url from environment.
    cinder_service_backup_swift_url:
    cinder_service_backup_swift_auth_version: 2
    cinder_service_backup_swift_user:
    cinder_service_backup_swift_tenant:
    cinder_service_backup_swift_key:
    cinder_service_backup_swift_container: volumebackups
    cinder_service_backup_swift_object_size: 52428800
    cinder_service_backup_swift_retry_attempts: 3
    cinder_service_backup_swift_retry_backoff: 2
    cinder_service_backup_compression_algorithm: zlib
    cinder_service_backup_metadata_version: 2
    

    在 cinder 安装期间,将配置备份服务。

  3. 如果使用 Horizon,您可能还需要显式定义 horizon_enable_cinder_backup: true 并运行 horizon playbook,以在 Horizon 中启用备份面板。

使用 Ceph 进行 cinder 备份

您可以部署 Ceph 来保存 cinder 卷备份。要开始,请设置 cinder_service_backup_driver Ansible 变量

cinder_service_backup_driver: cinder.backup.drivers.ceph.CephBackupDriver

配置 Ceph 用户和用于备份的池。默认值如下所示

cinder_service_backup_ceph_user: cinder-backup
cinder_service_backup_ceph_pool: backups

可用区

创建多个可用区以管理 cinder 存储主机。编辑 /etc/openstack_deploy/openstack_user_config.yml/etc/openstack_deploy/user_variables.yml 文件以设置可用区。

  1. 对于每个 cinder 存储主机,在 container_vars 节下配置可用区

    cinder_storage_availability_zone: CINDERAZ
    

    CINDERAZ 替换为合适的名称。例如 cinderAZ_2

  2. 如果创建了多个可用区,请通过在 /etc/openstack_deploy/user_variables.yml 中创建一个 cinder_default_availability_zone 来配置所有主机的默认可用区

    cinder_default_availability_zone: CINDERAZ_DEFAULT
    

    CINDERAZ_DEFAULT 替换为合适的名称。例如,cinderAZ_1。默认可用区应与所有 cinder 主机相同。

OpenStack Dashboard(horizon)配置 cinder

您可以配置变量以设置 OpenStack Dashboard(horizon)中 cinder 卷管理的行为。默认情况下,未设置 horizon 配置。

  1. 如果您使用多个可用区并且 cinder_default_availability_zone 没有定义,则默认目标可用区为 nova。如果在没有名为 nova 的可用区的情况下进行卷创建,则 horizon 上的卷创建可能会失败。将 cinder_default_availability_zone 设置为合适的可用区名称,以便 horizon 中的“任何可用区”正常工作。

  2. horizon 默认情况下不会填充卷类型。在新卷页面上,使用默认参数创建卷的请求失败。设置 cinder_default_volume_type,以便在没有显式卷类型的情况下成功进行卷创建请求。

  3. 您还可以配置实例启动菜单的参数,例如隐藏“创建卷”问题并始终为实例创建 Cinder 卷。为此,您可以定义以下变量

    horizon_launch_instance_defaults:
       create_volume: True
       hide_create_volume: True
       disable_image: False
       disable_instance_snapshot: False
       disable_volume: False
       disable_volume_snapshot: False
       default_availability_zone: any
    

    请在 Horizon 文档 中查看此参数的可用选项

配置 cinder 使用 LVM

  1. 列出包含目标主机存储选项的 container_vars

    注意

    与 cinder 可用区和 limit_container_types 相关的变量是可选的。

    要配置 LVM,请使用以下示例

    storage_hosts:
     Infra01:
       ip: 172.29.236.16
       container_vars:
         cinder_storage_availability_zone: cinderAZ_1
         cinder_default_availability_zone: cinderAZ_1
         cinder_backends:
           lvm:
             volume_backend_name: LVM_iSCSI
             volume_driver: cinder.volume.drivers.lvm.LVMVolumeDriver
             volume_group: cinder-volumes
             iscsi_ip_address: "{{ cinder_storage_address }}"
           limit_container_types: cinder_volume
    

要使用容器而不是裸机中的另一个后端,请将 env.d/cinder.yml 复制到 /etc/openstack_deploy/env.d/cinder.yml 文件,并将 cinder_volumes_container 属性下的 is_metal: true 节更改为 is_metal: false

或者,您可以选择性地覆盖,如下所示

container_skel:
  cinder_volumes_container:
    properties:
      is_metal: false

配置 cinder 使用 Ceph

为了使 cinder 使用 Ceph,有必要为 API 和后端进行配置。当使用任何形式的网络存储(iSCSI、NFS、Ceph)作为 cinder 时,API 容器可以被视为后端服务器。不需要单独的存储主机。

env.d/cinder.yml 复制到 /etc/openstack_deploy/env.d/cinder.yml 文件,并将 cinder_volumes_container 属性下的 is_metal: true 节更改为 is_metal: false

或者,您可以选择性地覆盖,如下所示

container_skel:
  cinder_volumes_container:
    properties:
      is_metal: false
  1. 要部署 cinder API 的目标主机列表。我们建议为此服务使用至少三个目标主机。

    storage-infra_hosts:
      infra1:
        ip: 172.29.236.101
      infra2:
        ip: 172.29.236.102
      infra3:
        ip: 172.29.236.103
    

    要配置 RBD 后端,请使用以下示例

    container_vars:
      cinder_storage_availability_zone: cinderAZ_3
      cinder_default_availability_zone: cinderAZ_1
      cinder_backends:
        limit_container_types: cinder_volume
        rbd_backend:
          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: 30
          volume_backend_name: rbd_backend
          rbd_user: "{{ cinder_ceph_client }}"
          rbd_secret_uuid: "{{ cinder_ceph_client_uuid }}"
    

以下示例将 cinder 设置为使用 cinder_volumes 池。该示例使用 cephx 身份验证,需要为 cinder_volumes 池的 cinder 帐户。

user_variables.yml

ceph_mons:
  - 172.29.244.151
  - 172.29.244.152
  - 172.29.244.153

openstack_user_config.yml

storage_hosts:
 infra1:
  ip: 172.29.236.101
  container_vars:
   cinder_backends:
     limit_container_types: cinder_volume
     rbd:
       volume_group: cinder-volumes
       volume_driver: cinder.volume.drivers.rbd.RBDDriver
       volume_backend_name: rbd
       rbd_pool: cinder-volumes
       rbd_ceph_conf: /etc/ceph/ceph.conf
       rbd_user: cinder
 infra2:
  ip: 172.29.236.102
  container_vars:
   cinder_backends:
     limit_container_types: cinder_volume
     rbd:
       volume_group: cinder-volumes
       volume_driver: cinder.volume.drivers.rbd.RBDDriver
       volume_backend_name: rbd
       rbd_pool: cinder-volumes
       rbd_ceph_conf: /etc/ceph/ceph.conf
       rbd_user: cinder
 infra3:
  ip: 172.29.236.103
  container_vars:
   cinder_backends:
     limit_container_types: cinder_volume
     rbd:
       volume_group: cinder-volumes
       volume_driver: cinder.volume.drivers.rbd.RBDDriver
       volume_backend_name: rbd
       rbd_pool: cinder-volumes
       rbd_ceph_conf: /etc/ceph/ceph.conf
       rbd_user: cinder

此链接提供了一个完整的 Ceph 设置和与 cinder(nova 和 glance 包含在内)集成的示例

配置 cinder 使用 Dell EqualLogic

要将 Dell EqualLogic 卷驱动程序用作后端,请编辑 /etc/openstack_deploy/openstack_user_config.yml 文件并配置将使用它的每个存储节点。

定义以下参数。

  1. 为每个存储节点在 cinder_backends 下添加 dellqlx

    cinder_backends:
      delleqlx:
    
  2. 指定卷后端名称

    volume_backend_name: DellEQLX_iSCSI
    
  3. 使用 Dell EQLX San ISCSI 驱动程序

    volume_driver: cinder.volume.drivers.dell_emc.ps.PSSeriesISCSIDriver
    
  4. 指定 SAN IP 地址

    san_ip: ip_of_dell_storage
    
  5. 指定 SAN 用户名(默认:grpadmin)

    san_login: grpadmin
    
  6. 指定 SAN 密码

    san_password: password
    
  7. 指定池的组名(默认:group-0)

    eqlx_group_name: group-0
    
  8. 指定 Cinder 将创建卷和快照的池(默认:default)

    eqlx_pool: default
    
  9. 确保 openstack_user_config.yml 配置准确

    storage_hosts:
      Infra01:
        ip: infra_host_ip
        container_vars:
          cinder_backends:
            limit_container_types: cinder_volume
            delleqlx:
              volume_backend_name: DellEQLX_iSCSI
              volume_driver: cinder.volume.drivers.dell_emc.ps.PSSeriesISCSIDriver
              san_ip: ip_of_dell_storage
              san_login: grpadmin
              san_password: password
              eqlx_group_name: group-0
              eqlx_pool: default
    

配置 cinder 使用 NetApp 设备

要使用 NetApp 存储设备后端,请编辑 /etc/openstack_deploy/openstack_user_config.yml 文件并配置将使用它的每个存储节点。

注意

确保 NAS 团队启用 httpd.admin.access

  1. 为每个存储节点在 cinder_backends 节下添加 netapp

    cinder_backends:
      netapp:
    

    后续步骤中的选项位于 netapp 节下。

    后端名称是任意的,并在 cinder 中成为卷类型。

  2. 配置存储系列

    netapp_storage_family: STORAGE_FAMILY
    

    STORAGE_FAMILY 替换为 ontap_7mode 以使用 7 模式下的 Data ONTAP 操作系统,或 ontap_cluster 以使用作为集群运行的 Data ONTAP 操作系统。

  3. 配置存储协议

    netapp_storage_protocol: STORAGE_PROTOCOL
    

    STORAGE_PROTOCOL 替换为 iscsi 以使用 iSCSI,或 nfs 以使用 NFS。

    对于 NFS 协议,指定列出对 cinder 可用的共享的配置文件的位置

    nfs_shares_config: FILENAME_NFS_SHARES
    

    FILENAME_NFS_SHARES 替换为共享配置文件的位置。例如,/etc/cinder/nfs_shares

  4. 配置服务器

    netapp_server_hostname: SERVER_HOSTNAME
    

    SERVER_HOSTNAME 替换为两个 netapp 控制器的主机名。

  5. 配置服务器 API 端口

    netapp_server_port: PORT_NUMBER
    

    PORT_NUMBER 替换为 HTTP 的 80 或 HTTPS 的 443。

  6. 配置服务器凭据

    netapp_login: USER_NAME
    netapp_password: PASSWORD
    

    USER_NAMEPASSWORD 替换为适当的值。

  7. 选择 NetApp 驱动程序

    volume_driver: cinder.volume.drivers.netapp.common.NetAppDriver
    
  8. 配置卷后端名称

    volume_backend_name: BACKEND_NAME
    

    BACKEND_NAME 替换为一个提供 cinder 调度器提示的值。例如,NETAPP_iSCSI

  9. 确保 openstack_user_config.yml 配置准确

    storage_hosts:
      Infra01:
        ip: 172.29.236.16
        container_vars:
          cinder_backends:
            limit_container_types: cinder_volume
            netapp:
              netapp_storage_family: ontap_7mode
              netapp_storage_protocol: nfs
              netapp_server_hostname: 111.222.333.444
              netapp_server_port: 80
              netapp_login: openstack_cinder
              netapp_password: password
              volume_driver: cinder.volume.drivers.netapp.common.NetAppDriver
              volume_backend_name: NETAPP_NFS
    

    对于 netapp_server_hostname,指定 Data ONTAP 服务器的 IP 地址。根据配置,包括 iSCSI 或 NFS 作为 netapp_storage_family。对于 netapp_server_port,如果使用 HTTP,则添加 80,如果使用 HTTPS,则添加 443。

    cinder-volume.yml playbook 将自动在主机上安装 nfs-common 文件,从而从 LVM 转换为 NetApp 后端。

配置 cinder qos 规范

部署者可以选择定义变量 cinder_qos_specs 以创建 qos 规范。此变量是包含每个 qos 规范选项的字典列表。可以通过在所需的 qos 规范字典中定义键 cinder_volume_types 来将 cinder 卷类型分配给 qos 规范。

- name: high-iops
  options:
    consumer: front-end
    read_iops_sec: 2000
    write_iops_sec: 2000
  cinder_volume_types:
    - volumes-1
    - volumes-2
- name: low-iops
  options:
    consumer: front-end
    write_iops_sec: 100

配置 cinder 创建私有卷类型

默认情况下,定义的 cinder 后端将创建一个公共卷类型。为了创建一个私有卷类型,请添加变量 public 并将其设置为 false。如果设置为 true 或未设置,则创建的卷类型将是公共的。

cinder_backends:
  private_type:
    public: false

共享存储和同步 UID/GID

为 cinder 用户指定自定义 UID 和为 cinder 组指定 GID,以确保在每个主机上它们都相同。当在计算节点上使用共享存储时,这很有帮助,因为它允许实例迁移而不会出现文件系统所有权失败。

默认情况下,Ansible 在不指定 UID 或 GID 的情况下创建 cinder 用户和组。要为 UID 或 GID 指定自定义值,请设置以下 Ansible 变量

cinder_system_user_uid = <specify a UID>
cinder_system_group_gid = <specify a GID>

警告

在部署了 OpenStack-Ansible 的环境之后设置此值可能会导致故障、错误和普遍的不稳定性。这些值应仅在部署 OpenStack 环境之前设置一次,然后不再更改。