码迷,mamicode.com
首页 > 其他好文 > 详细

Hadoop2.0安装之非HA版

时间:2018-09-24 18:28:49      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:shuff   inpu   pytho   命令   data   server   tar   conf   shuffle   

主要步骤跟Hadoop1.0(1.0安装地址)一致,主要在配置这块有更改

安装

  • 下载地址:http://archive.apache.org/dist/hadoop/core/hadoop-2.6.5/

  • hadoop安装目录创建./tmp目录,./dfs/name,./dfs/data

  • 修改./etc/hadoop/hadoop-env.sh
# 设置JAVA_HOME
export JAVA_HOME="/usr/local/src/jdk1.8.0_181/"
  • 修改./etc/hadoop/yarn-env.sh
# 设置JAVA_HOME
JAVA_HOME="/usr/local/src/jdk1.8.0_181/"
  • 修改./etc/hadoop/slaves
slave1
slave2
  • 修改./etc/hadoop/core-site.xml
<configuration>
    <property>
        <name>fs.defaultFS</name>
        <value>hdfs://master:9000</value>
    </property>
    <property>
        <name>hadoop.tmp.dir</name>
        <value>file:/usr/local/src/hadoop-2.6.5/tmp</value>
    </property>
</configuration>
  • 修改./etc/hadoop/hdfs-site.xml
<configuration>
    <property>
        <name>dfs.namenode.secondary.http-address</name>
        <value>master:9001</value>
    </property>
    <property>
        <name>dfs.namenode.name.dir</name>
        <value>file:/usr/local/src/hadoop-2.6.5/dfs/name</value>
    </property>
    <property>
        <name>dfs.datanode.data.dir</name>
        <value>file:/usr/local/src/hadoop-2.6.5/dfs/data</value>
    </property>
    <property>
        <name>dfs.replication</name>
        <value>2</value>
    </property>
</configuration>
  • 修改./etc/hadoop/mapred-site.xml
<configuration>
    <property>
        <name>mapreduce.framework.name</name>
        <value>yarn</value>
    </property>
    <property>
        <name>mapreduce.jobhistory.address</name>
        <value>slave1:10020</value>
    </property>
    <property>
        <name>mapreduce.jobhistory.webapp.address</name>
        <value>slave1:19888</value>
    </property>
</configuration>
  • 修改./etc/hadoop/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>
    <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.resourcemanager.resource-tracker.address</name>
        <value>master:8035</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>
    <property>
        <name>yarn.log-aggregation-enable</name>
        <value>true</value>
    </property>
    <property>
        <name>yarn.log-aggregation.retain-seconds</name>
        <value>259200</value>
    </property>
    <property>
        <name>yarn.log.server.url</name>
        <value>http://slave1:19888/jobhistory/logs</value>
    </property>
    <property>
        <name>yarn.nodemanager.vmem-pmem-ratio</name>
        <value>4.0</value>
    </property>
</configuration>
  • 和Hadoop1.0一样,第一次启动前,需要格式化hdfs:./bin/hadoop namenode -format

  • 启动:./sbin/start-all.sh

  • 使用:跟Hadoop1.0一样,使用./bin/hadoop命令

  • 关闭:./sbin/stop-all.sh

提交MapReduce任务

基本上没什么变化,除了Hadoop streaming地址变了

[wadeyu@master mr_count]$ cat run.sh
HADOOP_CMD=/usr/local/src/hadoop-2.6.5/bin/hadoop
HADOOP_STREAMING_JAR=/usr/local/src/hadoop-2.6.5/share/hadoop/tools/lib/hadoop-streaming-2.6.5.jar

INPUT_FILE=/data/The_Man_of_Property.txt
OUTPUT_DIR=/output/wc

$HADOOP_CMD fs -rmr -skipTrash $OUTPUT_DIR

$HADOOP_CMD jar $HADOOP_STREAMING_JAR     -input $INPUT_FILE     -output $OUTPUT_DIR     -mapper "python map.py"     -reducer "python red.py"     -file ./map.py     -file ./red.py

参考资料

【0】八斗学院内部培训资料

Hadoop2.0安装之非HA版

标签:shuff   inpu   pytho   命令   data   server   tar   conf   shuffle   

原文地址:https://www.cnblogs.com/wadeyu/p/9696044.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!