1. 程式人生 > >3.4 HDFS叢集模式

3.4 HDFS叢集模式

第3章 HDFS:分散式檔案系統

3.4 HDFS叢集模式

節點 IP 角色
node1 192.168.80.131 NameNode,DataNode
node2 192.168.80.132 SecondaryNameNode,DataNode
node3 192.168.80.133 DataNode

3.4.1 Hadoop環境變數

[root@node1 ~]# vi /etc/profile.d/custom.sh
      
  • 1
  • 1

      
  1. #Hadoop path
  2. export HADOOP_HOME=/opt/hadoop- 2.7. 3
  3. export PATH= $PATH: $HADOOP_HOME/bin: $HADOOP_HOME/sbin
  • 1
  • 2
  • 3
  • 這裡寫圖片描述
[root@node1 ~]# source /etc/profile.d/custom.sh
      
  • 1

【2018-01-27補充】 
感謝吳家行hang的提醒,這裡node2和node3也要進行類似的環境變數配置。

3.4.2 準備工作

由於前面在node1上部署了Hadoop單機模式,需要停止Hadoop所有服務並清除資料目錄。順便檢驗一下設定的Hadoop環境變數。

這裡寫圖片描述

清除Hadoop資料目錄

[root@node1 ~]# rm -rf /tmp/hadoop-root/
      
  • 1

3.4.2 core-site.xml


      
  1. [root @node1 ~] # cd /opt/hadoop-2.7.3/etc/hadoop/
  2. [root @node1 hadoop] # vi core-site.xml
  • 1
  • 2

core-site.xml檔案內容如下:


      
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
  3. <configuration>
  4. <property>
  5. <name>fs.defaultFS </name>
  6. <value>hdfs://node1:9000 </value>
  7. </property>
  8. <property>
  9. <name>hadoop.tmp.dir </name>
  10. <value>/var/data/hadoop </value>
  11. </property>
  12. <property>
  13. <name>io.file.buffer.size </name>
  14. <value>65536 </value>
  15. </property>
  16. </configuration>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

3.4.3 hdfs-site.xml

[root@node1 hadoop]# vi hdfs-site.xml
      
  • 1

hdfs-site.xml檔案內容如下:


      
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
  3. <configuration>
  4. <property>
  5. <name>dfs.replication </name>
  6. <value>3 </value>
  7. </property>
  8. <property>
  9. <name>dfs.namenode.secondary.http-address </name>
  10. <value>node2:50090 </value>
  11. </property>
  12. <property>
  13. <name>dfs.namenode.secondary.https-address </name>
  14. <value>node2:50091 </value>
  15. </property>
  16. </configuration>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

3.4.4 slaves

編輯slaves檔案

[root@node1 hadoop]# vi slaves
      
  • 1

slaves檔案內容設定為:


      
  1. node1
  2. node2
  3. node3
  • 1
  • 2
  • 3

這裡寫圖片描述

3.4.5 分發檔案

將Hadoop軟體包複製到node2和node3節點上

[root@node1 ~]# scp -r /opt/hadoop-2.7.3/ node2:/opt
      
  • 1
[root@node1 ~]# scp -r /opt/hadoop-2.7.3/ node3:/opt
      
  • 1

將環境變數檔案複製到node2和node3節點上

[root@node1 ~]# scp /etc/profile.d/custom.sh node2:/etc/profile.d
      
  • 1
[root@node1 ~]# scp /etc/profile.d/custom.sh node3:/etc/profile.d
      
  • 1

最後source一下

[root@node2 ~]# source /etc/profile.d/custom.sh
      
  • 1
[root@node3 ~]# source /etc/profile.d/custom.sh
      
  • 1

3.4.6 NameNode格式化

[root@node1 ~]# hdfs namenode -format
      
  • 1

      
  1. ************************************************************/
  2. 17/ 05/ 14 09: 17: 28 INFO namenode .NameNode: registered UNIX signal handlers for [ TERM, HUP, INT]
  3. 17/ 05/ 14 09: 17: 28 INFO namenode .NameNode: createNameNode [-format]
  4. Formatting using clusterid: CID- 29bae3d3- 1786- 4428- 8359- 077976fe15e5
  5. 17/ 05/ 14 09: 17: 30 INFO namenode .FSNamesystem: No KeyProvider found.
  6. 17/ 05/ 14 09: 17: 30 INFO namenode .FSNamesystem: fsLock is fair: true
  7. 17/ 05/ 14 09: 17: 30 INFO blockmanagement .DatanodeManager: dfs .block .invalidate .limit= 1000
  8. 17/ 05/ 14 09: 17: 30 INFO blockmanagement .DatanodeManager: dfs .namenode .datanode .registration .ip-hostname-check= true
  9. 17/ 05/ 14 09: 17: 30 INFO blockmanagement .BlockManager: dfs .namenode .startup .delay .block .deletion .sec is set to 000: 00: 00: 00.000
  10. 17/ 05/ 14 09: 17: 30 INFO blockmanagement .BlockManager: The block deletion will start around 2017 May 14 09: 17: 30
  11. 17/ 05/ 14 09: 17: 30 INFO util .GSet: Computing capacity for map BlocksMap
  12. 17/ 05/ 14 09: 17: 30 INFO util .GSet: VM type = 64-bit
  13. 17/ 05/ 14 09: 17: 30 INFO util .GSet: 2.0% max memory 966.7 MB = 19.3 MB
  14. 17/ 05/ 14 09: 17: 30 INFO util .GSet: capacity = 2^ 21 = 2097152 entries
  15. 17/ 05/ 14 09: 17: 30 INFO blockmanagement .BlockManager: dfs .block .access .token .enable= false
  16. 17/ 05/ 14 09: 17: 30 INFO blockmanagement .BlockManager: defaultReplication = 3
  17. 17/ 05/ 14 09: 17: 30 INFO blockmanagement .BlockManager: maxReplication = 512
  18. 17/ 05/ 14 09: 17: 30 INFO blockmanagement .BlockManager: minReplication = 1
  19. 17/ 05/ 14 09: 17: 30 INFO blockmanagement .BlockManager: maxReplicationStreams = 2
  20. 17/ 05/ 14 09: 17: 30 INFO blockmanagement .BlockManager: replicationRecheckInterval = 3000
  21. 17/ 05/ 14 09: 17: 30 INFO blockmanagement .BlockManager: encryptDataTransfer = false
  22. 17/ 05/ 14 09: 17: 30 INFO blockmanagement .BlockManager: maxNumBlocksToLog = 1000
  23. 17/ 05/ 14 09: 17: 30 INFO namenode .FSNamesystem: fsOwner = root (auth: SIMPLE)
  24. 17/ 05/ 14 09: 17: 30 INFO namenode .FSNamesystem: supergroup = supergroup
  25. 17/ 05/ 14 09: 17: 30 INFO namenode .FSNamesystem: isPermissionEnabled = true
  26. 17/ 05/ 14 09: 17: 30 INFO namenode .FSNamesystem: HA Enabled: false
  27. 17/ 05/ 14 09: 17: 30 INFO namenode .FSNamesystem: Append Enabled: true
  28. 17/ 05/ 14 09: 17: 31 INFO util .GSet: Computing capacity for map INodeMap
  29. 17/ 05/ 14 09: 17: 31 INFO util .GSet: VM type = 64-bit
  30. 17/ 05/ 14 09: 17: 31 INFO util .GSet: 1.0% max memory 966.7 MB = 9.7 MB
  31. 17/ 05/ 14 09: 17: 31 INFO util .GSet: capacity = 2^ 20 = 1048576 entries
  32. 17/ 05/ 14 09: 17: 31 INFO namenode .FSDirectory: ACLs enabled? false
  33. 17/ 05/ 14 09: 17: 31 INFO namenode .FSDirectory: XAttrs enabled? true
  34. 17/ 05/ 14 09: 17: 31 INFO namenode .FSDirectory: Maximum size of an xattr: 16384
  35. 17/ 05/ 14 09: 17: 31 INFO namenode .NameNode: Caching file names occuring more than 10 times
  36. 17/ 05/ 14 09: 17: 31 INFO util .GSet: Computing capacity for map cachedBlocks