连接 meta server 报错,Connection refused

  • nebula 2.0.0-rc1
  • 部署方式: Docker
  • 硬件信息
    • SSD
    • MacOS core-i5,8G内存
  • 问题的具体描述
  • 执行 nebula-python 项目下 example/ScanVertexEdgeExample.py 报错
    报错信息如下:
Traceback (most recent call last):
  File "../nebula2/fbthrift/transport/TSocket.py", line 279, in open
    handle.connect(address)
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "ScanVertexEdgeExample.py", line 129, in <module>
    meta_cache = MetaCache([('127.0.0.1', 9559)], 50000)
  File "../nebula2/mclient/__init__.py", line 177, in __init__
    self._meta_client.open()
  File "../nebula2/mclient/__init__.py", line 65, in open
    transport.open()
  File "../nebula2/fbthrift/transport/TTransport.py", line 176, in open
    return self.__trans.open()
  File "../nebula2/fbthrift/transport/TSocket.py", line 294, in open
    raise TTransportException(TTransportException.NOT_OPEN, msg)
nebula2.fbthrift.transport.TTransport.TTransportException: socket error connecting to host 127.0.0.1, port 9559 (('127.0.0.1', 9559)): ConnectionRefusedError(61, 'Connection refused')

python 相关代码如下

    meta_cache = None
    graph_storage_client = None
    try:
        # the metad servers's address
        meta_cache = MetaCache([('127.0.0.1', 9559)], 50000)
        graph_storage_client = GraphStorageClient(meta_cache)
        prepare_data()
        scan_person_vertex(graph_storage_client)
        scan_person_edge(graph_storage_client)

    except Exception as x:
        import traceback
        print(traceback.format_exc())
        if graph_storage_client is not None:
            graph_storage_client.close()
        exit(1)
    finally:
        if graph_storage_client is not None:
            graph_storage_client.close()
        if meta_cache is not None:
            meta_cache.close()

example目录下的 GraphClientMultiThreadExample.pyGraphClientSimpleExample.py 没有出错。

你连错端口了,9559 是docker内部的端口,你要用映射出来的端口。

还有,你在macos下面docker的这种网络方式也是不能用scan的,因为从meta拿到的storage信息是docker内部的ip和端口,从外部也是访问不了,你换成host模式再使,具体看这个链接里面的讨论

1 个赞

我的nebula不是用docker启动的,也是出现nebula2.Exception.SpaceNotFoundException: ScanSpace这个错误,代码如下:
meta_cache = MetaCache([(‘192.168.0.172’, 9779)], 50000)
里面space是存在的,不知道如何解决,望指教!

metacache用的是metad的端口,9779应该是storage的端口,你换成9559

换成9559后报下面的错误:
[2021-04-15 16:03:17,842]:Create storage connection failed: socket error connecting to host 127.0.0.1, port 9779 ((‘127.0.0.1’, 9779)): ConnectionRefusedError(10061, ‘由于目标计算机积极拒绝,无法连接。’, None, 10061, None)
是我电脑的问题吗,我用的是win10系统

你的服务假如不是docker部署,是不可以通过安装包安装到windows的,你的服务安装在其他机器,你就需要用那个机器的ip,还有你还要确认那机器是否有开防火墙

就是用服务器的ip+port访问的,是可以通过pycharm访问nebulagraph图数据库并添加数据的;
查看了一下防火墙:
FirewallD is not running

你先说你的nebulagraph是怎么部署的吧,你上面已经说不是用docker启动,那就是用安装包安装,安装包没有支持windows的,你安装到哪里。

直接安装linux服务器上了,只是没有搭建集群,只是在那台linux服务器上通过nebula.service start all启动的服务

你在你的电脑上面允许的java 程序,服务端在linux机器上面,你怎么可以用127.0.0.1呢,你要用linux那机子自己的IP呀


代码里面有的是服务器的ip,并不是“127.0.0.1”

scan_person_vertex 是你自己写的函数吧,先用文档上试一下。

    resp = graph_storage_client.scan_vertex(
        space_name='space1',
        tag_name='Person')
    print(resp)

防火墙关了吗?

这就是文档上的函数

关了

感觉就是网不通,本地访问不到,也不知道为什么之前运行一直出错,就在刚才运行了一下,突然就可以了,我啥也没改,不知道这是为什么呢?


还是同样的配方,还是同样的味道,给了我异样的惊喜!!!


你这里的 (127.0.0.1,9779) 是storage的ip和端口。
你之前的storaged配置的local_ip是127.0.0.1,所以你在其他机器连接metad去拿到的storage的ip还是127.0.0.1,所以你在windows上面的java程序连不上storage。
现在ok了是不是你改了storage的配置,将local_ip修改为本机ip,所以在你电脑的python程序可以连上storage。

1 个赞