hadoop环境搭建官方文档(一)伪分布式搭建

首先学习hadoop集群搭建,最好的方法还是去多看官方文档里面包含各种环境搭建的过程和原因。

官方文档:https://hadoop.apache.org/docs/r2.5.2/

下载hadoop2.5.0  :http://archive.apache.org/dist/hadoop/common/

(这里有hadoop历史上的所有的版本,不过2.5.0版本是相对很稳定的版本,比较适合学习)

首先说明,hadoop环境搭建共分为四种方式:(安装hadoop之前需要安装jdk并且配置环境变量

一.本地模式 

本地模式不需要对hadoop进行配置,只要解压就可以了,下面是官方文档对hdfs的一些操作实现。

  $ mkdir input
  $ cp etc/hadoop/*.xml input
  $ bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.5.2.jar grep input output 'dfs[a-z.]+'
  $ cat output/*

二.伪分布式

  • Pseudo-Distributed Mode
  • 1.首先配置hdfs文件系统
  • 配置之前先设置三个配置文件中的java_home的环境变量
  • etc/hadoop/mapred-env.sh
  • etc/hadoop/yarn-env.sh
  • etc/hadoop/hadoop-env.sh
  • 1. core-site.xml (注意:localhost改成你的主机名)

   配置namenode的主机名和端口号

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

  <!--设置临时目录文件 对应你自己设置的临时目录-->
  <property>
 <name>hadoop.tmp.dir</name>
  <value>/opt/modules/hadoop-2.5.0/data/tmp</value>
  </property>

 

2.配置hdfs-site.xml(设置文件备份,伪分布式部署在一台机器上,设置为1)

<configuration>
    <property>
        <name>dfs.replication</name>
        <value>1</value>
    </property>
</configuration>

3.对应文档进行格式化文件系统

  1. Format the filesystem:格式化文件系统(以后不要轻易再格式化了,容易报错,第二次格式化之前,清空日志信息,和配置的临时目录)
      $ bin/hdfs namenode -format
  2. Start NameNode daemon and DataNode daemon:(启动hdfs)
      $ sbin/start-dfs.sh

    The hadoop daemon log output is written to the $HADOOP_LOG_DIR directory (defaults to $HADOOP_HOME/logs).

  3. Browse the web interface for the NameNode; by default it is available at:(查看网址50070端口号,localhost修改为你对应的主机IP地址)
    • NameNode - http://localhost:50070/
  4. Make the HDFS directories required to execute MapReduce jobs:(创建hdfs文件,在网页上查看)
      $ bin/hdfs dfs -mkdir /user
      $ bin/hdfs dfs -mkdir /user/<username>
  5. Copy the input files into the distributed filesystem:
      $ bin/hdfs dfs -put etc/hadoop input
  6. Run some of the examples provided:
      $ bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.5.2.jar grep input output 'dfs[a-z.]+'
  7. Examine the output files:(上传文件到hdfs)

    Copy the output files from the distributed filesystem to the local filesystem and examine them:

      $ bin/hdfs dfs -get output output
      $ cat output/*

    or

    View the output files on the distributed filesystem:(显示output文件内容)

      $ bin/hdfs dfs -cat output/*
  8. When you're done, stop the daemons with:(停止hdfs)

      $ sbin/stop-dfs.sh

    3.配置yarn的环境变量  yarn-site.xml

<configuration>
    <property>
        <name>yarn.nodemanager.aux-services</name>
        <value>mapreduce_shuffle</value>
    </property>
<!--设置resourcemanage的配置映射主机名-->
   <property>
        <name>yarn.resourcemanager.hostname</name>
        <value>bigdata-senior01</value>
    </property>

   <!--hdfs文件聚集设置-->
   <property>
        <name>yarn.log-aggregation-enable</name>
        <value>true</value>
    </property>

<!--设置保存日志文件时间 设置为七天-->
   <property>
        <name>yarn.log-aggregation.retain-seconds</name>
        <value>640800</value>
    </property>

4.配置mapred-site.xml  (是mapred-site.xml.template重新命名来的)

<configuration>
 <property>
        <name>mapreduce.framework.name</name>
        <value>yarn</value>
    </property>
<!--配置historyserver服务的两项配置-->
<property>
        <name>mapreduce.jobhistory,address</name>
        <value>bigdata-senior01:10020</value>
    </property>
<property>
        <name>mapreduce.jobhistory.webapp.address</name>
        <value>bigdata-senior01:19888</value>
    </property>

</configuration>
 

 

sbin/start-yarn.sh

查看8088端口号
 

 

三.完全分布式

四.HA高可用方式

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值