Hadoop 第一次安裝就上手 CDH3


Outline
  1. 1. 1. Centos 6.2 (CentOS-6.2-x86_64-bin-DVD1.iso)
  2. 2. 2. JDK installation
  3. 3. 3. System environment configuration
  4. 4. 4. Hadoop Installation
  5. 5. 5. Hadoop 參數配置 與 運行
  • 6. 實例測試
    1. 0.1. Reference
  • 1. Centos 6.2 (CentOS-6.2-x86_64-bin-DVD1.iso

    1
    2
    3
    * Live 版本一般用來修複系統使用,有容量很小,不用安裝,可以自啟動等特性。
    * bin 版本也具有同樣的功能,但是體積較大,所以才會有 Live版本的出現!
    * netinstall 版本則是透過網路來安裝(bin不用網路)。

    1. 使用 vmware 簡易安裝

    2. $ yum update

    3. 不使用GUI 改成 CLI mode:

      使用root登入 $ vim /etc/inittab

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    # 更改 Runlevel
    id:3:initdefault
    # Runlevel 0 and 6: halt and reboot the machine, respectively.
    # Runlevel 1: No services running, only root can login.
    # Runlevel 2: Users can login but no networking.
    # Runlevel 3: Networking and text-mode.
    # Runlevel 4: unused.
    # Runlevel 5: GUI. (原本)
    要換GUI回來的話
    $ init 5
    $ reboot

    2. JDK installation

    1
    2
    3
    $ cd Downloads/
    $ chmod 777 jdk-6u33-linux-x64-rpm.bin
    $ ./jdk-6u33-linux-x64-rpm.bin
    • Setup alternative
    1
    2
    $ alternatives --install /usr/bin/java java /usr/java/latest/bin/java 2
    $ alternatives --config java
    • Execute “java -version” to verify jdk version
    1
    2
    3
    4
    $ java -version
    # java version "1.6.0_33"
    # Java(TM) SE Runtime Environment (build 1.6.0_33-b03-424-11M3720)
    # Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03-424, mixed mode)

    3. System environment configuration

    • Environment Variables $ vim /etc/profile
    1
    2
    export JAVA_HOME=/usr/java/default
    export PATH=$JAVA_HOME/bin:$PATH
    • Swappiness $ vim /etc/sysctl.conf
    1
    vm.swappiness = 0
    • ulimit $ vim /etc/security/limits.conf
    1
    2
    3
    hdfs soft nofile 102642
    hdfs hard nofile 102642
    hbase - nofile 102642

    4. Hadoop Installation

    1
    2
    $ tar -zxvf hadoop-1.0.4.tar.gz
    $ mv hadoop-1.0.4 /usr/java/
    • 設置hadoop的JAVA_HOME環境變量
    1
    2
    $ cd /usr/java/hadoop-1.0.4/conf/
    $ vi hadoop-env.sh
    1
    export JAVA_HOME="/usr/java/jdk1.6.0_33/"
    • 在hadoop解壓文件下,有一個“hadoop-mapred-examples-0.22.0.jar”包,使用以下指令可以查看該jar的內容。
    1
    $ jar tf hadoop-examples-1.0.4.jar
    • 測試 wordcount
    1
    2
    3
    4
    5
    6
    7
    8
    $ mkdir input
    $ cd input
    $ echo "hello world">test1.txt
    $ echo "hello hadoop">test2.txt
    $ cd ..
    $ bin/hadoop jar hadoop-examples-1.0.4.jar wordcount input outputc
    # check output

    5. Hadoop 參數配置 與 運行

    跟著步驟6.1~6.3

    1. jobtracker http://localhost:50030
    2. tasktracker http://localhost:50060
    3. dfshealth http://localhost:50070

    6. 實例測試

    1
    2
    $ bin/hadoop dfs -copyFromLocal input inputTest
    $ bin/hadoop jar hadoop-examples-1.0.4.jar wordcount inputTest outputTest

    Reference