美文网首页
win7 搭建hadoop demo

win7 搭建hadoop demo

作者: gehaixia | 来源:发表于2019-08-28 15:58 被阅读0次

    第一次搭建hadoop环境,因为目前没有linux环境,只能在window本地搭建,window环境的搭建比linux麻烦点,做下记录,毕竟好记性不如烂笔头,并且现在记忆里不断地下降。。。

    初学hadoop,很多内容都是边查边学的理解的不对,还请指正。。。。

    1、环境准备

    我用的hadoop的版本是最先版本3.2的版本,下载地址:https://hadoop.apache.org/release/3.2.0.html的二进制版本,如果在window环境中部署安装hadoop需要winutils,官方推荐的下载地址https://github.com/4ttty/winutils,找到相应版本进行配置。

    我安装的hadoop是hadoop-3.2.0的版本,选择的winutils的版本为3.1(目前的最高版为3.1,测试过可用)

    2、安装步骤

    (1)解压hadoop-3.2.0到D:\hadoop-3.2.0,

    (2)然后配置环境变量,HADOOP_HOME=D:\hadoop-3.2.0,环境变量PATH=%HADOOP_HOME%\bin;%HADOOP_HOME%\sbin

    (3)cmd窗口运行hadoop version,如下图所示表示安装配置成功

    如下图:

    (4)

    因为在window环境下需要解压apache-hadoop-3.1.0-winutils-master.zip这个并替换D:\hadoop-3.2.0\bin中的相同文件

    (5)修改core-site.xml、hdfs-site.xml、mapred-site.xml、yarn-site.xml文件:

    hadoop 启动:在cmd中start-all

    hadoop资源、节点的查看web地址:http://localhost:8088/cluster

    hdfsweb地址:http://localhost:9870/dfshealth.html#tab-overview,hadoop版本3以后的端口由http://localhost:50070/修改为了http://localhost:9870

    创建hdfs额目录:

    hadoop fs -mkdir /test

    hadoop fs -mkdir /test/input

    -put 是上传命令            -ls是查看命令

    C:\Users\Administrator>hadoop fs -put D:\test\hadoop_test.txt /test/input 上传文件

    C:\Users\Administrator>hadoop fs -ls /test/input 查看上传的文件

    C:\Users\Administrator>hadoop jar D:\hadoop-3.2.0\share\hadoop\mapreduce\hadoop-

    mapreduce-examples-3.2.0.jar wordcount /test/input /test/output 使用wordcount方法统计字符个数

    C:\Users\Administrator>hadoop fs -ls /test/outpu 查看输出目录

    3、demo测试

    (1)随便创建一个文档,D:\test\hadoop_test.txt

    (2)上传并运行wordcount方法(命令参考上面步骤)

    运行结果:

    1

    相关文章

      网友评论

          本文标题:win7 搭建hadoop demo

          本文链接:https://www.haomeiwen.com/subject/pasqcctx.html