Hadoop记录-切换NN
一、第一种方法
重启namenode(1.1.1.1 1.1.1.2)
重启standby节点:1.1
hadoop-daemon.sh stop zkfc
hadoop-daemon.sh stop namenode
hadoop-daemon.sh start namenode
hadoop dfsadmin -safemode get #查看安全模式是否退出
hadoop-daemon.sh start zkfc
tail -300f /log/hadoop/hadoop-hdfs-zkfc-xxx.log #查看zkfc日志是否已注册节点返回信息(standby)
重启1.2(从1.2切换到1.1)
停止1.4的zkfc:hadoop-daemon.sh stop zkfc
查看1.1是否已自动切换为active
tail -300f /log/hadoop/hadoop-hdfs-zkfc-xxx.log #查看zkfc日志是否已注册节点返回信息(active)
如已切换,重启1.2 namenode
hadoop-damon.sh stop namenode
hadoop-damon.sh start namenode
hadoop dfsadmin -safemode get #查看安全模式是否退出
hadoop-daemon.sh start zkfc
tail -300f /log/hadoop/hadoop-hdfs-zkfc-xxx.log #查看zkfc日志是否已注册节点返回信息(standby)
从1.1切换到1.2
停止1.1的zkfc
hadoop-daemon.sh stop zkfc
查看1.2是否已自动切换为active
tail -300f /log/hadoop/hadoop-hdfs-zkfc-xxx.log #查看zkfc日志是否已注册节点返回信息(active)
hadoop dfsadmin -safemode get #查看安全模式是否退出
http://1.1.1.1:50070/dfshealth.html#tab-overview
http://1.1.1.2:50070/dfshealth.html#tab-overview
如已切换,启动1.1的zkfc
hadoop-daemon.sh start zkfc
tail -300f /log/hadoop/hadoop-hdfs-zkfc-xxx.log #查看zkfc日志是否已注册节点返回信息(standby)
################################################################
#切换ative nn
#hdfs haadmin -failover nn2 nn1
#
#把nn1置为:standby hdfs haadmin -transitionToStandby nn1
#把nn2置为:Active hdfs haadmin -transitionToActive nn2
#
#hdfs haadmin -transitionToActive nn1
#hadoop-daemon.sh stop namenode (nn2)
#hadoop-daemon.sh start namenode (nn2)
#nn2 变为standby
#
#hdfs haadmin -transitionToStandby -forcemanual nn2
#
#hdfs haadmin -failover --forcefence --forceactive nn2 nn1
#hdfs haadmin -failover --forcefence --forceactive nn1 nn2
##############################################################
二、第2种方法
1.保证standby节点和active节点的zkfc正常运行
2.停止active节点的zkfc,查看standby节点的zkfc日志是否已切换为active
3.如已切换,开启已停止的zkfc,待状态已切换,切换完成