测试服务器上的Ceph-rest-api



当试图在一个名为"ceph"的通用ceph集群上运行ceph-rest-api时,它可以从cli:

/bin/ceph-rest-api --cluster ceph --id admin
  * Running on http://0.0.0.0:5000/

但是,当我尝试在一个名为"test"的测试集群上运行它时,它出错了:

/bin/ceph-rest-api --cluster test --id test
Traceback (most recent call last):
  File "/bin/ceph-rest-api", line 59, in <module>
    rest,
  File "/usr/lib/python2.7/site-packages/ceph_rest_api.py", line 495, in generate_app
    addr, port = api_setup(app, conf, cluster, clientname, clientid, args)
  File "/usr/lib/python2.7/site-packages/ceph_rest_api.py", line 106, in api_setup
    app.ceph_cluster.connect()
  File "rados.pyx", line 785, in rados.Rados.connect (rados.c:8969)
rados.ObjectNotFound: error connecting to the cluster

我也试过使用一个变化,得到一个不同的错误:

/bin/ceph-rest-api --cluster test --name test
Traceback (most recent call last):
  File "/bin/ceph-rest-api", line 59, in <module>
    rest,
  File "/usr/lib/python2.7/site-packages/ceph_rest_api.py", line 495, in generate_app
    addr, port = api_setup(app, conf, cluster, clientname, clientid, args)
  File "/usr/lib/python2.7/site-packages/ceph_rest_api.py", line 104, in api_setup
    app.ceph_cluster = rados.Rados(name=clientname, conffile=conf)
  File "rados.pyx", line 525, in rados.Rados.__init__ (rados.c:5719)
  File "rados.pyx", line 425, in rados.requires.wrapper.validate_func (rados.c:4106)
  File "rados.pyx", line 557, in rados.Rados.__setup (rados.c:6237)
rados.Error: rados_initialize failed with error code: -22

如果你能告诉我我做错了什么,我将不胜感激。

rados.ObjectNotFound: error connecting to the cluster for /bin/ceph-rest-api --cluster test --id test表示测试用户不存在。此外,根据ceph-rest-api手册页,——name以client开头,——id不以client开头。即:ceph-rest-api --cluster test --name client.adminceph-rest-api --cluster test --id admin

您需要在应该启动ceph-rest-api的机器上放置一个密匙环文件。

  1. 创建restapi用户
    ceph auth get-or-create client.rest-test mds 'allow' osd 'allow *' mon 'allow *

    输出应该像这样
    [client.rest-test] key = AQDPVTFZsiZjIRAAtLXWWlr8Q8t1PjhFKnOCyw==

  2. 创建其他用户密匙环文件/etc/ceph/ceph-client.<username>.keyring
    并将ceph auth get-or-create的输出粘贴到该文件中,或者在执行命令时重定向输出。
    您总是可以重复命令ceph auth get-or-create,当用户已经创建时,ceph auth将以相同的方式获取用户密钥和名称


  3. 启动ceph-rest-apiceph-rest-api --name client.rest-test

    ceph-rest-api --id rest-test

<标题> 研究

我用strace做了一些测试,以找出ceph-rest-api在开始之前打开和读取的文件。
strace -e open ceph-rest-api -i rest-test 2>&1 | grep key

...
open("/etc/ceph/ceph.client.rest-test.keyring", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/ceph/ceph.keyring", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/ceph/keyring", O_RDONLY)     = -1 ENOENT (No such file or directory)
open("/etc/ceph/keyring.bin", O_RDONLY) = -1 ENOENT (No such file or directory)

可以看到,ceph-rest-api尝试打开一些不同的密钥文件,在这种情况下没有密钥文件存在,启动ceph-rest-api失败。如果您在/etc/ceph中放置了代表rest-user的正确密钥文件,则将读取该文件并启动rest-api。

strace -e open,connect ceph-rest-api  -i rest-test 2>&1  | grep -i 'key|running'
open("/etc/ceph/ceph.client.rest-test.keyring", O_RDONLY) = 3
open("/etc/ceph/ceph.client.rest-test.keyring", O_RDONLY) = 3
* Running on http://0.0.0.0:5000/

相关内容

  • 没有找到相关文章

最新更新