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

复制代码
相关推荐
2301_767902643 小时前
ceph分布式存储(三)
分布式·ceph
2301_767902641 天前
ceph分布式存储(一)
分布式·ceph
2301_767902641 天前
ceph分布式存储(二)
分布式·ceph
FJW0208143 天前
cephadm部署ceph集群以及k8s对接
ceph·容器·kubernetes
韭菜张师傅4 天前
Ceph RBD 命令详解
ceph
韭菜张师傅5 天前
Ceph FS 命令详解
ceph
韭菜张师傅5 天前
Ceph MDS 命令详解
网络·ceph
lpruoyu5 天前
【云原生】Kubernetes平台存储系统搭建_CRI、CNI、CSI
ceph·云原生·容器·kubernetes
JNU freshman6 天前
Ceph 中与“重构/恢复/回填/重平衡”相关的参数表
java·ceph·重构
Insist7538 天前
基于 ceph-deploy 部署 Ceph 集群
运维·服务器·ceph