ceph-rest-api的使用

来源:互联网 发布:汕头 钦差 知乎 编辑:程序博客网 时间:2024/05/16 09:16

最近在想怎么去更有效的监控和管理ceph集群的问题,之前主要就是脚本调用ceph的命令,有没有更方便和有效的方式呢?之前部署过calamari,不过这个calamari比较庞大,所以看看ceph原生的rest api.


ceph rest api是一个wsgi(Web Service Gateway Interface)应用,默认监听5000端口

ceph-rest-api本身包含在ceph-common这个包里面,因此默认已经安装在集群的节点上,如果我们要在其他非集群节点上执行api,安装ceph-common包就可以了。

启动ceph-rest-api:
[root@CHN-ID-3-3W7 ~]# ceph-rest-api -n client.admin
* Running on http://0.0.0.0:5000/

如果提示找不到jinja,则需执行:
easy_install Jinja2或者pip install Jinja2

如何使用:
[root@CHN-ID-3-3W7 ~]# curl 127.0.0.1:5000               
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to target URL: <a href="/api/v0.1">/api/v0.1</a>.  If not click the link.[root@CHN-ID-3-3W7 ~]#


[root@CHN-ID-3-3W7 ~]# curl 127.0.0.1:5000/api/v0.1/status
    cluster 05fb7439-f063-45b7-aa58-3977c630db3f
     health HEALTH_OK
     monmap e1: 3 mons at {a=10.20.42.177:6789/0,b=10.20.42.187:6789/0,c=10.20.42.166:6789/0}, election epoch 674, quorum 0,1,2 c,a,b
     osdmap e1157: 188 osds: 188 up, 188 in
      pgmap v2394280: 84928 pgs, 9 pools, 426 GB data, 1094 kobjects
            2742 GB used, 681 TB / 683 TB avail
               84928 active+clean
  client io 144 kB/s rd, 438 B/s wr, 109 op/s



[root@CHN-ID-3-3W7 ~]# curl 127.0.0.1:5000/api/v0.1/osd/pool/get?pool=.rgw.buckets\&var=min_size
min_size: 1 

相应的可以在启动ceph-rest-api的终端看到请求的url和对应的响应码:
[root@CHN-ID-3-3W7 ~]# ceph-rest-api -n client.admin
* Running on http://0.0.0.0:5000/
127.0.0.1 - - [18/Jun/2015 19:34:28] "GET /api/v0.1/status HTTP/1.1" 200 -
127.0.0.1 - - [18/Jun/2015 19:34:42] "GET / HTTP/1.1" 302 -
127.0.0.1 - - [18/Jun/2015 19:35:09] "GET /api/v0.1/status HTTP/1.1" 200 -
127.0.0.1 - - [18/Jun/2015 19:35:53] "GET /api/v0.1/osd/pool/get?pool=.rgw.buckets&var=min_size HTTP/1.1" 200 -

从这里看其功能和我们直接在节点上执行cli的命令的作用相同,但是其提供这种http请求方式的接口去管理和监控集群,能够很方便的集成到监控平台中。

参考:
https://dmsimard.com/2013/12/21/experimenting-with-the-ceph-rest-api/
https://ceph.com/category/ceph-rest-api/                             -------------这个包含了所有的api对应的url

0 0
原创粉丝点击