管理 API 指南
参考和集成指南
摘要
第 1 章 RESTful 插件
第 2 章 问题和答案
2.1. 获取信息
本节介绍如何使用 RESTful 插件查看有关集群、监控器、OSD、池、主机和请求的信息:
- 第 2.1.1 节 “如何查看所有群集配置选项?”
- 第 2.1.2 节 “如何查看部分群集配置选项?”
- 第 2.1.3 节 “如何查看 OSD 的所有配置选项?”
- 第 2.1.4 节 “如何查看 CRUSH 规则?”
- 第 2.1.5 节 “如何查看有关 monitor 的信息?”
- 第 2.1.6 节 “我如何查看有关部分 monitor 的信息?”
- 第 2.1.7 节 “如何查看有关 OSD 的信息?”
- 第 2.1.8 节 “如何查看有关部分 OSD 的信息?”
- 第 2.1.9 节 “如何确定哪些进程可以在 OSD 上调度?”
- 第 2.1.10 节 “如何查看关于池的信息?”
- 第 2.1.11 节 “我如何查看关于组件池的信息?”
- 第 2.1.12 节 “如何查看关于请求的信息?”
- 第 2.1.13 节 “我如何查看关于部分请求的信息?”
- 第 2.1.14 节 “如何查看关于主机的信息?”
- 第 2.1.15 节 “我如何查看关于部分主机的信息?”
2.1.1. 如何查看所有群集配置选项?
本节论述了如何使用 RESTful 插件查看集群配置选项及其值。
curl 命令
在命令行中使用:
curl --silent --user <user> 'https://<ceph-mgr>:8003/config/cluster'
替换:
-
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
curl --silent --insecure --user <user> 'https://<ceph-mgr>:8003/config/cluster'
Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/config/cluster', auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/config/cluster', auth=("<user>", "<password>"), verify=False)
>> print result.json()Web 浏览器
在 Web 浏览器中输入:
https://<ceph-mgr>:8003/config/cluster
替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名
出现提示时,输入用户名和密码。
其它资源
- Red Hat Ceph Storage 4 配置指南
2.1.2. 如何查看部分群集配置选项?
本节论述了如何查看特定集群选项及其值。
curl 命令
在命令行中使用:
curl --silent --user <user> 'https://<ceph-mgr>:8003/config/cluster/<argument>'
替换:
-
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<argument>带有您要查看的配置选项
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
curl --silent --insecure --user <user> 'https://<ceph-mgr>:8003/config/cluster/<argument>'
Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/config/cluster/<argument>', auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<argument>带有您要查看的配置选项 -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/config/cluster/<argument>', auth=("<user>", "<password>"), verify=False)
>> print result.json()Web 浏览器
在 Web 浏览器中输入:
https://<ceph-mgr>:8003/config/cluster/<argument>
替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<argument>带有您要查看的配置选项
出现提示时,输入用户名和密码。
其它资源
- Red Hat Ceph Storage 4 配置指南
2.1.3. 如何查看 OSD 的所有配置选项?
本节介绍如何查看 OSD 的所有配置选项及其值。
curl 命令
在命令行中使用:
curl --silent --user <user> 'https://<ceph-mgr>:8003/config/osd'
替换:
-
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
curl --silent --insecure --user <user> 'https://<ceph-mgr>:8003/config/osd'
Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/config/osd', auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/config/osd', auth=("<user>", "<password>"), verify=False)
>> print result.json()Web 浏览器
在 Web 浏览器中输入:
https://<ceph-mgr>:8003/config/osd
替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名
出现提示时,输入用户名和密码。
其它资源
- Red Hat Ceph Storage 4 配置指南
2.1.4. 如何查看 CRUSH 规则?
本节介绍如何查看 CRUSH 规则。
curl 命令
在命令行中使用:
curl --silent --user <user> 'https://<ceph-mgr>:8003/crush/rule'
替换:
-
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
curl --silent --insecure --user <user> 'https://<ceph-mgr>:8003/crush/rule'
Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/crush/rule', auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/crush/rule', auth=("<user>", "<password>"), verify=False)
>> print result.json()Web 浏览器
在 Web 浏览器中输入:
https://<ceph-mgr>:8003/crush/rule
替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名
出现提示时,输入用户名和密码。
其它资源
- 红帽 Ceph 存储 4 管理指南 中的 CRUSH 规则 部分
2.1.5. 如何查看有关 monitor 的信息?
本节论述了如何查看特定 monitor 的信息,例如:
- IP 地址
- 名称
- 仲裁状态
curl 命令
在命令行中使用:
curl --silent --user <user> 'https://<ceph-mgr>:8003/mon'
替换:
-
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
curl --silent --insecure --user <user> 'https://<ceph-mgr>:8003/mon'
Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/mon', auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/mon', auth=("<user>", "<password>"), verify=False)
>> print result.json()Web 浏览器
在 Web 浏览器中输入:
https://<ceph-mgr>:8003/mon
替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名
出现提示时,输入用户名和密码。
2.1.6. 我如何查看有关部分 monitor 的信息?
本节论述了如何查看特定 monitor 的信息,例如:
- IP 地址
- 名称
- 仲裁状态
curl 命令
在命令行中使用:
curl --silent --user <user> 'https://<ceph-mgr>:8003/mon/<name>'
替换:
-
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<name>,带有 monitor 的短主机名
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
curl --silent --insecure --user <user> 'https://<ceph-mgr>:8003/mon/<name>'
Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/mon/<name>', auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<name>,带有 monitor 的短主机名 -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/mon/<name>', auth=("<user>", "<password>"), verify=False)
>> print result.json()Web 浏览器
在 Web 浏览器中输入:
https://<ceph-mgr>:8003/mon/<name>
替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<name>,带有 monitor 的短主机名
出现提示时,输入用户名和密码。
2.1.7. 如何查看有关 OSD 的信息?
本节介绍如何查看 OSD 的信息,例如:
- IP 地址
- 其池
- 关联性
- weight
curl 命令
在命令行中使用:
curl --silent --user <user> 'https://<ceph-mgr>:8003/osd'
替换:
-
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
curl --silent --insecure --user <user> 'https://<ceph-mgr>:8003/osd'
Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/osd/', auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/osd/', auth=("<user>", "<password>"), verify=False)
>> print result.json()Web 浏览器
在 Web 浏览器中输入:
https://<ceph-mgr>:8003/osd
替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名
出现提示时,输入用户名和密码。
2.1.8. 如何查看有关部分 OSD 的信息?
本节论述了如何查看特定 OSD 的信息,例如:
- IP 地址
- 其池
- 关联性
- weight
curl 命令
在命令行中使用:
curl --silent --user <user> 'https://<ceph-mgr>:8003/osd/<id>'
替换:
-
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有osd字段中列出的 OSD 的 ID
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
curl --silent --insecure --user <user> 'https://<ceph-mgr>:8003/osd/<id>'
Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/osd/<id>', auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有osd字段中列出的 OSD 的 ID -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/osd/<id>', auth=("<user>", "<password>"), verify=False)
>> print result.json()Web 浏览器
在 Web 浏览器中输入:
https://<ceph-mgr>:8003/osd/<id>
替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有osd字段中列出的 OSD 的 ID
出现提示时,输入用户名和密码。
2.1.9. 如何确定哪些进程可以在 OSD 上调度?
本节介绍如何使用 RESTful 插件查看哪些进程(如清理或深度清理)可以调度到 OSD 上。
curl 命令
在命令行中使用:
curl --silent --user <user> 'https://<ceph-mgr>:8003/osd/<id>/command'
替换:
-
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有osd字段中列出的 OSD 的 ID
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
curl --silent --insecure --user <user> 'https://<ceph-mgr>:8003/osd/<id>/command'
Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/osd/<id>/command', auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有osd字段中列出的 OSD 的 ID -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/osd/<id>/command', auth=("<user>", "<password>"), verify=False)
>> print result.json()Web 浏览器
在 Web 浏览器中输入:
https://<ceph-mgr>:8003/osd/<id>/command
替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有osd字段中列出的 OSD 的 ID
出现提示时,输入用户名和密码。
2.1.10. 如何查看关于池的信息?
本节论述了如何查看池的信息,例如:
- 标记
- Size
- 放置组数量
curl 命令
在命令行中使用:
curl --silent --user <user> 'https://<ceph-mgr>:8003/pool'
替换:
-
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
curl --silent --insecure --user <user> 'https://<ceph-mgr>:8003/pool'
Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/pool', auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/pool', auth=("<user>", "<password>"), verify=False)
>> print result.json()Web 浏览器
在 Web 浏览器中输入:
https://<ceph-mgr>:8003/pool
替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名
出现提示时,输入用户名和密码。
2.1.11. 我如何查看关于组件池的信息?
本节论述了如何查看特定池的信息,例如:
- 标记
- Size
- 放置组数量
curl 命令
在命令行中使用:
curl --silent --user <user> 'https://<ceph-mgr>:8003/pool/<id>'
替换:
-
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有在pool字段中列出的池的 ID
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
curl --silent --insecure --user <user> 'https://<ceph-mgr>:8003/config/cluster'
Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/pool/<id>', auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有在pool字段中列出的池的 ID -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/pool/<id>', auth=("<user>", "<password>"), verify=False)
>> print result.json()Web 浏览器
在 Web 浏览器中输入:
https://<ceph-mgr>:8003/pool/<id>
替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有在pool字段中列出的池的 ID
出现提示时,输入用户名和密码。
2.1.12. 如何查看关于请求的信息?
本节论述了如何查看请求的信息。
curl 命令
在命令行中使用:
curl --silent --user <user> 'https://<ceph-mgr>:8003/request'
替换:
-
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
curl --silent --insecure --user <user> 'https://<ceph-mgr>:8003/request'
Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/request', auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/request', auth=("<user>", "<password>"), verify=False)
>> print result.json()Web 浏览器
在 Web 浏览器中输入:
https://<ceph-mgr>:8003/request
替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名
出现提示时,输入用户名和密码。
2.1.13. 我如何查看关于部分请求的信息?
本节论述了如何查看特定请求的信息。
curl 命令
在命令行中使用:
curl --silent --user <user> 'https://<ceph-mgr>:8003/request/<id>'
替换:
-
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有id字段中列出的请求的 ID
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
curl --silent --insecure --user <user> 'https://<ceph-mgr>:8003/request/<id>'
Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/request/<id>', auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有id字段中列出的请求的 ID -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/request/<id>', auth=("<user>", "<password>"), verify=False)
>> print result.json()Web 浏览器
在 Web 浏览器中输入:
https://<ceph-mgr>:8003/request/<id>
替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有id字段中列出的请求的 ID
出现提示时,输入用户名和密码。
2.1.14. 如何查看关于主机的信息?
本节论述了如何查看主机的信息,例如:
- 主机名
- Ceph 守护进程及其 ID
- Ceph 版本
curl 命令
在命令行中使用:
curl --silent --user <user> 'https://<ceph-mgr>:8003/server'
替换:
-
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
curl --silent --insecure --user <user> 'https://<ceph-mgr>:8003/server'
Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/server', auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/server', auth=("<user>", "<password>"), verify=False)
>> print result.json()Web 浏览器
在 Web 浏览器中输入:
https://<ceph-mgr>:8003/server
替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名
出现提示时,输入用户名和密码。
2.1.15. 我如何查看关于部分主机的信息?
本节论述了如何查看特定主机的信息,例如:
- 主机名
- Ceph 守护进程及其 ID
- Ceph 版本
curl 命令
在命令行中使用:
curl --silent --user <user> 'https://<ceph-mgr>:8003/server/<hostname>'
替换:
-
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<hostname>以及hostname字段中列出的主机主机名
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
curl --silent --insecure --user <user> 'https://<ceph-mgr>:8003/server/<hostname>'
Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/server/<hostname>', auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<hostname>以及hostname字段中列出的主机主机名 -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.get('https://<ceph-mgr>:8003/server/<hostname>', auth=("<user>", "<password>"), verify=False)
>> print result.json()Web 浏览器
在 Web 浏览器中输入:
https://<ceph-mgr>:8003/server/<hostname>
替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<hostname>以及hostname字段中列出的主机主机名
出现提示时,输入用户名和密码。
2.2. 更改配置
本节介绍如何使用 RESTful 插件更改 OSD 配置选项、OSD 状态和池的相关信息:
2.2.1. 如何更改 OSD 配置选项?
本节介绍如何使用 RESTful 插件更改 OSD 配置选项。
curl 命令
在命令行中使用:
echo -En '{"<option>": <value>}' | curl --request PATCH --data @- --silent --user <user> 'https://<ceph-mgr>:8003/config/osd'替换:
-
<option> 带有修改的选项;pause、noup、nodown、noout、noin、nobackfill、norecover、noscrub、nodeep-scrub -
带有
true或false的<value> -
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
echo -En '{'<option>': <value>}' | curl --request PATCH --data @- --silent --insecure --user <user> 'https://<ceph-mgr>:8003/config/osd'Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.patch('https://<ceph-mgr>:8003/config/osd', json={"<option>": <value>}, auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<option> 带有修改的选项;pause、noup、nodown、noout、noin、nobackfill、norecover、noscrub、nodeep-scrub -
<value>withTrue或False -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.patch('https://<ceph-mgr>:8003/config/osd', json={"<option>": <value>}, auth=("<user>", "<password>"), verify=False)
>> print result.json()2.2.2. 如何更改 OSD 状态?
本节介绍如何使用 RESTful 插件更改 OSD 的状态。
curl 命令
在命令行中使用:
echo -En '{"<state>": <value>}' | curl --request PATCH --data @- --silent --user <user> 'https://<ceph-mgr>:8003/osd/<id>'替换:
-
<state>带有要更改的状态(in或up) -
带有
true或false的<value> -
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有osd字段中列出的 OSD 的 ID
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
echo -En '{"<state>": <value>}' | curl --request PATCH --data @- --silent --insecure --user <user> 'https://<ceph-mgr>:8003/osd/<id>'Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.patch('https://<ceph-mgr>:8003/osd/<id>', json={"<state>": <value>}, auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<state>带有要更改的状态(in或up) -
<value>withTrue或False -
<id>带有osd字段中列出的 OSD 的 ID -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.patch('https://<ceph-mgr>:8003/osd/<id>', json={"<state>": <value>}, auth=("<user>", "<password>"), verify=False)
>> print result.json()2.2.3. 如何重新加权 OSD?
本节介绍如何更改 OSD 的权重。
curl 命令
在命令行中使用:
echo -En '{"reweight": <value>}' | curl --request PATCH --data @- --silent --user <user> 'https://<ceph-mgr>:8003/osd/<id>'替换:
-
带有新权重的
<value> -
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有osd字段中列出的 OSD 的 ID
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
echo -En '{"reweight": <value>}' | curl --request PATCH --data @- --silent --insecure --user <user> 'https://<ceph-mgr>:8003/osd/<id>'Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.patch('https://<ceph-mgr>:8003/osd/<id>', json={"reweight": <value>}, auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
带有新权重的
<value> -
<id>带有osd字段中列出的 OSD 的 ID -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.patch('https://<ceph-mgr>:8003/osd/<id>', json={"reweight": <value>}, auth=("<user>", "<password>"), verify=False)
>> print result.json()2.2.4. 如何更改池的信息?
本节介绍如何使用 RESTful 插件更改特定池的信息。
curl 命令
在命令行中使用:
echo -En '{"<option>": <value>}' | curl --request PATCH --data @- --silent --user <user> 'https://<ceph-mgr>:8003/pool/<id>'替换:
-
<option>和要修改的选项 -
使用选项的新值 <value> -
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有在pool字段中列出的池的 ID
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
echo -En '{"<option>": <value>}' | curl --request PATCH --data @- --silent --insecure --user <user> 'https://<ceph-mgr>:8003/pool/<id>'Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.patch('https://<ceph-mgr>:8003/pool/<id>', json={"<option>": <value>}, auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有在pool字段中列出的池的 ID -
<option>和要修改的选项 -
使用选项的新值 <value> -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.patch('https://<ceph-mgr>:8003/pool/<id>', json={"<option>": <value>}, auth=("<user>", "<password>"), verify=False)
>> print result.json()2.3. 管理集群
本节介绍如何使用 RESTful 插件对 OSD 初始化清理或深度清理、创建池或删除池中的数据、删除请求或创建请求:
2.3.1. 如何才能在 OSD 上运行调度的进程?
本节介绍如何使用 RESTful API 在 OSD 上运行调度的进程,如清理或深度清理。
curl 命令
在命令行中使用:
echo -En '{"command": "<command>"}' | curl --request POST --data @- --silent --user <user> 'https://<ceph-mgr>:8003/osd/<id>/command'替换:
-
命令包含您要启动的进程(清理、深度清理或修复)。验证 OSD 上支持该进程。详情请查看 第 2.1.9 节 “如何确定哪些进程可以在 OSD 上调度?”。 -
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有osd字段中列出的 OSD 的 ID
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
echo -En '{"command": "<command>"}' | curl --request POST --data @- --silent --insecure --user <user> 'https://<ceph-mgr>:8003/osd/<id>/command'Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.post('https://<ceph-mgr>:8003/osd/<id>/command', json={"command": "<command>"}, auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有osd字段中列出的 OSD 的 ID -
命令包含您要启动的进程(清理、深度清理或修复)。验证 OSD 上支持该进程。详情请查看 第 2.1.9 节 “如何确定哪些进程可以在 OSD 上调度?”。 -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.post('https://<ceph-mgr>:8003/osd/<id>/command', json={"command": "<command>"}, auth=("<user>", "<password>"), verify=False)
>> print result.json()2.3.2. 如何创建新池?
本节介绍如何使用 RESTful 插件创建新池。
curl 命令
在命令行中使用:
echo -En '{"name": "<name>", "pg_num": <number>}' | curl --request POST --data @- --silent --user <user> 'https://<ceph-mgr>:8003/pool'替换:
-
带有新池名称的 <name> -
<number> 带有放置组的数量 -
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
echo -En '{"name": "<name>", "pg_num": <number>}' | curl --request POST --data @- --silent --insecure --user <user> 'https://<ceph-mgr>:8003/pool'Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.post('https://<ceph-mgr>:8003/pool', json={"name": "<name>", "pg_num": <number>}, auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
带有新池名称的 <name> -
<number> 带有放置组的数量 -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.post('https://<ceph-mgr>:8003/pool', json={"name": "<name>", "pg_num": <number>}, auth=("<user>", "<password>"), verify=False)
>> print result.json()2.3.3. 如何删除池?
本节介绍如何使用 RESTful 插件删除池。
此请求默认为禁止。若要允许,可添加下列参数到 Ceph 配置指南中:
mon_allow_pool_delete = true
curl 命令
在命令行中使用:
curl --request DELETE --silent --user <user> 'https://<ceph-mgr>:8003/pool/<id>'
替换:
-
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有在pool字段中列出的池的 ID
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
curl --request DELETE --silent --insecure --user <user> 'https://<ceph-mgr>:8003/pool/<id>'
Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.delete('https://<ceph-mgr>:8003/pool/<id>', auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有在pool字段中列出的池的 ID -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.delete('https://<ceph-mgr>:8003/pool/<id>', auth=("<user>", "<password>"), verify=False)
>> print result.json()2.3.4. 如何删除所有已完成的请求?
本节介绍如何使用 RESTful 插件删除所有已完成的请求。
curl 命令
在命令行中使用:
curl --request DELETE --silent --user <user> 'https://<ceph-mgr>:8003/request'
替换:
-
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
curl --request DELETE --silent --insecure --user <user> 'https://<ceph-mgr>:8003/request'
Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.delete('https://<ceph-mgr>:8003/request', auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.delete('https://<ceph-mgr>:8003/request', auth=("<user>", "<password>"), verify=False)
>> print result.json()2.3.5. 如何删除部分请求?
本节介绍如何使用 RESTful 插件从数据库中删除特定请求。
curl 命令
在命令行中使用:
curl --request DELETE --silent --user <user> 'https://<ceph-mgr>:8003/request/<id>'
替换:
-
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有id字段中列出的请求的 ID
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
curl --request DELETE --silent --insecure --user <user> 'https://<ceph-mgr>:8003/request/<id>'
Python
在 Python 解释器中输入:
$ python
>> import requests
>> result = requests.delete('https://<ceph-mgr>:8003/request/<id>', auth=("<user>", "<password>"))
>> print result.json()替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有id字段中列出的请求的 ID -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
$ python
>> import requests
>> result = requests.delete('https://<ceph-mgr>:8003/request/<id>', auth=("<user>", "<password>"), verify=False)
>> print result.json()2.3.6. 如何执行管理命令?
使用 /request 端点和 POST 方法执行管理命令。通过这种方法,您甚至可以使用不受 API 直接支持的命令,但在 Ceph 源代码中的 src/mon/MonCommands.h 文件中定义。例如,在构建使用 API 您自己的应用时,这非常有用。
Python
查看
src/mon/MonCommands.h,找到您要在 API 中执行的命令,例如:COMMAND("osd ls " \ "name=epoch,type=CephInt,range=0,req=false", \ "show all OSD ids", "osd", "r", "cli,rest")命令是
osd ls。name位指定命令具有的参数的名称,type指定参数采用的值类型,范围指定参数接受的值的范围,而req指定是否需要该参数。在本例中,参数是epoch,参数采用的值类型是整数,接受的值的范围是0,参数是可选的。在 Python 解释器中输入:
$ python >> import requests >> result = requests.post( 'https://<ceph-mgr>:8003/request', json={'prefix': '<command>', <argument>:<value>}, auth=("<user>", "<password>") ) >> print result.json()替换 :
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<command>,带有在src/mon/MonCommands.h文件中列出的命令 -
<argument>带有src/mon/MonCommands.h文件中列出的命令参数,如果参数是可选的,您可以省略它 -
<value>带有参数的值 -
<user>with user name -
<password>和用户的密码
例如,使用
osd ls epoch 0命令:将<command>替换为osd ls,<argument>替换为epoch,<value>替换为0:$ python >> import requests >> result = requests.post( 'https://ceph-node1:8003/request', json={'prefix': 'osd ls', 'epoch': 0}, auth=("ceph-user", "<password>") ) >> print result.json()如果您使用自签名证书,请使用
verify=False选项:$ python >> import requests >> result = requests.post( 'https://<ceph-mgr>:8003/request', json={'prefix': '<command>', <optional_argument>:<value>}, auth=("<user>", "<password>"), verify=False ) >> print result.json()-
其它资源
- GitHub 上的 src/mon/MonCommands.h 文件