您的位置:首頁技術文章
文章詳情頁

python訪問hdfs的操作

瀏覽:15日期:2022-07-22 14:49:36

pip install hdfs

python 讀取hdfs目錄或文件

import hdfs client =hdfs.Client('http://10.10.1.4:50070')fileDir='/user/hive/warehouse/house.db/dm_house/dt=201800909'try: status=client.status(fileDir,False) if status: print (status) rst=client.download(fileDir,'/home/dev/gewei') print (rst)exception Exception as e: print (e)

補充知識:用python訪問hdfs出現webhdfs找不到的情況

有可能是webhdfs服務沒有開啟

向hdfs-site.xml文件中添加屬性:

<property> <name>dfs.webhdfs.enabled</name> <value>true</value> </property>

可以使用如下命令檢測,

獲得目錄的列表:

curl -i 'http://Hadoop:50070/webhdfs/v1/?user.name=hadoop&op=LISTSTATUS'

以上這篇python訪問hdfs的操作就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持好吧啦網。

標簽: Python 編程
相關文章:
国产综合久久一区二区三区