windows配置hadoop环境变量

1.首先需要下载 hadoop的tar.gz包,目前最新版本是2.9.0 下载地址:

文件共享在最下面

http://hadoop.apache.org/releases.html

前提是JDK必须配置成功

我的hadoop是在 如图解压在E盘下  解压完之后大概是2G多需要一点时间啊

2.修改etc\hadoop下的文件(注意以下配置文件下所有的地址都是从Linux集群中的hadoop  jar粘贴复制过来的)

4个配置文件

 core-site.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>
<property>
   <name>fs.defaultFS</name>
   <value>hdfs://master:9000</value>
</property>

  <property>
     <name>hadoop.tmp.dir</name>
     <value>/usr/local/hadoop-2.8.0/tmp</value> //linux集群中的地址
</property>

</configuration>

mapred-site.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>
 <property>
    <name>mapreduce.framework.name</name>
    <value>yarn</value>
  </property>
  <property>
    <name>mapreduce.jobhistory.address</name>
    <value>master:10020</value>
  </property>
  <property>
    <name>mapreduce.jobhistory.address</name>
    <value>master:19888</value>
  </property>

</configuration>

hdfs-site.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>
<property>
      <name>dfs.namenode.secondary.http-address</name>
      <value>master:50090</value>
    </property>
    <property>
      <name>dfs.replication</name>
      <value>2</value>
    </property>
    <property>
      <name>dfs.namenode.name.dir</name>
      <value>file:/usr/local/hadoop-2.8.0/hdfs/name</value>
    </property>
    <property>
      <name>dfs.datanode.data.dir</name>
      <value>file:/usr/local/hadoop-2.8.0/hdfs/data</value>
    </property>

</configuration>

yarn-site.xml

<?xml version="1.0"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->
<configuration>

<!-- Site specific YARN configuration properties -->

<property>
          <name>yarn.nodemanager.aux-services</name>
          <value>mapreduce_shuffle</value>
  </property>
  <property>
           <name>yarn.resourcemanager.address</name>
           <value>master:8032</value>
  </property>
  <property>
          <name>yarn.resourcemanager.scheduler.address</name>
          <value>master:8030</value>
  </property>
<property>  
    <name>yarn.log-aggregation-enable</name>  
    <value>true</value>  
</property> 

 <property>
         <name>yarn.resourcemanager.resource-tracker.address</name>
         <value>master:8031</value>
     </property>
     <property>
         <name>yarn.resourcemanager.admin.address</name>
         <value>master:8033</value>
     </property>
     <property>
         <name>yarn.resourcemanager.webapp.address</name>
         <value>master:8088</value>
     </property>

      
</configuration>

3.配置环境变量

此电脑--属性--高级系统设置--环境变量

新建系统变量

变量名:HADOOP_HOME

变量值:你的hadoop位置  E:\hadoop\hadoop-2.8.0\hadoop-2.8.0

编辑Path系统路径   %HADOOP_HOME%\bin

然后一路确定下来

4.编辑hadoop的文件

如下打开 \etc\hadoop\hadoop-enc.cmd文件,修改JAVA_HOME为你自己的jdk路径 。注意你的JDK安装在Program Files目录下,

名称用名称用\PROGRA~1\Java 否则中间的空格可能会识别失败。

到此为止配置完毕 如果不行的化可能需要点右键运行一遍

5.window+r打开 cmd窗口输入 hadoop测试

配置成功 也可以格式化节点具体命令是

1、切换到etc/hadoop目录,运行hadoop-env.cmd

2、格式化HDFS文件系统,切换到bin目录然后执行命令:hdfs namenode -format

 

posted @ 2018-03-18 16:22  快乐的小银龙  阅读(4965)  评论(0编辑  收藏  举报