注意

本文档适用于 Ceph 开发版本。

使用命令行界面配置 iSCSI 目标

Ceph iSCSI 网关既是 iSCSI 目标,也是 Ceph 客户端;

要求:

  • 正在运行的 Ceph Luminous 或更高版本的存储集群

  • Red Hat Enterprise Linux/CentOS 7.5(或更新版本);Linux 内核 v4.16(或更新版本)

  • 以下软件包必须从您的 Linux 发行版的软件仓库中安装:

    • targetcli-2.1.fb47或更新版本软件包

    • python-rtslib-2.1.fb68或更新版本软件包

    • tcmu-runner-1.4.0或更新版本软件包

    • ceph-iscsi-3.2或更新版本软件包

    重要

    如果这些软件包的旧版本存在,则必须在安装新版本之前先删除它们。

在继续进行之前,在 Ceph iSCSI 网关节点上执行以下步骤安装部分:

  1. 如果 Ceph iSCSI 网关不共位于 OSD 节点上,则将 Ceph 配置文件,位于/etc/ceph/,从存储集群中的运行 Ceph 节点复制到 iSCSI 网关节点。Ceph 配置文件必须在 iSCSI 网关节点下存在/etc/ceph/.

  2. 安装和配置Ceph 命令行界面

  3. 如有必要,在防火墙上打开 TCP 端口 3260 和 5000。

    Note

    对端口 5000 的访问应限制在受信任的内部网络或仅限于使用gwcliceph-mgr守护进程运行的单独主机。

  4. 创建一个新的或使用现有的 RADOS 块设备(RBD)。

安装:

如果您正在使用上游的 ceph-iscsi 软件包,请按照手动安装说明.

对于基于 rpm 的说明,执行以下命令:

  1. Asroot,在所有 iSCSI 网关节点上安装ceph-iscsi软件包:

    yum install ceph-iscsi
    
  2. Asroot,在所有 iSCSI 网关节点上安装tcmu-runner软件包:

    yum install tcmu-runner
    

设置:

  1. gwcli 需要一个名为rbd的池,以便它可以存储元数据,例如 iSCSI 配置。要检查此池是否已创建,请运行:

    ceph osd lspools
    

    如果它不存在,可以在RADOS 池操作页面找到创建池的说明.

  2. Asroot,在 iSCSI 网关节点上创建一个名为iscsi-gateway.cfg。Cephadm 还支持使用/etc/ceph/目录:

    touch /etc/ceph/iscsi-gateway.cfg
    
    1. 编辑iscsi-gateway.cfg的文件并添加以下行:

      [config]
      # Name of the Ceph storage cluster. A suitable Ceph configuration file allowing
      # access to the Ceph storage cluster from the gateway node is required, if not
      # colocated on an OSD node.
      cluster_name = ceph
      
      # Place a copy of the ceph cluster's admin keyring in the gateway's /etc/ceph
      # directory and reference the filename here
      gateway_keyring = ceph.client.admin.keyring
      
      
      # API settings.
      # The API supports a number of options that allow you to tailor it to your
      # local environment. If you want to run the API under https, you will need to
      # create cert/key files that are compatible for each iSCSI gateway node, that is
      # not locked to a specific node. SSL cert and key files *must* be called
      # 'iscsi-gateway.crt' and 'iscsi-gateway.key' and placed in the '/etc/ceph/' directory
      # on *each* gateway node. With the SSL files in place, you can use 'api_secure = true'
      # to switch to https mode.
      
      # To support the API, the bare minimum settings are:
      api_secure = false
      
      # Additional API configuration options are as follows, defaults shown.
      # api_user = admin
      # api_password = admin
      # api_port = 5001
      # trusted_ip_list = 192.168.0.10,192.168.0.11
      

      Note

      trusted_ip_list 是每个 iSCSI 网关上的 IP 地址列表,将用于管理操作,如目标创建、LUN 导出等。IP 可以是与 iSCSI 数据(如到/从 RBD 图像的 READ/WRITE 命令)相同的 IP,但建议使用不同的 IP。

      重要

      The iscsi-gateway.cfg文件必须在所有 iSCSI 网关节点上相同。

    2. Asroot,将iscsi-gateway.cfg文件复制到所有 iSCSI 网关节点。

  3. Asroot,在所有 iSCSI 网关节点上启用并启动 API 服务:

    systemctl daemon-reload
    
    systemctl enable rbd-target-gw
    systemctl start rbd-target-gw
    
    systemctl enable rbd-target-api
    systemctl start rbd-target-api
    

配置:

gwcli 将创建和配置 iSCSI 目标和 RBD 图像,并将配置跨最后部分设置的网关复制。可以使用 targetcli 和 rbd 等低级工具查询本地配置,但不应使用它们来修改配置。下一部分将演示如何创建 iSCSI 目标并将 RBD 图像作为 LUN 0 导出。

  1. Asroot,在 iSCSI 网关节点上启动 iSCSI 网关命令行界面:

    gwcli
    
  2. 转到 iscsi-targets 并创建一个名为

    > /> cd /iscsi-targets
    > /iscsi-targets>  create iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw
    
  3. 创建 iSCSI 网关。下面使用的 IP 是将用于 iSCSI 数据(如 READ 和 WRITE 命令)的 IP。它们可以是管理操作中列出的 trusted_ip_list 中的 IP,但建议使用不同的 IP。

    > /iscsi-targets> cd iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/gateways
    > /iscsi-target...-igw/gateways>  create ceph-gw-1 10.172.19.21
    > /iscsi-target...-igw/gateways>  create ceph-gw-2 10.172.19.22
    

    如果不使用 RHEL/CentOS 或使用上游或 ceph-iscsi-test 内核,则必须使用 skipchecks=true 参数。这将避免 Red Hat 内核和 rpm 检查:

    > /iscsi-targets> cd iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/gateways
    > /iscsi-target...-igw/gateways>  create ceph-gw-1 10.172.19.21 skipchecks=true
    > /iscsi-target...-igw/gateways>  create ceph-gw-2 10.172.19.22 skipchecks=true
    
  4. 在池 rbd 中添加一个名为 disk_1 的 RBD 图像:

    > /iscsi-target...-igw/gateways> cd /disks
    > /disks> create pool=rbd image=disk_1 size=90G
    
  5. 创建一个名为 iqn.1994-05.com.redhat:rh7-client 的客户端:

    > /disks> cd /iscsi-targets/iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw/hosts
    > /iscsi-target...eph-igw/hosts>  create iqn.1994-05.com.redhat:rh7-client
    
  6. 设置目标将用于在身份验证发起者时使用的 CHAP 用户名和密码:

    > /iscsi-target...at:rh7-client>  auth username=myusername password=mypassword
    

    警告

    CHAP 必须始终配置。没有 CHAP,目标将拒绝任何登录请求。

    要使用相互(双向)身份验证,还设置目标 CHAP 用户名和密码,发起者将用于在身份验证目标时使用:

    > /iscsi-target...at:rh7-client>  auth username=myusername password=mypassword mutual_username=mytgtusername mutual_password=mytgtpassword
    

    Note

    CHAP 用户名必须为 8 到 64 个字符。有效字符:0to9, atoz, AtoZ, @, _, -, ., :.

    Note

    CHAP 密码必须为 12 到 16 个字符。有效字符:0to9, atoz, AtoZ, @, _, -, /.

    Note

    对于相互 CHAP,发起者和目标的用户名和密码不能相同。

  7. 将磁盘添加到客户端:

    > /iscsi-target...at:rh7-client> disk add rbd/disk_1
    

下一步是配置 iSCSI 发起者。

由 Ceph 基金会带给您

Ceph 文档是一个社区资源,由非盈利的 Ceph 基金会资助和托管Ceph Foundation. 如果您想支持这一点和我们的其他工作,请考虑加入现在加入.