pyclient 连接 MetaCache 出错

  • nebula 版本:v2.0.0-rc1
  • 部署方式:Docker
  • 硬件信息
    • SSD
    • MacOS core-i5、8GB 内存
  • 在 MacOS 上通过 Docker 方式安装后(nebula-docker-compose 安装),
  • 报错信息
example git:(v2.0.0) ✗ python3 ScanVertexEdgeExample.py
[2021-03-26 16:01:28,976]:Update meta data failed: TSocket read 0 bytes
[2021-03-26 16:01:28,993]:Traceback (most recent call last):
  File "../nebula2/mclient/__init__.py", line 198, in _load_all
    spaces = self._meta_client.list_spaces()
  File "../nebula2/mclient/__init__.py", line 101, in list_spaces
    resp = self._connection.listSpaces(req)
  File "../nebula2/meta/MetaService.py", line 18113, in listSpaces
    return self.recv_listSpaces()
  File "../nebula2/meta/MetaService.py", line 18124, in recv_listSpaces
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
  File "../nebula2/fbthrift/protocol/TBinaryProtocol.py", line 153, in readMessageBegin
    name = self.trans.readAll(sz)
  File "../nebula2/fbthrift/transport/TTransport.py", line 75, in readAll
    chunk = self.read(need)
  File "../nebula2/fbthrift/transport/TTransport.py", line 186, in read
    self.__rbuf = StringIO(self.__trans.read(max(sz, self.__rbuf_size)))
  File "../nebula2/fbthrift/transport/TSocket.py", line 301, in read
    message='TSocket read 0 bytes')
nebula2.fbthrift.transport.TTransport.TTransportException: TSocket read 0 bytes

python 代码


if __name__ == '__main__':
    meta_cache = None
    graph_storage_client = None
    try:
        # the metad servers's address
        meta_cache = MetaCache([('127.0.0.1', 49880)], 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()

奇怪的是,执行 GraphClientMultiThreadExample.pyGraphClientSimpleExample.py 都很顺利。

如下是docker内 nebula 信息:
docker-compose ps


nebula 版本是

nebula-graphd version Git: 761f22b, Build Time: Mar 23 2021 13:53:19

meta的端口是49882,不是49880, 49880 是http的

1 个赞

将端口换成 49882 了,但是现在报如下错误:

[2021-03-26 16:28:10,042]:Create storage connection failed: socket error connecting to host storaged0, port 9779 (('127.0.0.1', 9779)): ConnectionRefusedError(61, 'Connection refused')
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 130, in <module>
    graph_storage_client = GraphStorageClient(meta_cache)
  File "../nebula2/sclient/GraphStorageClient.py", line 41, in __init__
    self._create_connection()
  File "../nebula2/sclient/GraphStorageClient.py", line 62, in _create_connection
    conn.open()
  File "../nebula2/sclient/net/__init__.py", line 41, 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 storaged0, port 9779 (('127.0.0.1', 9779)): ConnectionRefusedError(61, 'Connection refused')

macos 是没法访问 docker 里面storage的端口号和ip的,你要换成host模式。论坛里面有人提过相应的问题的。你可以搜索下。

似乎是 storaged0 出问题了

请问 “换成 host 模式” 是指?原谅我这个小白

看这个链接 nebula2-python中如何使用nebula-python中的获取全部点和边的方法scan_vertex,scan_edge - #26 由 henson

浙ICP备20010487号