首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Python hdfscli - Server IPC版本9不能与客户端版本4通信。

Python hdfscli - Server IPC版本9不能与客户端版本4通信。
EN

Stack Overflow用户
提问于 2021-05-29 20:16:03
回答 1查看 160关注 0票数 0

我正在尝试从Python连接到本地运行的Hadoop集群,我一直收到以下错误:requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine('\x00\x00\x00\x7f~\x08ÿÿÿÿ\x0f\x10\x02\x18\t")org.apache.hadoop.ipc.RPC$VersionMismatch*>Server IPC version 9 cannot communicate with client version

下面是我的代码:“从hdfs导入Config

类HDFSClient:_instance = None

代码语言:javascript
运行
复制
def __init__(self, env):
    self._client = Config().get_client(env)

def write_data(self, data, hdfs_filename):
    """
    Write data to an HDFS file.
    """
    pass

def write_data_stream(self, iterator, hdfs_filename):
    """
    Write data to an HDFS file.
    Data is retrieved iteratively from @iterator.
    """
    self._client.write(hdfs_filename, iterator)

@staticmethod
def get_instance(env="dev"):
    if HDFSClient._instance:
        return HDFSClient._instance
    HDFSClient._instance = HDFSClient(env)
    return HDFSClient._instance`

我的配置文件也非常简单:

代码语言:javascript
运行
复制
[global]
default.alias = dev

[dev.alias]
url = http://localhost:9000

[prod.alias]
url = http://localhost:9000

以下是完整的错误:

代码语言:javascript
运行
复制
Traceback (most recent call last):
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\urllib3\connectionpool.py", line 436, in _make_request
    httplib_response = conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\urllib3\connectionpool.py", line 445, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
    # Permission is hereby granted, free of charge, to any person obtaining a copy
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\urllib3\connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\http\client.py", line 1347, in getresponse
    response.begin()
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\http\client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\http\client.py", line 289, in _read_status
    raise BadStatusLine(line)
http.client.BadStatusLine: 

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\urllib3\util\retry.py", line 531, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\urllib3\packages\six.py", line 734, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\urllib3\connectionpool.py", line 445, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
    # Permission is hereby granted, free of charge, to any person obtaining a copy
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\urllib3\connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\http\client.py", line 1347, in getresponse
    response.begin()
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\http\client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\http\client.py", line 289, in _read_status
    raise BadStatusLine(line)
urllib3.exceptions.ProtocolError: ('Connection aborted.', BadStatusLine('\x00\x00\x00\x7f~\x08ÿÿÿÿ\x0f\x10\x02\x18\t")org.apache.hadoop.ipc.RPC$VersionMismatch*>Server IPC version 9 cannot communicate with client version 470\x0e:\x00@\x01Hõ*'))

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\_compat.py", line 39, in reraise
    raise value
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\_compat.py", line 39, in reraise
    raise value
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "C:\Users\Julien\Documents\Travail\PanoptesTechnologies\block-analysis-backend\api\src\with_cors.py", line 12, in decorated_function
    return f(*args, **kwargs)
  File "C:\Users\Julien\Documents\Travail\PanoptesTechnologies\block-analysis-backend\api\utils\log.py", line 37, in decorated
    return f(*args, **kwargs)
  File "C:\Users\Julien\Documents\Travail\PanoptesTechnologies\block-analysis-backend\api\app.py", line 154, in heuristic
   #=======================================================================================================================
File "C:\Users\Julien\Documents\Travail\PanoptesTechnologies\block-analysis-backend\api\utils\hadoop.py", line 21, in write_data_stream
    self._client.write(hdfs_filename, iterator)
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\hdfs\client.py", line 459, in write
    res = self._create(
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\hdfs\client.py", line 125, in api_handler
    raise err
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\hdfs\client.py", line 102, in api_handler
    res = client._request(
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\hdfs\client.py", line 209, in _request
    return self._session.request(
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\Julien\AppData\Local\Programs\Python\Python38\Lib\site-packages\requests\adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine('\x00\x00\x00\x7f~\x08ÿÿÿÿ\x0f\x10\x02\x18\t")org.apache.hadoop.ipc.RPC$VersionMismatch*>Server IPC version 9 cannot communicate with client version 470\x0e:\x00@\x01Hõ*'))

Python版本: 3.8 hdfscli版本: 2.6.0 Hadoop版本: 3.2.1

我已经检查了hdsfcli所需的包版本。

有什么我能解决的吗?谢谢你的帮助。

最好的摄政王

EN

回答 1

Stack Overflow用户

发布于 2022-02-14 14:37:34

韦尔普我也有过同样的挣扎。对于上下文:这个包使用webhdfs API。在其他版本中,它运行在50070端口上,但是对于Hadoop3.2.1和3.3.1 (我的版本),它运行在9870端口上。

只要改变:

代码语言:javascript
运行
复制
[dev.alias]
url = http://localhost:9000

[prod.alias]
url = http://localhost:9000

至:

代码语言:javascript
运行
复制
[dev.alias]
url = http://localhost:9870

[prod.alias]
url = http://localhost:9870

而且你是黄金。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67755421

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档