使用pyhdfs(httpconnectionpool)将本地文件放入hdfs时出错

gg58donl  于 2021-05-27  发布在  Hadoop
关注(0)|答案(0)|浏览(186)

我想用 pyhdfs 在我的hdfs系统上操作。我可以得到 lstdir 或者 NameNode 信息正常,但我无法将本地文件放入系统,我得到如下错误:
connectionerror:httpconnectionpool(host='ali',端口=50075):超过url:/webhdfs/v1/harrypotter/harry%20potter2.txt?op=create&user.name=root&namenoderpcaddress的最大重试次数=ali:9000&overwrite=false (由newconnectionerror('<urllib3.connection.httpconnection object at 0x000001ba68852d00>:无法建立新连接:[errno 11001]getaddrinfo failed')引起)
我已经试过了 max_tries 以及 retry_delay 数量大,但问题又来了。下面是我的代码(localfile alredy位于正确的路径):

import pyhdfs
fs = pyhdfs.HdfsClient(hosts='my_ip_here,50070', user_name='root', max_tries=10, retry_delay=2000)
path='/HarryPotter/'
print('Path existed!') if fs.exists(path) else fs.mkdirs(path)
file = 'harry potter2.txt'
print('File existed!') if fs.exists(path+file) else fs.copy_from_local(file, path+file)

感谢您的帮助:)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题