Hadoop集群手动主备切换
查看节点状态
#查看节点状态 [root@hadoop1 bin]# hdfs haadmin -getServiceState nn1 standby [root@hadoop1 bin]# hdfs haadmin -getServiceState nn2 active [root@hadoop1 bin]# pwd /root/tools/hadoop/tools/hadoop/bin
将 NN2 切换为 Standby 备用节点
hdfs haadmin -transitionToStandby --forcemanual nn2
将 NN1 切换为 Active 备用节点
hdfs haadmin -transitionToActive --forcemanual nn1
[root@hadoop1 bin]# 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 23/04/19 17:19:02 WARN ha.HAAdmin: Proceeding with manual HA state management even though automatic failover is enabled for NameNode at hadoop2/192.168.1.202:9000 [root@hadoop1 bin]# hdfs haadmin -getServiceState nn2 standby [root@hadoop1 bin]# hdfs haadmin -transitionToActive --forcemanual nn1 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 23/04/19 17:20:35 WARN ha.HAAdmin: Proceeding with manual HA state management even though automatic failover is enabled for NameNode at hadoop2/192.168.1.202:9000 23/04/19 17:20:35 WARN ha.HAAdmin: Proceeding with manual HA state management even though automatic failover is enabled for NameNode at hadoop1/192.168.1.201:9000
切换后的状态及效果图
[root@hadoop1 bin]# hdfs haadmin -getServiceState nn2 standby [root@hadoop1 bin]# hdfs haadmin -getServiceState nn1 active
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!