Hadoop2.7實戰v1.0之HDFS HA
HDFS HA實戰v1.0
當前環境:hadoop+zookeeper(namenode,resourcemanager HA)
namenode | serviceId | Init status |
sht-sgmhadoopnn-01 | nn1 | active |
sht-sgmhadoopnn-02 | nn2 | standby |
參考: http://blog.csdn.net/u011414200/article/details/50336735
一.檢視namenode是active還是standby
1.開啟網頁
2.檢視zkfc日誌
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopnn-01 logs]# more hadoop-root-zkfc-sht-sgmhadoopnn-01.telenav.cn.log
-
-
…………………..
-
-
2016-02-28 00:24:00,692 INFO org.apache.hadoop.ha.ZKFailoverController: Trying to make NameNode at sht-sgmhadoopnn-01/172.16.101.55:8020 active...
-
-
2016-02-28 00:24:01,762 INFO org.apache.hadoop.ha.ZKFailoverController: Successfully transitioned NameNode at sht-sgmhadoopnn-01/172.16.101.55:8020 to active state
-
-
-
[root@sht-sgmhadoopnn-02 logs]# more hadoop-root-zkfc-sht-sgmhadoopnn-01.telenav.cn.log
-
-
…………………..
-
-
2016-02-28 00:24:01,186 INFO org.apache.hadoop.ha.ZKFailoverController: ZK Election indicated that NameNode at sht-sgmhadoopnn-02/172.16.101.56:8020 should become standby
-
- 2016-02-28 00:24:01,209 INFO org.apache.hadoop.ha.ZKFailoverController: Successfully transitioned NameNode at sht-sgmhadoopnn-02/172.16.101.56:8020 to standby state
3. 透過命令hdfs haadmin –getServiceState
###$HADOOP_HOME/etc/hadoop/hdfs-site.xml, dfs.ha.namenodes.[dfs.nameservices]
<!--設定NameNode IDs 此版本最大隻支援兩個NameNode -->
dfs.ha.namenodes.mycluster
nn1,nn2
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopnn-02 logs]# hdfs haadmin -getServiceState nn1
-
-
active
-
-
[root@sht-sgmhadoopnn-02 logs]# hdfs haadmin -getServiceState nn2
-
- standby
二.基本命令
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopnn-02 logs]# hdfs --help
-
-
Usage: hdfs [--config confdir] [--loglevel loglevel] COMMAND
-
-
where COMMAND is one of:
-
-
dfs run a filesystem command on the file systems supported in Hadoop.
-
-
classpath prints the classpath
-
-
namenode -format format the DFS filesystem
-
-
secondarynamenode run the DFS secondary namenode
-
-
namenode run the DFS namenode
-
-
journalnode run the DFS journalnode
-
-
zkfc run the ZK Failover Controller daemon
-
-
datanode run a DFS datanode
-
-
dfsadmin run a DFS admin client
-
-
haadmin run a DFS HA admin client
-
-
fsck run a DFS filesystem checking utility
-
-
balancer run a cluster balancing utility
-
-
jmxget get JMX exported values from NameNode or DataNode.
-
-
mover run a utility to move block replicas across
-
-
storage types
-
-
oiv apply the offline fsimage viewer to an fsimage
-
-
oiv_legacy apply the offline fsimage viewer to an legacy fsimage
-
-
oev apply the offline edits viewer to an edits file
-
-
fetchdt fetch a delegation token from the NameNode
-
-
getconf get config values from configuration
-
-
groups get the groups which users belong to
-
-
snapshotDiff diff two snapshots of a directory or diff the
-
-
current directory contents with a snapshot
-
-
lsSnapshottableDir list all snapshottable dirs owned by the current user
-
-
Use -help to see options
-
-
portmap run a portmap service
-
-
nfs3 run an NFS version 3 gateway
-
-
cacheadmin configure the HDFS cache
-
-
crypto configure HDFS encryption zones
-
-
storagepolicies list/get/set block storage policies
-
-
version print the version
-
-
###########################################################################
-
-
[root@sht-sgmhadoopnn-02 logs]# hdfs namenode --help
-
-
Usage: java NameNode [-backup] |
-
-
[-checkpoint] |
-
-
[-format [-clusterid cid ] [-force] [-nonInteractive] ] |
-
-
[-upgrade [-clusterid cid] [-renameReserved<k-v pairs>] ] |
-
-
[-upgradeOnly [-clusterid cid] [-renameReserved<k-v pairs>] ] |
-
-
[-rollback] |
-
-
[-rollingUpgrade <rollback|downgrade|started> ] |
-
-
[-finalize] |
-
-
[-importCheckpoint] |
-
-
[-initializeSharedEdits] |
-
-
[-bootstrapStandby] |
-
-
[-recover [ -force] ] |
-
-
[-metadataVersion ] ]
-
-
-
-
-
###########################################################################
-
-
[root@sht-sgmhadoopnn-02 logs]# hdfs haadmin --help
-
-
-help: Unknown command
-
-
Usage: haadmin
-
-
[-transitionToActive [--forceactive] <serviceId>]
-
-
[-transitionToStandby <serviceId>]
-
-
[-failover [--forcefence] [--forceactive] <serviceId> <serviceId>]
-
-
[-getServiceState <serviceId>]
-
-
[-checkHealth <serviceId>]
-
- [-help <command>]
failover 初始化一個故障恢復。該命令會從一個失效的NameNode切換到另一個上面(不支援在自動切換的環境操作)。
getServiceState 獲取當前NameNode的狀態。
checkHealth 檢查NameNode的狀態。正常就返回0,否則返回非0值。
三.實驗
1.測試HDFS的手工切換功能(失敗)
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopnn-01 ~]# hdfs haadmin -failover --forceactive nn1 nn2
-
- forcefence and forceactive flags not supported with auto-failover enabled.
#hdfs-site.xml 中設定dfs.ha.automatic-failover.enabled為 true,故提示不能手動切換
2.測試HDFS的自動切換功能(成功)
a.在active namenode機器上透過jps命令查詢到namenode的程式號,然後透過kill -9的方式殺掉程式,觀察另一個namenode節點是否會從狀態standby變成active狀態
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopnn-01 ~]# hdfs haadmin -getServiceState nn1
-
-
active
-
-
[root@sht-sgmhadoopnn-01 ~]# hdfs haadmin -getServiceState nn2
-
-
standby
-
-
-
-
-
[root@sht-sgmhadoopnn-01 ~]# jps
-
-
10327 ResourceManager
-
-
10162 DFSZKFailoverController
-
-
9821 NameNode
-
-
20064 Jps
-
-
[root@sht-sgmhadoopnn-01 ~]# kill -9 9821
-
-
[root@sht-sgmhadoopnn-01 ~]# jps
-
-
10327 ResourceManager
-
-
10162 DFSZKFailoverController
-
-
20121 Jps
-
-
-
-
[root@sht-sgmhadoopnn-01 ~]# hdfs haadmin -getServiceState nn1
-
-
16/02/28 22:01:37 INFO ipc.Client: Retrying connect to server: sht-sgmhadoopnn-01/172.16.101.55:8020. Already tried 0 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=1, sleepTime=1000 MILLISECONDS)
-
-
Operation failed: Call From sht-sgmhadoopnn-01.telenav.cn/172.16.101.55 to sht-sgmhadoopnn-01:8020 failed on connection exception: java.net.ConnectException: Connection refused; For more details see: http://wiki.apache.org/hadoop/ConnectionRefused
-
-
[root@sht-sgmhadoopnn-01 ~]# hdfs haadmin -getServiceState nn2
-
-
active
-
- [root@sht-sgmhadoopnn-01 ~]#
##也可以透過觀察zkfc日誌或者 來檢視是否切換成功
b.手動啟動sht-sgmhadoopnn-01的namenode
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopnn-01 ~]# cd /hadoop/hadoop-2.7.2/sbin
-
-
[root@sht-sgmhadoopnn-01 sbin]# jps
-
-
10327 ResourceManager
-
-
10162 DFSZKFailoverController
-
-
21640 Jps
-
-
[root@sht-sgmhadoopnn-01 sbin]# hadoop-daemon.sh start namenode
-
-
starting namenode, logging to /hadoop/hadoop-2.7.2/logs/hadoop-root-namenode-sht-sgmhadoopnn-01.telenav.cn.out
-
-
[root@sht-sgmhadoopnn-01 sbin]# jps
-
-
10327 ResourceManager
-
-
10162 DFSZKFailoverController
-
-
21784 Jps
-
-
21679 NameNode
-
-
[root@sht-sgmhadoopnn-01 sbin]# hdfs haadmin -getServiceState nn1
-
-
standby
-
- [root@sht-sgmhadoopnn-01 sbin]#
#### sht-sgmhadoopnn-01 機器上namenode 程式已經起來,且狀態為standby
c. 再次切換
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopnn-01 sbin]# hdfs haadmin -transitionToStandby nn2
-
-
Automatic failover is enabled for NameNode at sht-sgmhadoopnn-02/172.16.101.56:8020
-
-
Refusing to manually manage HA state, since it may cause
-
-
a split-brain scenario or other incorrect state.
-
-
If you are very sure you know what you are doing, please
-
-
specify the --forcemanual flag.
-
-
-
[root@sht-sgmhadoopnn-01 sbin]# hdfs haadmin -transitionToStandby --forcemanual nn2
-
-
You have specified the --forcemanual flag. This flag is dangerous, as it can induce a split-brain scenario that WILL CORRUPT your HDFS namespace, possibly irrecoverably.
-
-
It is recommended not to use this flag, but instead to shut down the cluster and disable automatic failover if you prefer to manually manage your HA state.
-
-
You may abort safely by answering 'n' or hitting ^C now.
-
-
Are you sure you want to continue? (Y or N) Y
-
-
16/02/28 22:30:22 WARN ha.HAAdmin: Proceeding with manual HA state management even though
-
-
automatic failover is enabled for NameNode at sht-sgmhadoopnn-02/172.16.101.56:8020
-
-
-
-
[root@sht-sgmhadoopnn-01 sbin]# hdfs haadmin -getServiceState nn1
-
-
active
-
-
[root@sht-sgmhadoopnn-01 sbin]# hdfs haadmin -getServiceState nn2
-
-
standby
-
- [root@sht-sgmhadoopnn-01 sbin]#
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30089851/viewspace-2047907/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Hadoop2.7實戰v1.0之YARN HAHadoopYarn
- Hadoop2.7實戰v1.0之HBase1.1.5 HA分散式搭建Hadoop分散式
- Hadoop2.7實戰v1.0之start-balancer.sh與hdfs balancer資料均衡Hadoop
- Hadoop2.7實戰v1.0之Flume1.6.0搭建(Http Source-->Memory Chanel --> Hdfs Sink)HadoopHTTP
- Hadoop2.7實戰v1.0之JVM引數調優HadoopJVM
- Hadoop2.7實戰v1.0之Linux引數調優HadoopLinux
- Hadoop2.7實戰v1.0之Hive-2.0.0+MySQL本地模式安裝HadoopHiveMySql模式
- Hadoop2.7實戰v1.0之Hive-2.0.0+MySQL遠端模式安裝HadoopHiveMySql模式
- Hadoop2.7實戰v1.0之Eclipse+Hive2.0.0的JDBC案例(最詳細搭建)HadoopEclipseHiveJDBC
- Hadoop2.7實戰v1.0之動態刪除DataNode(含NodeManager)節點(修改dfs.replication)Hadoop
- Hadoop2.7實戰v1.0之動態新增、刪除DataNode節點及複製策略導向Hadoop
- Hadoop2.7實戰v1.0之新增DataNode節點後,更改檔案複製策略dfs.replicationHadoop
- HDFS HA 配置學習
- hadoop 2.0 hdfs HA 搭建Hadoop
- Hadoop2.7實戰v1.0之Hive-2.0.0的Hiveserver2服務和beeline遠端除錯HadoopHiveServer除錯
- 大資料謝列3:Hdfs的HA實現大資料
- HDFS HA 高可用機制詳解
- HDFS High Availability(HA)高可用配置AI
- 03【線上日誌分析】之hadoop-2.7.3編譯和搭建叢集環境(HDFS HA,Yarn HA)Hadoop編譯Yarn
- 【實驗】Hadoop-2.7.2+zookeeper-3.4.6完全分散式環境搭建(HDFS、YARN HA)Hadoop分散式Yarn
- hadoop實戰4--(hdfs讀流程,hdfs寫流程,副本放置策略)Hadoop
- Hadoop2.x運維實戰之入門手冊v1.0Hadoop運維
- Hadoop大資料實戰系列文章之HDFS檔案系統Hadoop大資料
- 小白學習大資料測試之hadoop hdfs和MapReduce小實戰大資料Hadoop
- 實戰生產環境vCenter HA配置(VCSA6.5)
- HDFS系列之DataNode磁碟管理解析及實踐!
- ORACLE之常用FAQ V1.0Oracle
- HDFS 07 - HDFS 效能調優之 合併小檔案
- Hadoop面試題之HDFSHadoop面試題
- Hadoop原理之——HDFS原理Hadoop
- HDFS 重要機制之 checkpoint
- 分散式檔案系統HDFS,大資料儲存實戰(一)分散式大資料
- Storm實戰之WordCountORM
- Storm實戰之TopNORM
- 大資料專案實踐(一)——之HDFS叢集配置大資料
- java專案實戰(1)—基礎——超市購物管理系統V1.0Java
- Hadoop2之NameNode HA詳解Hadoop
- 4.7 Hadoop+zookeeper實現HAHadoop