3.4. 为 Ceph 文件系统创建客户端用户
Red Hat Ceph Storage 使用 cephx
进行身份验证,这在默认情况下是启用的。若要将 cephx
与 Ceph 文件系统搭配使用,请在 Ceph 监控节点上创建具有正确授权功能的用户,并在将要挂载 Ceph 文件系统的节点上提供其密钥。
先决条件
- 一个正在运行的 Red Hat Ceph Storage 集群。
- 安装和配置 Ceph 元数据服务器守护进程 (ceph-mds)。
- Ceph 监控节点的根级别访问权限.
- Ceph 客户端节点的根级别访问权限。
流程
在监控节点上登录到 Cephadm shell:
示例
[root@host01 ~]# cephadm shell
在 Ceph 监控节点上,创建一个客户端用户:
语法
ceph fs authorize FILE_SYSTEM_NAME client.CLIENT_NAME /DIRECTORY CAPABILITY [/DIRECTORY CAPABILITY] PERMISSIONS ...
将客户端限制为仅在文件系统
cephfs_a
的temp
目录中写入:示例
[ceph: root@host01 /]# ceph fs authorize cephfs_a client.1 / r /temp rw client.1 key = AQBSdFhcGZFUDRAAcKhG9Cl2HPiDMMRv4DC43A==
要将客户端完全限制到
temp
目录,请删除根 (/
) 目录:示例
[ceph: root@host01 /]# ceph fs authorize cephfs_a client.1 /temp rw
注意提供
all
或星号作为文件系统名称将授予对每个文件系统的访问权限。通常,需要对星号加上引号以避免它在 shell 中被错误使用。验证创建的密钥:
语法
ceph auth get client.ID
示例
[ceph: root@host01 /]# ceph auth get client.1 client.1 key = AQBSdFhcGZFUDRAAcKhG9Cl2HPiDMMRv4DC43A== caps mds = "allow r, allow rw path=/temp" caps mon = "allow r" caps osd = "allow rw tag cephfs data=cephfs_a"
将密钥环复制到客户端。
在 Ceph 监控节点上,将密钥环导出到文件中:
语法
ceph auth get client.ID -o ceph.client.ID.keyring
示例
[ceph: root@host01 /]# ceph auth get client.1 -o ceph.client.1.keyring exported keyring for client.1
将 Ceph 监控节点的客户端密钥环复制到客户端节点上的
/etc/ceph/
目录中:语法
scp /ceph.client.ID.keyring root@CLIENT_NODE_NAME:/etc/ceph/ceph.client.ID.keyring
将 CLIENT_NODE_NAME 替换为 Ceph 客户端节点名称或 IP。
示例
[ceph: root@host01 /]# scp /ceph.client.1.keyring root@client01:/etc/ceph/ceph.client.1.keyring
在客户端节点中,为密钥环文件设置适当的权限:
语法
chmod 644 ceph.client.ID.keyring
示例
[root@client01 ~]# chmod 644 /etc/ceph/ceph.client.1.keyring
其它资源
- 如需了解更多详细信息,请参见 Red Hat Ceph Storage 管理指南中的 用户管理一章。