ceph-rest-api的IPv6环境配置

引言

ceph-rest-api 是一个 WSGI (网页服务器网关接口)应用程序,可作为网页服务独立运行,也可在支持 WSGI 的网页服务器下运行。它通过 HTTP 访问接口提供了 ceph 命令行工具的大多数功能,官网详细介绍。本篇将介绍如何配置IPv6环境的ceph-rest-api。

配置

IPv4环境

ceph-rest-api默认已经安装在ceph集群中,使用如下命令即可启功:


1
2

[[email protected] ~]# ceph-rest-api -n client.admin
* Running on http://0.0.0.0:5000/

如果要更改IP或者端口号,只需在ceph.conf配置文件[global]下添加public_addr字段,如下:


1
2

[global]
public_addr = 49.123.93.84:5001

启动ceph-rest-api


1
2

[[email protected] cluster]# ceph-rest-api -n client.admin
* Running on http://49.123.93.84:5001/

访问 http://49.123.93.84:5001/ 即可查看对应的原生API
ceph-rest-api的IPv6环境配置

IPv6环境

之前尝试直接在ceph.conf配置文件中配置对应的IPv6地址与端口号,但是在启动时报错


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

[[email protected] cluster]# ceph-rest-api -n client.admin
* Running on http://[[2001:250:4402:2001:20c:29ff:fe25:8888]]:5001/
Traceback (most recent call last):
File "/usr/bin/ceph-rest-api", line 72, in <module>
app.run(host=app.ceph_addr, port=app.ceph_port)
File "/usr/lib/python2.7/site-packages/flask/app.py", line 772, in run
run_simple(host, port, self, **options)
File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 710, in run_simple
inner()
File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 692, in inner
passthrough_errors, ssl_context).serve_forever()
File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 486, in make_server
passthrough_errors, ssl_context)
File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 410, in __init__
HTTPServer.__init__(self, (host, int(port)), handler)
File "/usr/lib64/python2.7/SocketServer.py", line 419, in __init__
self.server_bind()
File "/usr/lib64/python2.7/BaseHTTPServer.py", line 108, in server_bind
SocketServer.TCPServer.server_bind(self)
File "/usr/lib64/python2.7/SocketServer.py", line 430, in server_bind
self.socket.bind(self.server_address)
File "/usr/lib64/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.gaierror: [Errno -2] Name or service not known

从报错信息可知IPv6地址不合法http://[[2001:250:4402:2001:20c:29ff:fe25:8888]]:5001/ ,正确地址应该是http://[2001:250:4402:2001:20c:29ff:fe25:8888]:5001/ ,找到对应的/usr/bin/ceph-rest-api文件,打印对应的host为[2001:250:4402:2001:20c:29ff:fe25:8888],目前找到的解决办法是直接将IPv6地址与端口号写入此文件


1
2
3
4
5
6
7
8

...
if 'pdb.py' in files:
app.run(host=app.ceph_addr, port=app.ceph_port,
debug=True, use_reloader=False, use_debugger=False)
else:
app.ceph_addr='2001:250:4402:2001:20c:29ff:fe25:8888';
app.ceph_port=5001;
app.run(host=app.ceph_addr, port=app.ceph_port)

并运行ceph-rest-api


1
2

[[email protected] cluster]# ceph-rest-api -n client.admin
* Running on http://[2001:250:4402:2001:20c:29ff:fe25:8888]:5001/

访问地址 http://[2001:250:4402:2001:20c:29ff:fe25:8888]:5001/ 即可。

后续

本篇中提到的配置IPv6的方法仅仅是权宜之计,按理来说不应该修改ceph-rest-api文件,而是去查看对应的url地址如何拼接,哪位大神如果知道在哪修改欢迎留言。

坚持原创技术分享,您的支持将鼓励我继续创作!