4.2. 启用和禁用 Cephx
启用 Cephx 要求您已部署 monitor 和 OSD 的密钥。如果您简单地在 / off 上切换 Cephx,则不必重复引导过程。
4.2.1. 启用 Cephx 复制链接链接已复制到粘贴板!
启用 cephx 后,Ceph 将在默认搜索路径中查找密钥环,其中包括 /etc/ceph/$cluster.$name.keyring。您可以通过在 Ceph 配置文件的 [global] 部分添加 keyring 选项来覆盖该位置,但不建议这样做。
执行以下步骤,在禁用身份验证的集群中启用 cephx。如果您或部署实用程序生成了密钥,您可以跳过与生成密钥相关的步骤。
创建
client.admin密钥,并为您的客户端主机保存密钥副本:ceph auth get-or-create client.admin mon 'allow *' osd 'allow *' -o /etc/ceph/ceph.client.admin.keyring警告这将擦除任何现有
/etc/ceph/client.admin.keyring文件的内容。如果部署工具已为您完成,则不要执行此步骤。为 monitor 集群创建密钥环,并生成监控器 secret 密钥:
ceph-authtool --create-keyring /tmp/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *'将 monitor keyring 复制到每个 monitor mon
数据目录中的文件。例如,要将其复制到 clusterceph.mon.keyringceph中的mon.a中,请使用:cp /tmp/ceph.mon.keyring /var/lib/ceph/mon/ceph-a/keyring为每个 OSD 生成 secret 密钥,其中
{$id}是 OSD 号:ceph auth get-or-create osd.{$id} mon 'allow rwx' osd 'allow *' -o /var/lib/ceph/osd/ceph-{$id}/keyring默认情况下启用
cephx身份验证协议。注意如果以前通过将身份验证选项设置为
none来禁用cephx身份验证协议,那么请在 Ceph 配置文件[global]部分 (/etc/ceph/ceph.conf) 下删除 [global] 部分下的以下行,则会重新启用cephx身份验证协议:auth_cluster_required = none auth_service_required = none auth_client_required = none启动或重启 Ceph 集群。
重要启用
cephx需要停机,因为集群需要完全重启,或者在禁用客户端 I/O 时将其关闭并启动。这些标记需要在重启或关闭存储集群前设置:
# ceph osd set noout # ceph osd set norecover # ceph osd set norebalance # ceph osd set nobackfill # ceph osd set nodown # ceph osd set pause启用
cephx后,所有 PG 都活跃且干净,取消设置标记:# ceph osd unset noout # ceph osd unset norecover # ceph osd unset norebalance # ceph osd unset nobackfill # ceph osd unset nodown # ceph osd unset pause