栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

【hdfs】在win10上使用python访问hdfs操作文件

【hdfs】在win10上使用python访问hdfs操作文件

1、环境安装:使用cmd安装hdfs环境,pip install hdfs

2、访问hdfs:

from hdfs.client import Client
HDFSHOST = "http://192.168.56.101:9870"
client = Client(HDFSHOST)
# 返回目录下的文件
#print(client.list('/wm/'))

# 创建目录
#client.makedirs('/tmp')
#print(client.list('/'))

# 删除hdfs文件
#print(client.delete('/wm/start-dfs.sh'))
#print(client.list('/wm'))

# 上传文件到hdfs(需要将集群所有节点配置到hosts
#client.upload('/tmp','D:\2.txt',cleanup=True)
#print(client.list('/tmp'))

# 追加数据到hdfs文件,小于3副本需要修改配置文件
#client.write('/tmp/2.txt', 'sssddss', overwrite=False,  append=True, encoding='utf-8')


# 覆盖数据写到hdfs文件
#client.write('/tmp/1.txt', 'fugai', overwrite=True, append=False, encoding='utf-8')

# 移动或者修改文件
#client.rename('/tmp/1.txt','/tmp/5.txt')

当集群副本设置小于3时,覆盖文件报错Trafodion Troubleshooting-Failed to replace a bad datanode on the existing pipeline:

解决:修改hdfs-site.xml文件,添加或者修改以下两项:node


dfs.client.block.write.replace-datanode-on-failure.enable
true


dfs.client.block.write.replace-datanode-on-failure.policy
NEVER
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/775694.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号