我正在使用以下 python 代码将文件从本地系统上传到远程 HDFSpyhdfs
from pyhdfs import HdfsClient
client = HdfsClient(hosts='1.1.1.1',user_name='root')
client.mkdirs('/jarvis')
client.copy_from_local('/my/local/file,'/hdfs/path')
使用python3.5/。Hadoop 在默认端口中运行:50070 1.1.1.1 是我的远程 Hadoop url
创建目录“jarvis”工作正常,但复制文件不起作用。我收到以下错误
回溯(最后一次调用):
文件“test_hdfs_upload.py”,第 14 行,在 client.copy_from_local('/tmp/data.json','/test.json')
文件“/Library/Frameworks/Python.framework/ Versions/3.6/lib/python3.6/site-packages/pyhdfs.py”,第 753 行,在 copy_from_local self.create(dest, f, **kwargs)
文件“/Library/Frameworks/Python.framework/Versions/3.6 /lib/python3.6/site-packages/pyhdfs.py”,第 426 行,在创建 metadata_response.headers['location'], data=data, **self._requests_kwargs)
文件“/Library/Frameworks/Python.framework /Versions/3.6/lib/python3.6/site-packages/requests/api.py”,第 99 行,输入返回请求('put',url,data=data,**kwargs)
请求返回 session.request(method=method, url=url, **kwargs)
文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/sessions.py”,第 383 行,在请求中 resp = self.send(prep, * *send_kwargs)
文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/sessions.py”,第 486 行,发送 r = adapter.send(request, **夸格斯)
文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/adapters.py”,第 378 行,在发送中引发 ConnectionError(e) requests.exceptions.ConnectionError: HTTPConnectionPool( host='ip-1-1-1-1', port=50075): 最大重试次数超出 url: /webhdfs/v1/test.json?op=CREATE&user.name=root&namenoderpcaddress=ip-1-1-1- 1:9000&overwrite=false(由:[Errno 8] 节点名或服务名提供,或未知)