Hadoop 2.5.2版本安裝部署

呆呆笨笨的魚發表於2014-12-02

軟體及版本:

Hadoop版本

hadoop-2.5.2

作業系統

Red Hat Linux 6.4

32bit

JDK版本

jdk-8u25-linux-i586.rpm


軟體準備:

下載hadoop-2.5.2

wget

 

下載JDKjdk-8u25-linux-i586.rpm

       

總體的流程如下:
1
、實現ssh無密碼驗證配置
2
、安裝jdk,並配好環境變數
3
、安裝與配置Hadoop
4
、格式化與啟動
5
、驗證是否啟動


一.主機之間SSH無密碼驗證
利用 :  ssh-kengen –t rsa 命令產生公鑰,將個主機之間的公鑰,相互複製到authorized_keys檔案內。

二.安裝JDK
安裝好後,用java -version 檢驗下

配置環境變數: 

點選(此處)摺疊或開啟

  1. ###set java_env
  2. export JAVA_HOME=/usr/java/jdk1.8.0_25/
  3. export JRE_HOME=/usr/java/jdk1.8.0_25/jre
  4. export CLASS_PATH=.:$CLASS_PATH:$JAVA_HOME/lib:$JRE_HOME/lib
  5. export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
  6. ###set hadoop_env
  7. export HADOOP_HOME=/home/zhang/hadoop-2.5.2
  8. export HADOOP_COMMON_HOME=$HADOOP_HOME
  9. export HADOOP_HDFS_HOME=$HADOOP_HOME
  10. export HADOOP_MAPRED_HOME=$HADOOP_HOME
  11. export HADOOP_YARN_HOME=$HADOOP_HOME
  12. export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
  13. export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HADOOP_HOME/lib
  14. export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
  15. export HADOOP_OPTS=\"-Djava.library.path=$HADOOP_HOME/lib\"


三.部署配置Hadoop
解壓Hadoop 到 自己的hadoop 目錄

配置相關的配置檔案
2.5.x版本的配置檔案在:$Hadoop_Home/etc/hadoop  目錄下
2.X版本較1.X版本改動很大,主要是用Hadoop MapReduceV2(Yarn) 框架代替了一代的架構,其中JobTracker 和 TaskTracker 不見了,取而代之的是 ResourceManager, ApplicationMaster 與 NodeManager 三個部分,而具體的配置檔案位置與內容也都有了相應變化,具體的可參考文獻:http://www.ibm.com/developerworks/cn/opensource/os-cn-hadoop-yarn/

(1)hadoop/etc/hadoop/hadoop-env.sh 與 hadoop/etc/hadoop/yarn-env.sh來配置兩個檔案裡的JAVA_HOME

(2)etc/hadoop/core-site.xml,配置為:

點選(此處)摺疊或開啟

  1. <configuration>

  2. <property>
  3. <name>hadoop.tmp.dir</name>
  4. <value>/home/zhang/hadoop-2.5.2/tmp</value>
  5. <description>A base for other temporary directories.</description>
  6. </property>

  7. <property>
  8. <name>fs.default.name</name>
  9. <value>hdfs://namenode:9000</value>
  10. </property>

  11. <property>
  12. <name>io.file.buffer.size</name>
  13. <value>131072</value>
  14. </property>

  15. <property>
  16. <name>hadoop.proxyuser.root.hosts</name>
  17. <value>namenode</value>
  18. </property>

  19. <property>
  20. <name>hadoop.proxyuser.root.groups</name>
  21. <value>*</value>
  22. </property>


  23. </configuration>

(3)etc/hadoop/hdfs-site.xml,配置為: (注意:這裡需要自己手動用mkdir建立name和data資料夾,具體位置也可以自己選擇,其中dfs.replication的值建議配置為與分散式 cluster 中實際的 DataNode 主機數一致。)

點選(此處)摺疊或開啟

  1. <configuration>
  2. <property>
  3. <name>dfs.namenode.name.dir</name>
  4. <value>/home/zhang/hadoop-2.5.2/hdfs/name</value>
  5. <final>true</final>
  6. </property>

  7. <property>
  8. <name>dfs.datanode.data.dir</name>
  9. <value>/home/zhang/hadoop-2.5.2/hdfs/data</value>
  10. <final>true</final>
  11. </property>

  12. <property>
  13. <name>dfs.replication</name>
  14. <value>2</value>
  15. </property>

  16. <property>
  17. <name>dfs.permissions</name>
  18. <value>false</value>
  19. </property>

  20. </configuration>

(4)etc/hadoop/mapred-site.xml,配置為:

點選(此處)摺疊或開啟

  1. <configuration>
  2. <property>
  3. <name>mapreduce.framework.name</name>
  4. <value>Yarn</value>
  5. </property>

  6. <property>
  7. <name>mapreduce.jobhistory.address</name>
  8. <value>namenode:10020</value>
  9. </property>

  10. <property>
  11. <name>mapreduce.jobhistory.webapp.address</name>
  12. <value>namenode:19888</value>
  13. </property>

  14. <property>
  15. <name>mapreduce.jobhistory.intermediate-done-dir</name>
  16. <value>/mr-history/tmp</value>
  17. </property>

  18. <property>
  19. <name>mapreduce.jobhistory.done-dir</name>
  20. <value>/mr-history/done</value>
  21. </property>

  22. </configuration>

(5)etc/hadoop/yarn-site.xml對yarn進行配置:

點選(此處)摺疊或開啟

  1. <configuration>

  2. <!-- Site specific YARN configuration properties -->

  3. <property>
  4. <name>Yarn.nodemanager.aux-services</name>
  5. <value>mapreduce.shuffle</value>
  6. </property>

  7. <property>
  8. <name>Yarn.resourcemanager.address</name>
  9. <value>namenode:18040</value>
  10. </property>

  11. <property>
  12. <name>Yarn.resourcemanager.scheduler.address</name>
  13. <value>namenode:18030</value>
  14. </property>

  15. <property>
  16. <name>Yarn.resourcemanager.resource-tracker.address</name>
  17. <value>namenode:18025</value>
  18. </property>

  19. <property>
  20. <name>Yarn.resourcemanager.admin.address</name>
  21. <value>namenode:18041</value>
  22. </property>

  23. <property>
  24. <name>Yarn.resourcemanager.webapp.address</name>
  25. <value>namenode:8088</value>
  26. </property>

  27. <property>
  28. <name>Yarn.nodemanager.local-dirs</name>
  29. <value>/home/zhang/hadoop-2.5.2/mynode/my</value>
  30. </property>

  31. <property>
  32. <name>Yarn.nodemanager.log-dirs</name>
  33. <value>/home/zhang/hadoop-2.5.2/mynode/logs</value>
  34. </property>

  35. <property>
  36. <name>Yarn.nodemanager.log.retain-seconds</name>
  37. <value>10800</value>
  38. </property>

  39. <property>
  40. <name>Yarn.nodemanager.remote-app-log-dir</name>
  41. <value>/logs</value>
  42. </property>

  43. <property>
  44. <name>Yarn.nodemanager.remote-app-log-dir-suffix</name>
  45. <value>logs</value>
  46. </property>

  47. <property>
  48. <name>Yarn.log-aggregation.retain-seconds</name>
  49. <value>-1</value>
  50. </property>

  51. <property>
  52. <name>Yarn.log-aggregation.retain-check-interval-seconds</name>
  53. <value>-1</value>
  54. </property>


  55. </configuration>

四.啟動測試
(1)用scp 命令將hadoop資料夾複製到所有的節點機器相同路徑上。
(2)驗證一下SSH 無密碼訪問已經沒有問題了
(3)關閉防火牆
       如果不關閉的話可能造成,無法訪問埠的問題。不關閉防火牆也可以將對應的相關埠開啟比如 namenode上:9000埠

       方法:http://blog.itpub.net/28929558/viewspace-1353996/

(4)啟動測試
格式化namdenode
    hadoop/bin/hadoop namenode -format

檢視列印資訊的倒數第三行:Storage directory ~/hadoop-2.5.2/hdfs/name has been successfully formatted
則說明成功了!

啟動 hdfs :
     sbin/start-dfs.sh
jps 檢視 namenode 上: NameNode    SecondaryNameNode
            datanode shang : DataNode

啟動 yarn :start-yarn.sh
jps 檢視 namenode 上: NameNode    SecondaryNameNode   ResourceManager
            datanode shang : DataNode    NodeManager


用 hdfs  dfsadmin -report 檢驗一下
9189 NameNode
[zhang@namenode sbin]$ hdfs dfsadmin -report
14/12/01 23:19:15 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Configured Capacity: 8177262592 (7.62 GB)
Present Capacity: 4473057280 (4.17 GB)
DFS Remaining: 4473032704 (4.17 GB)
DFS Used: 24576 (24 KB)
DFS Used%: 0.00%
Under replicated blocks: 0
Blocks with corrupt replicas: 0
Missing blocks: 0


-------------------------------------------------
Live datanodes (1):


Name: 10.0.128.124:50010 (datanode01)
Hostname: datanode01
Decommission Status : Normal
Configured Capacity: 8177262592 (7.62 GB)
DFS Used: 24576 (24 KB)
Non DFS Used: 3704205312 (3.45 GB)
DFS Remaining: 4473032704 (4.17 GB)
DFS Used%: 0.00%
DFS Remaining%: 54.70%
Configured Cache Capacity: 0 (0 B)
Cache Used: 0 (0 B)
Cache Remaining: 0 (0 B)
Cache Used%: 100.00%
Cache Remaining%: 0.00%
Xceivers: 1
Last contact: Mon Dec 01 23:19:15 PST 2014

 
測試放入資料檔案,並檢視:

[zhang@namenode sbin]$ hadoop fs -put ../../input/ /input
14/12/02 00:18:01 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable

[zhang@namenode sbin]$ hadoop fs -cat /input/test.txt
14/12/02 00:18:35 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
hello word !

驗證完畢!










 


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28929558/viewspace-1354180/,如需轉載,請註明出處,否則將追究法律責任。

相關文章