Ceph学习 -9.认证管理-用户实践

文章目录

  • 1.用户实践
    • [1.1 基础知识](#1.1 基础知识)
    • [1.2 简单实践](#1.2 简单实践)
    • [1.3 小结](#1.3 小结)

1.用户实践

学习目标:这一节,我们从 基础知识、简单实践、小结 三个方面来学习。

1.1 基础知识

简介

shell 复制代码
在ceph中,针对用户主要有两种场景:增删和导出导入

命令解析

shell 复制代码
添加用户:
	ceph auth add:创建用户、生成密钥并添加指定的caps
	ceph auth get-or-create:创建用户并返回密钥文件格式的密钥信息,用户存在时返回密钥信息
	ceph auth get-or-create-key:创建用户并返回密钥信息,用户存在时返回密钥信息

注意:
	典型的用户至少对 Ceph monitor 具有读取功能,并对 Ceph OSD 具有读取和写入功能;
	另外,用户的 OSD 权限通常应该限制为只能访问特定的存储池,
	否则,他将具有访问集群中所有存储池的权限
shell 复制代码
导入用户:
	命令:ceph auth import
shell 复制代码
修改用户caps:
	命令:ceph auth caps
		会覆盖用户现有的caps,因此建立事先使用ceph auth get TYPE.ID命令查看用户的caps

	若是为添加caps,则需要先指定现有的caps,命令格式如下:
		ceph auth caps TYPE.ID daemon 'allow [r|w|x|*|...] [pool=pool-name]' ...
shell 复制代码
删除用户:
	命令:ceph auth del TYPE.ID

1.2 简单实践

添加用户

shell 复制代码
查看帮助信息:
[cephadm@admin ceph-cluster]$ ceph auth --help

 General usage:
 ==============
usage: ceph [-h] [-c CEPHCONF] [-i INPUT_FILE] [-o OUTPUT_FILE]
            [--setuser SETUSER] [--setgroup SETGROUP] [--id CLIENT_ID]
            [--name CLIENT_NAME] [--cluster CLUSTER]
            [--admin-daemon ADMIN_SOCKET] [-s] [-w] [--watch-debug]
            [--watch-info] [--watch-sec] [--watch-warn] [--watch-error]
            [--watch-channel {cluster,audit,*}] [--version] [--verbose]
            [--concise] [-f {json,json-pretty,xml,xml-pretty,plain}]
            [--connect-timeout CLUSTER_TIMEOUT] [--block] [--period PERIOD]

Ceph administration tool

optional arguments:
  -h, --help            request mon help
  ......
shell 复制代码
创建普通用户:
[cephadm@admin ceph-cluster]$ ceph auth add client.testuser mon 'allow r' osd 'allow rw pool=rdbpool'
added key for client.testuser
shell 复制代码
获取创建的用户信息:
[cephadm@admin ceph-cluster]$ ceph auth get client.testuser
[client.testuser]
        key = AQAjixxmUbdGEBAAZFm/b7rRXvK+kdvO1NEQCg==
        caps mon = "allow r"
        caps osd = "allow rw pool=rdbpool"
exported keyring for client.testuser
shell 复制代码
列出用户的秘钥信息:
[cephadm@admin ceph-cluster]$ ceph auth print-key client.testuser
AQAjixxmUbdGEBAAZFm/b7rRXvK+kdvO1NEQCg==

用户授权

shell 复制代码
修改用户的授权:
[cephadm@admin ceph-cluster]$ ceph auth caps client.testuser mon 'allow rw' osd 'allow rw pool=rdbpool1'
updated caps for client.testuser
shell 复制代码
查看修改后的授权信息:
[cephadm@admin ceph-cluster]$ ceph auth get client.testuser
[client.testuser]
        key = AQAjixxmUbdGEBAAZFm/b7rRXvK+kdvO1NEQCg==
        caps mon = "allow rw"
        caps osd = "allow rw pool=rdbpool1"
exported keyring for client.testuser

导出用户

shell 复制代码
查看导出信息:
[cephadm@admin ceph-cluster]$ ceph auth export client.testuser
[client.testuser]
        key = AQAjixxmUbdGEBAAZFm/b7rRXvK+kdvO1NEQCg==
        caps mon = "allow rw"
        caps osd = "allow rw pool=rdbpool1"
export auth(key=AQAjixxmUbdGEBAAZFm/b7rRXvK+kdvO1NEQCg==)
shell 复制代码
导出信息到一个备份文件:
[cephadm@admin ceph-cluster]$ ceph auth export client.testuser > testuser.file
export auth(key=AQAjixxmUbdGEBAAZFm/b7rRXvK+kdvO1NEQCg==)

[cephadm@admin ceph-cluster]$ cat testuser.file
[client.testuser]
        key = AQAjixxmUbdGEBAAZFm/b7rRXvK+kdvO1NEQCg==
        caps mon = "allow rw"
        caps osd = "allow rw pool=rdbpool1"

删除用户

shell 复制代码
删除用户信息:
[cephadm@admin ceph-cluster]$ ceph auth del client.testuser
updated
shell 复制代码
查看效果:
[cephadm@admin ceph-cluster]$ ceph auth get client.testuser
Error ENOENT: failed to find client.testuser in keyring

导入用户

shell 复制代码
导入用户文件:
[cephadm@admin ceph-cluster]$ ceph auth import -i testuser.file
imported keyring
shell 复制代码
查看文件效果:
[cephadm@admin ceph-cluster]$ ceph auth get client.testuser
[client.testuser]
        key = AQAjixxmUbdGEBAAZFm/b7rRXvK+kdvO1NEQCg==
        caps mon = "allow rw"
        caps osd = "allow rw pool=rdbpool1"
exported keyring for client.testuser

尝试创建一个未知的用户

shell 复制代码
创建一个已知的用户:
[cephadm@admin ceph-cluster]$ ceph auth get-or-create client.testuser
[client.testuser]
        key = AQAjixxmUbdGEBAAZFm/b7rRXvK+kdvO1NEQCg==
结果显示:
	如果是一个已存在的用户名,则会返回具体的信息,而且不会覆盖现有的用户信息
shell 复制代码
[cephadm@admin ceph-cluster]$ ceph auth get client.testuser
[client.testuser]
        key = AQAjixxmUbdGEBAAZFm/b7rRXvK+kdvO1NEQCg==
        caps mon = "allow rw"
        caps osd = "allow rw pool=rdbpool1"
exported keyring for client.testuser
shell 复制代码
创建一个未知的用户:
[cephadm@admin ceph-cluster]$ ceph auth get-or-create client.testuser2 mon 'allow r' osd 'allow rw pool=rdbpool'
[client.testuser2]
        key = AQD7jBxm6E7mLBAASfvt0HFO0TCDQckbKGsORQ==
shell 复制代码
如果从未出现过的用户,则直接创建新的用户:
[cephadm@admin ceph-cluster]$ ceph auth get client.testuser2
[client.testuser2]
        key = AQD7jBxm6E7mLBAASfvt0HFO0TCDQckbKGsORQ==
        caps mon = "allow r"
        caps osd = "allow rw pool=rdbpool"
exported keyring for client.testuser2

1.3 小结

复制代码
相关推荐
mixboot12 小时前
ceph 14.2.22 nautilus Balancer 数据平衡
ceph·balancer·数据平衡
斯普信专业组4 天前
k8s云原生rook-ceph pvc快照与恢复(下)
ceph·云原生·kubernetes
斯普信专业组4 天前
k8s云原生rook-ceph pvc快照与恢复(上)
ceph·云原生·kubernetes
斯普信专业组4 天前
Ceph、K8s、CSI、PVC、PV 深入详解
ceph·容器·kubernetes
mixboot17 天前
Ceph OSD.419 故障分析
ceph·osd
赵成ccc17 天前
离线部署三节点 Ceph 分布式存储
分布式·ceph
赵成ccc17 天前
三节点Ceph分布式存储搭建指南
分布式·ceph
免檒17 天前
windows11下基于docker单机部署ceph集群
ceph·后端·docker·容器
mixboot17 天前
Ceph集群OSD崩溃恢复
ceph·osd
羌俊恩21 天前
分布式存储之Ceph使用指南--部署篇(未完待续)
分布式·ceph·pg·osd·rados