一、启动HDFS-HA集群
### --- 在各个JournalNode节点上,
~~~     输入以下命令启动journalnode服务(去往HA安装目录不要使用环境变量中命令)

[root@linux121 ~]# /opt/yanqi/servers/ha/hadoop-2.9.2/sbin/hadoop-daemon.sh start journalnode
[root@linux122 ~]# /opt/yanqi/servers/ha/hadoop-2.9.2/sbin/hadoop-daemon.sh start journalnode
[root@linux123 ~]# /opt/yanqi/servers/ha/hadoop-2.9.2/sbin/hadoop-daemon.sh start journalnode
 
[root@linuxlocalhost ~]# jps
11136 QuorumPeerMain
11360 JournalNode
### --- 在[nn1]上,对其进行格式化,并启动
~~~     # nn1是linux121

[root@linux121 ~]# /opt/yanqi/servers/ha/hadoop-2.9.2/bin/hdfs namenode -format
INFO namenode.FSImage: Allocated new BlockPoolId: BP-1469635148-192.168.1.121-1630487745461
INFO common.Storage: Storage directory /opt/yanqi/servers/ha/hadoop-2.9.2/data/tmp/dfs/name has been successfully formatted.
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at linux121/192.168.1.121
************************************************************/
 
[root@linux121 ~]# /opt/yanqi/servers/ha/hadoop-2.9.2/sbin/hadoop-daemon.sh start namenode

[root@linux121 ~]# jps
11136 QuorumPeerMain
11360 JournalNode
11491 NameNode
### --- 在[nn2]上,同步nn1的元数据信息
~~~     # nn2是linux2

[root@linux122 ~]# /opt/yanqi/servers/ha/hadoop-2.9.2/bin/hdfs namenode -bootstrapStandby
=====================================================
About to bootstrap Standby ID nn2 from:
           Nameservice ID: yanqicluster
        Other Namenode ID: nn1
  Other NN's HTTP address: http://linux121:50070
  Other NN's IPC  address: linux121/192.168.1.121:9000
             Namespace ID: 1066045453
            Block pool ID: BP-1469635148-192.168.1.121-1630487745461
               Cluster ID: CID-52d8d137-05f6-49d3-a9b2-75d944bbb62c
           Layout version: -63
       isUpgradeFinalized: true
=====================================================
INFO common.Storage: Storage directory /opt/yanqi/servers/ha/hadoop-2.9.2/data/tmp/dfs/name has been successfully formatted.
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at linux122/192.168.1.122
************************************************************/
### --- 在[nn1]上初始化zkfc

[root@linux121 ~]# /opt/yanqi/servers/ha/hadoop-2.9.2/bin/hdfs zkfc -formatZK
/************************************************************
SHUTDOWN_MSG: Shutting down DFSZKFailoverController at linux121/192.168.1.121
************************************************************/
### --- 在[nn1]上,启动集群

[root@linux121 ~]# /opt/yanqi/servers/ha/hadoop-2.9.2/sbin/start-dfs.sh
Starting namenodes on [linux121 linux122]
linux122: starting namenode, logging to /opt/yanqi/servers/ha/hadoop-2.9.2/logs/hadoop-root-namenode-linux122.out
linux121: namenode running as process 11491. Stop it first.
linux123: starting datanode, logging to /opt/yanqi/servers/ha/hadoop-2.9.2/logs/hadoop-root-datanode-linux123.out
linux121: starting datanode, logging to /opt/yanqi/servers/ha/hadoop-2.9.2/logs/hadoop-root-datanode-linux121.out
linux122: starting datanode, logging to /opt/yanqi/servers/ha/hadoop-2.9.2/logs/hadoop-root-datanode-linux122.out
Starting journal nodes [linux121 linux122 linux123]
linux122: journalnode running as process 9544. Stop it first.
linux121: journalnode running as process 11360. Stop it first.
linux123: journalnode running as process 11711. Stop it first.
Starting ZK Failover Controllers on NN hosts [linux121 linux122]
linux122: starting zkfc, logging to /opt/yanqi/servers/ha/hadoop-2.9.2/logs/hadoop-root-zkfc-linux122.out
linux121: starting zkfc, logging to /opt/yanqi/servers/ha/hadoop-2.9.2/logs/hadoop-root-zkfc-linux121.out
### --- 查看进程

[root@linux121 ~]# jps
11136 QuorumPeerMain
11360 JournalNode
11491 NameNode
11806 DataNode
12095 DFSZKFailoverController

[root@linux122 ~]# jps
9905 DFSZKFailoverController
9683 NameNode
9747 DataNode
9544 JournalNode
9342 QuorumPeerMain

[root@linux123 ~]# jps
11522 QuorumPeerMain
11798 DataNode
11711 JournalNode
二、验证HDFS集群
### --- 验证HDFS集群

~~~     访问:http://linux121:50070/dfshealth.html#tab-overview
### --- 访问:http://linux122:50070/dfshealth.html#tab-overview

~~~     可以看到linux122上显示为active:是为主;linux121上显示是standby:是为备
### --- 把linux122上的NameNode进程kill掉,验证linux121的hdfs是否会接受服务
~~~     # 将linux122:Active NameNode进程kill
~~~     # kill -9 namenode的进程id

[root@linux122 ~]# jps
9683 NameNode
[root@linux122 ~]# kill -9 9683
### --- 访问http://linux121:50070/dfshealth.html#tab-overview;

~~~     编程active已接管服务,自动升级为主节点

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm’d both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 
版权声明:本文为yanqi_vip原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/yanqivip/p/16117290.html