python訪問hdfs的操作
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出現(xiàn)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的操作就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持好吧啦網。
相關文章:
1. jscript與vbscript 操作XML元素屬性的代碼2. 不要在HTML中濫用div3. ASP將數(shù)字轉中文數(shù)字(大寫金額)的函數(shù)4. XML在語音合成中的應用5. HTML5實戰(zhàn)與剖析之觸摸事件(touchstart、touchmove和touchend)6. .NET Framework各版本(.NET2.0 3.0 3.5 4.0)區(qū)別7. XML入門的常見問題(三)8. 基于PHP做個圖片防盜鏈9. ASP基礎入門第四篇(腳本變量、函數(shù)、過程和條件語句)10. php使用正則驗證密碼字段的復雜強度原理詳細講解 原創(chuàng)
