windows配置hadoop环境变量

Posted 快乐的小银龙

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

 

以上是关于windows配置hadoop环境变量的主要内容,如果未能解决你的问题,请参考以下文章

Windows 下Hadoop的环境变量配置

Hadoop学习之Windows单机版安装

windows下运行hadoop2.7.2

HIVE学习系列——windows Hadoop安装(上)

Hadoop中HDFS的API操作客户端环境准备配置HADOOP_HOME环境变量

傻瓜式教程Windows下安装Hive MySQL版附安装Hadoop教程全网最详细的图文教程