Windows本地配置hadoop运行环境

windows本地配置hadoop运行环境,可以帮助我们更好进行开发或者hadoop学习。
本文介绍了如何搭建一个hadooop伪运行环境。

一、下载安装包并配置环境变量

下载hadoop binary安装安装包:
https://hadoop.apache.org/releases.html
下载完后配置环境变量:
HADOOP_HOME=D:\hadoop-2.6.0
path里面添加:%HADOOP_HOME%/bin

二、修改hadoop配置文件

进入hadoop安装目录D:\hadoop-2.6.0\etc\hadoop,修改D:\hadoop-2.6.0\etc\hadoop下面的
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://localhost:9000/</value>
  </property>
  <property>
    <name>io.native.lib.available</name>
    <value>false</value>
  </property>
  <property>
    <name>hadoop.native.lib</name>
    <value>false</value>
  </property>
  <property>
    <name>io.compression.codecs</name>
    <value>org.apache.hadoop.io.compress.GzipCodec,
           org.apache.hadoop.io.compress.DefaultCodec,
           com.hadoop.compression.lzo.LzoCodec,
           com.hadoop.compression.lzo.LzopCodec,
           org.apache.hadoop.io.compress.BZip2Codec,
           org.apache.hadoop.io.compress.SnappyCodec
        </value>
</property>
<property>
    <name>io.compression.codec.lzo.class</name>
    <value>com.hadoop.compression.lzo.LzoCodec</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.replication</name>  
			<value>1</value>  
   </property>
   <property>
			<name>dfs.namenode.name.dir</name>  
		   <value>file:///D:/Hadoop/namenode</value>  
   </property>
   <property>
		   <name>dfs.datanode.data.dir</name>  
		   <value>file:///D:/Hadoop/datanode</value>  
   </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>mapred.compress.map.output</name>
        <value>true</value>
    </property>
    <property>
        <name>mapred.map.output.compression.codec</name>
        <value>com.hadoop.compression.lzo.LzoCodec</value>
    </property> 
    <property> 
        <name>mapred.child.env</name> 
        <value>LD_LIBRARY_PATH=</value>
        <name>mapreduce.framework.name</name>
        <value>yarn</value>
    </property>
    <property>
        <name>mapred.compress.map.output</name>
        <value>true</value>
    </property>
    <property>
        <name>mapred.map.output.compression.codec</name>
        <value>com.hadoop.compression.lzo.LzoCodec</value>
    </property> 
    <property> 
        <name>mapred.child.env</name> 
        <value>LD_LIBRARY_PATH=D:\hadoop-2.7.3-win64\lib</value> 
    </property>
</configuration>

然后到bin目录下执行:
hdfs namenode -format
再到sbin目录下执行:
start-all.cmd
在这里插入图片描述

三、安装完后验证

浏览器输入:http://localhost:8088可以打开管理界面
命令行输入:

D:\hadoop-2.6.0\sbin>hadoop fs -ls /
Found 2 items
drwxr-xr-x   - HP supergroup          0 2019-06-19 10:28 /data
drwxr-xr-x   - HP supergroup          0 2019-06-19 11:00 /input

D:\hadoop-2.6.0\sbin>hadoop fs -mkdir /data1

D:\hadoop-2.6.0\sbin>hadoop fs -ls /
Found 3 items
drwxr-xr-x   - HP supergroup          0 2019-06-19 10:28 /data
drwxr-xr-x   - HP supergroup          0 2019-06-19 11:20 /data1
drwxr-xr-x   - HP supergroup          0 2019-06-19 11:00 /input
  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值