一.虛擬機安裝CentOS7并配置共享文件夾
二.CentOS 7 上hadoop偽分布式搭建全流程完整教程
三.本機使用python操作hdfs搭建及常見問題
四.mapreduce搭建
五.mapper-reducer編程搭建
確保網(wǎng)頁可以打開
ifconfig
查看當(dāng)前ip,
打開C:\Windows\System32\drivers\etc\,編輯hosts文件 ,在末尾添加192.168.137.134 hadoop4
若不可以編輯
右鍵屬性->安全->選擇Users那個->編輯->勾選修改 即可
打開我的電腦打開任意文件夾->左上角文件->打開Windows powershell->
進(jìn)行ping測試
wIn+r 輸入cmd進(jìn)入執(zhí)行(在任意python或conda環(huán)境安裝皆可)
pip install hdfs -i https://pypi.douban.com/simple/
二、python操作hdfs
1.建立連接PS D:\software\Bandicam\video>python
Python 3.9.7 (default, Sep 16 2021, 16:59:28) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
Type "help", "copyright", "credits" or "license" for more information.
>>>from hdfs.client import Client
>>>link=Client('http://hadoop4:50070')
>>>link.list('/')
[]
2.創(chuàng)建文件夾新建文件夾出現(xiàn)錯誤
>>>link.makedirs('/test')
Traceback (most recent call last):
File "", line 1, inFile "D:\Anaconda3\install_position\lib\site-packages\hdfs\client.py", line 1036, in makedirs
self._mkdirs(hdfs_path, permission=permission)
File "D:\Anaconda3\install_position\lib\site-packages\hdfs\client.py", line 118, in api_handler
raise err
hdfs.util.HdfsError: Permission denied: user=dr.who, access=WRITE, inode="/":huangqifa:supergroup:drwxr-xr-x
解決:
虛擬機端執(zhí)行hadoop fs -chmod -R 777 /
>>>link.makedirs('/test')
>>>link.list('/')
['test']
>>>
創(chuàng)建文件夾出現(xiàn)安全模式問題:
>>>link.makedirs('/test')
Traceback (most recent call last):
File "", line 1, inFile "D:\Anaconda3\install_position\lib\site-packages\hdfs\client.py", line 1036, in makedirs
self._mkdirs(hdfs_path, permission=permission)
File "D:\Anaconda3\install_position\lib\site-packages\hdfs\client.py", line 118, in api_handler
raise err
hdfs.util.HdfsError: Cannot create directory /test. Name node is in safe mode.
Resources are low on NN. Please add or free up more resources then turn off safe mode manually. NOTE: If you turn off safe mode before adding resources, the NN will immediately return to safe mode. Use "hdfs dfsadmin -safemode leave" to turn safe mode off.
解決:
虛擬機端執(zhí)行
hdfs dfsadmin -safemode leave
3.上傳文件(需保證jps服務(wù)中datanode namenode均打開)>>>link.makedirs('/test')
>>>link.list('/')
['test']
>>>link.upload('/test','C:/readme.txt')
'/test/readme.txt'
>>>link.list('/test')
['readme.txt']
>>>link.write('/test/test01.txt',"hello world")
>>>link.list('/test')
['readme.txt', 'test01.txt']
5.下載文件或文件夾>>>link.download('/test/test01.txt','D:/')
'D:\\test01.txt'
>>>
問題描述:物理機ping不到虛擬機ip或物理機192.168…h(huán)adoop網(wǎng)頁打不開
重置虛擬機網(wǎng)絡(luò)中NAT那個
解決:
虛擬機軟件->左上角編輯->虛擬機網(wǎng)絡(luò)編輯器
你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機房具備T級流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級服務(wù)器適合批量采購,新人活動首月15元起,快前往官網(wǎng)查看詳情吧
本文名稱:本機使用python操作hdfs搭建及常見問題-創(chuàng)新互聯(lián)
網(wǎng)址分享:http://www.rwnh.cn/article32/cegcsc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營銷推廣、App設(shè)計、網(wǎng)站排名、搜索引擎優(yōu)化、軟件開發(fā)、虛擬主機
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容