1. 程式人生 > 其它 >windows本地掛載HDFS

windows本地掛載HDFS

1、修改配置檔案

進入配置檔案目錄:

cd ${HADOOP_HOME}/etc/hadoop

修改core-site.xml:

vim core-site.xml

在檔案中增加以下內容:

<property>
  <name>hadoop.proxyuser.root.groups</name>
  <value>*</value>
  <description>
         The 'nfsserver' user is allowed to proxy all members of the 'users-group1' and
         'users-group2' groups. Note that in most cases you will need to include the
         group "root" because the user "root" (which usually belonges to "root" group) will
         generally be the user that initially executes the mount on the NFS client system.
         Set this to '*' to allow nfsserver user to proxy any group.
  </description>
</property>

<property>
  <name>hadoop.proxyuser.root.hosts</name>
  <value>*</value>
  <description>
         This is the host where the nfs gateway is running. Set this to '*' to allow
         requests from any hosts to be proxied.
  </description>
</property>

修改hdfs-site.xml:

vim hdfs-site.xml

在檔案中增加以下內容(ip等需要根據實際情況修改):

<property>
    <name>nfs.superuser</name>
    <value>root</value>
</property>
 <property>
    <name>dfs.namenode.accesstime.precision</name>
    <value>3600000</value>
    <description>The access time for HDFS file is precise upto this value.
           The default value is 1 hour. Setting a value of 0 disables
           access times for HDFS.
     </description>
</property>
<property>
     <name>nfs.dump.dir</name>
     <value>/tmp/.hdfs-nfs</value>
</property>
<property>
     <name>nfs.exports.allowed.hosts</name>
     <value>192.168.16.* rw</value>
</property>

修改log4j.properties:

vim log4j.properties

在最後增加以下內容:

log4j.logger.org.apache.hadoop.hdfs.nfs=DEBUG
log4j.logger.org.apache.hadoop.oncrpc=DEBUG

2、關閉系統服務

#使用root許可權停止系統本身的服務
service nfs stop
service rpcbind stop

3、啟動服務

#重啟Hadoop服務
start-all.sh
#檢視程序是否正確
jps
#後臺開啟hadoop自帶的portmap服務,需要root許可權
hadoop-daemon.sh start portmap 

#後臺開啟hadoop自帶的nfs服務,注意:啟動該服務的使用者需要與啟動Hadoop叢集的使用者一致
hadoop-daemon.sh start nfs3

驗證檢視rpc的掛載情況:

rpcinfo -p ${nfs伺服器ip}

4、開啟windows的NFS服務(windows10)

進入控制面板選擇程式和功能:

點選啟用或關閉windows功能:

勾選NFS服務:

注:如果此處沒有NFS服務證明當前Windows環境是家庭版,請升級到企業版或專業版後開啟服務。升級方法如下:

此電腦 -> 屬性 -> 更改產品金鑰 -> 輸入產品金鑰 -> 驗證成功後等待升級完成

#以下兩條金鑰如果都驗證失敗,請自行搜尋其他金鑰
J7QT3-3GCPG-9GVWT-CH2XR-GMRJM
VK7JG-NPHTM-C97JM-9MPGT-3V66T

5、掛載

#在一個區域網內的windows 系統掛載 centos7 的 HDFS 檔案系統使用命令:
net use X: \\${nfs伺服器ip}\!

檢視掛載情況:

到此掛載完成!!!

注:如果出現如下情況,請檢查配置檔案是否配置正確以及使用jps命令檢視程序是否成功啟動。

#如果需要結束掛載點使用以下命令
net use X: /del