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 小结

复制代码
相关推荐
行走的山峰17 小时前
ceph之osd扩容和缩容
ceph
hejingdong12317 小时前
ceph iscsi网关配置过程遇到的问题和解决办法
ceph·ceph iscsi·iscsi 网关
行走的山峰17 小时前
ceph简介
ceph
奋斗的松鼠2 天前
numa分布奇葩引发的性能问题
ceph
奋斗的松鼠9 天前
2.1ceph集群部署准备-硬件及拓扑
linux·服务器·ceph
hejingdong12313 天前
ceph-iscsi 手动安装过程中的一些问题记录以及解决办法
ceph
奋斗的松鼠13 天前
2.2ceph集群部署准备-软件准备上
分布式·ceph
henan程序媛14 天前
云原生存储Rook部署Ceph
ceph·云原生·rook
不爱代码的小杜14 天前
Ceph集群维护相关操作
linux·服务器·ceph
PolarisHuster14 天前
ceph中pg与pool关系
ceph