【问题标题】:ceph-rest-api on a test server测试服务器上的 ceph-rest-api
【发布时间】:2016-07-01 18:14:55
【问题描述】:

当尝试在名为“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

对我做错的任何帮助将不胜感激。

【问题讨论】:

    标签: linux rest ceph


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      您需要在应该启动 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.&lt;username&gt;.keyring
        并将ceph auth get-or-create 的输出粘贴到该文件中,或者在执行命令时重定向输出。
        您可以随时重复命令ceph auth get-or-create,当用户已经创建时,ceph auth 将以相同的方式获取用户密钥和名称

      3. 使用
        ceph-rest-api --name client.rest-test
        启动 ceph-rest-api 或
        ceph-rest-api --id rest-test

      研究

      我用 strace 做了一些测试,以确定 ceph-rest-api 在开始之前打开和读取了哪些文件。
      strace -e open ceph-rest-api -i rest-test 2&gt;&amp;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 失败。 如果您将代表您的 rest-user 的正确密钥文件放在 /etc/ceph 中,则该文件将被读取并且 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/
      

      【讨论】:

        猜你喜欢
        • 2021-05-14
        • 1970-01-01
        • 1970-01-01
        • 2019-11-15
        • 1970-01-01
        • 1970-01-01
        • 2019-12-08
        • 2023-04-02
        • 1970-01-01
        相关资源
        最近更新 更多