记录一次在windows上安装hadoop

1. 首先前往https://hadoop.apache.org/releases.html下载自己喜欢的hadoop版本。由于winutil只支持2.8的,所以不要太高版本。解压。下载的是2.8.5

2.前往https://github.com/steveloughran/winutils/releases下载winutils。编译windows 的hadoop必须,因为hadoop官网支持linux。解压并覆盖至hadoop/bin目录。下载的是2.8.1

3.修改配置文件etc\hadoop下

core-site.xml

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

hdfs-site.xml 目录随意自己喜欢

<configuration>
    <property>
        <name>dfs.replication</name>
        <value>1</value>
    </property>
    <property>    
        <name>dfs.namenode.name.dir</name>    
        <value>namenode目录</value>    
    </property>    
    <property>    
        <name>dfs.datanode.data.dir</name>    
        <value>data目录</value>  
    </property>
</configuration>

mapred-site.xml 通过template复制修改

<configuration>
    <property>
        <name>mapreduce.framework.name</name>
        <value>yarn</value>
    </property>
</configuration>

yarn-site.xml

<configuration>
    <property>
        <name>yarn.nodemanager.aux-services</name>
        <value>mapreduce_shuffle</value>
    </property>
    <property>
        <name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>
        <value>org.apache.hadoop.mapred.ShuffleHandler</value>
    </property>
</configuration>

4. 格式化并启动

进入hadoop bin目录,

hadoop namenode -format

进入sbin 目录 start-all.cmd;

因为不知道怎么直接执行子目录bat,于是只能不停地cd.....

这时可以进入localhost:8088 查看页面

还有一个localhost:50070(3.0版本以上是9870端口);

5.执行wordcount

创建input目录并复制文件进去:

hadoop fs -mkdir /input
hadoop fs -put *.txt /input

执行,由于没有设置classpath,于是直接全名:

hadoop jar E:\st\hadoop-2.8.5\hadoop-2.8.5\share\hadoop\mapreduce\hadoop-mapreduce-examples-2.8.5.jar org.apache.hadoop.examples.WordCount /input /output

查看结果

hadoop fs -cat /output/part-r-00000

over

猜你喜欢

转载自www.cnblogs.com/ddota/p/10715272.html