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)
補(bǔ)充知識(shí):用python訪問hdfs出現(xiàn)webhdfs找不到的情況
有可能是webhdfs服務(wù)沒有開啟
向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的操作就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. ASP刪除img標(biāo)簽的style屬性只保留src的正則函數(shù)2. Spring注入Date類型的三種方法總結(jié)3. PHP循環(huán)與分支知識(shí)點(diǎn)梳理4. HTML 絕對(duì)路徑與相對(duì)路徑概念詳細(xì)5. ASP實(shí)現(xiàn)加法驗(yàn)證碼6. ASP基礎(chǔ)入門第二篇(ASP基礎(chǔ)知識(shí))7. PHP設(shè)計(jì)模式中工廠模式深入詳解8. ASP基礎(chǔ)知識(shí)Command對(duì)象講解9. CSS可以做的幾個(gè)令你嘆為觀止的實(shí)例分享10. PHP session反序列化漏洞超詳細(xì)講解
