zoukankan      html  css  js  c++  java
  • Hadoop单机模式配置

    Required Software

    1. 安装Java环境推荐的版本在链接中有介绍HadoopJavaVersions.

    2. 安装ssh以使用hadoop脚本管理远程Hadoop daemons.

    Download Hadoop

    relevant mirror download

    Installing Software

    1. 安装JDK,网上的教程比较多,不做详述

    2. 安装ssh,在Ubuntu Linux系统上通过如下指令安装:

    $ sudo apt-get install ssh
    $ sudo apt-get install rsync
    

    对于mac操作系统,需要在偏好设置中开启远程登录服务。

    Configuration

    配置Hadoop环境变量

    export HADOOP_HOME="/Users/majun/mysoftware/hadoop272"
    export PATH="$PATH:/Users/majun/mysoftware/scala/bin:$HADOOP_HOME/bin"
    export HADOOP_OPTS="$HADOOP_OPTS -Djava.library.path=/usr/local/hadoop/lib/native"
    

    修改etc/hadoop/core-site.xml:

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

    etc/hadoop/hdfs-site.xml:

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

    Setup passphraseless ssh

    使用如下命令来判断是否需要输入密码来ssh登陆:

    ssh localhost
    

    如果无法登陆在不输密码的情况下,可以执行下面的语句:

      $ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
      $ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
      $ chmod 0600 ~/.ssh/authorized_keys
    

    Execution

    序列化数据

      $ bin/hdfs namenode -format
    

    启动namenode和datanode daemon

      $ sbin/start-dfs.sh
    

    打开NameNode的web

    NameNode - http://localhost:50070/
    

    创建hdfs目录

    $ bin/hdfs dfs -mkdir /user
    $ bin/hdfs dfs -mkdir /user/<username>
    

    将本地input拷进hdfs系统中

    $ bin/hdfs dfs -put etc/hadoop input
    

    运行官方提供的sample

    $ bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar grep input output 'dfs[a-z.]+'
    

    检验输出文件,将hdfs文件拷到本地

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

    Reference

    官方文档

  • 相关阅读:
    快速搭建http server
    cwmp part2 测试基础RPC
    Leetcode-5223 Queens That Can Attack the King(可以攻击国王的皇后)
    Leetcode-5222 Split a String in Balanced Strings(分割平衡字符串)
    Leetcode-5224 Dice Roll Simulation(掷骰子模拟)
    P2604-[ZJOI2010]网络扩容
    P2053-[SCOI2007]修车
    P2153-[SDOI2009]晨跑
    P2774 方格取数问题
    P2763-试题库问题
  • 原文地址:https://www.cnblogs.com/jun-ma/p/5281197.html
Copyright © 2011-2022 走看看