一.虚拟机安装CentOS7并配置共享文件夹
二.CentOS 7 上hadoop伪分布式搭建全流程完整教程
三.本机使用python操作hdfs搭建及常见问题
四.mapreduce搭建
五.mapper-reducer编程搭建
ifconfig
查看当前ip,
打开C:\Windows\System32\drivers\etc\,编辑hosts文件 ,在末尾添加192.168.137.134 hadoop4
若不可以编辑
右键属性->安全->选择Users那个->编辑->勾选修改 即可
打开我的电脑打开任意文件夹->左上角文件->打开Windows powershell->
进行ping测试
wIn+r 输入cmd进入执行(在任意python或conda环境安装皆可)
pip install hdfs -i https://pypi.douban.com/simple/
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('/')
[]
新建文件夹出现错误
>>> link.makedirs('/test')
Traceback (most recent call last):
File "" , line 1, in <module>
File "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
解决:
虚拟机端执行hadoop fs -chmod -R 777 /
>>> link.makedirs('/test')
>>> link.list('/')
['test']
>>>
>>> link.makedirs('/test')
Traceback (most recent call last):
File "" , line 1, in <module>
File "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.
解决:
虚拟机端执行
hdfs dfsadmin -safemode leave
>>> 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']
>>> link.download('/test/test01.txt','D:/')
'D:\\test01.txt'
>>>
问题描述:物理机ping不到虚拟机ip或物理机192.168…hadoop网页打不开
重置虚拟机网络中NAT那个
解决:
虚拟机软件->左上角编辑->虚拟机网络编辑器