注意
本文档适用于 Ceph 的开发版本。
使用命令行接口配置 iSCSI 目标
Ceph iSCSI 网关既是 iSCSI 目标,也是 Ceph 客户端;可以将其视为 Ceph 的 RBD 接口与 iSCSI 标准之间的“翻译器”。Ceph iSCSI 网关可以运行在独立节点上,也可以与 Ceph Object Store Disk (OSD) 节点等其他守护程序并置。并置时,请确保有足够的 CPU 和内存可供共享。以下步骤将安装和配置 Ceph iSCSI 网关以进行基本操作。
要求
一个正在运行的 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 网关节点上执行以下步骤
如果 Ceph iSCSI 网关未与 OSD 节点并置,则将位于
/etc/ceph/中的 Ceph 配置文件从存储集群中正在运行的 Ceph 节点复制到 iSCSI 网关节点。Ceph 配置文件必须存在于 iSCSI 网关节点的/etc/ceph/下。安装并配置 Ceph 命令行接口
如果需要,在防火墙上打开 TCP 端口 3260 和 5000。
注意
对端口 5000 的访问应仅限于受信任的内部网络,或仅限于使用
gwcli或运行ceph-mgr守护程序的单个主机。创建新的或使用现有的 RADOS 块设备 (RBD)。
安装
如果您使用的是上游 ceph-iscsi 软件包,请遵循 手动安装说明。
对于基于 rpm 的说明,请执行以下命令
以
root身份,在所有 iSCSI 网关节点上,安装ceph-iscsi软件包yum install ceph-iscsi以
root身份,在所有 iSCSI 网关节点上,安装tcmu-runner软件包yum install tcmu-runner
设置
gwcli 需要一个名为
rbd的池,以便存储 iSCSI 配置等元数据。要检查此池是否已创建,请运行ceph osd lspools如果不存在,可以在 RADOS 池操作页面上找到创建池的说明。
以
root身份,在 iSCSI 网关节点上,在/etc/ceph/目录中创建名为iscsi-gateway.cfg的文件touch /etc/ceph/iscsi-gateway.cfg编辑
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
注意
trusted_ip_list 是每个 iSCSI 网关上将用于管理操作(如创建目标、LUN 导出等)的 IP 地址列表。此 IP 可以与用于 iSCSI 数据(如对 RBD 映像的 READ/WRITE 命令)的 IP 相同,但建议使用单独的 IP。
重要
iscsi-gateway.cfg文件在所有 iSCSI 网关节点上必须相同。以
root身份,将iscsi-gateway.cfg文件复制到所有 iSCSI 网关节点。
以
root身份,在所有 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。
以
root身份,在 iSCSI 网关节点上,启动 iSCSI 网关命令行接口gwcli转到 iscsi-targets 并创建一个名为 iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw 的目标
> /> cd /iscsi-targets > /iscsi-targets> create iqn.2003-01.com.redhat.iscsi-gw:iscsi-igw
创建 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
在池 rbd 中添加名为 disk_1 的 RBD 映像
> /iscsi-target...-igw/gateways> cd /disks > /disks> create pool=rbd image=disk_1 size=90G
创建一个启动器名称为 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
设置目标在对启动器进行身份验证时将使用的启动器 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注意
CHAP 用户名长度必须在 8 到 64 个字符之间。有效字符:
0到9,a到z,A到Z,@,_,-,.,:。注意
CHAP 密码长度必须在 12 到 16 个字符之间。有效字符:
0到9,a到z,A到Z,@,_,-,/。注意
对于相互 CHAP,启动器和目标用户名和密码不得相同。
将磁盘添加到客户端
> /iscsi-target...at:rh7-client> disk add rbd/disk_1
下一步是配置 iSCSI 启动器。