Hadoop HA namenode 活动节点迁移

目录

  • 一. 官网关于 "活动节点迁移" 的介绍
  • 二. 获取 namenode 角色状态
  • 三. namenode active节点角色切换

一. 官网关于 “活动节点迁移” 的介绍

haadmin

Usage:

hdfs haadmin -checkHealth
hdfs haadmin -failover [–forcefence] [–forceactive]
hdfs haadmin -getServiceState
hdfs haadmin -help
hdfs haadmin -transitionToActive [–forceactive]
hdfs haadmin -transitionToStandby

COMMAND_OPTION Description
-checkHealth check the health of the given NameNode
-failover initiate a failover between two NameNodes
-getServiceState determine whether the given NameNode is Active or Standby
-transitionToActive transition the state of the given NameNode to Active (Warning: No fencing is done)
-transitionToStandby transition the state of the given NameNode to Standby (Warning: No fencing is done)

二. 获取 namenode 角色状态

[root@server254-20-22-11 cloudera]# hdfs haadmin -getServiceState ‘namenode81’
active
[root@server254-20-22-11 cloudera]# hdfs haadmin -getServiceState ‘namenode61’
standby

三. namenode active节点角色切换

默认进行"活动节点迁移"时, 会因为可能产生脑裂场景或其他不正确的状态, 而导致操作被"拒绝"
CDH6上默认执行"hdfs haadmin"的角色为yarn, 因为默认cdh6构建的hdfs用户是nologin用户(cat /etc/passwd | grep hdfs), 如下:
hdfs:x:993:990:Hadoop HDFS:/var/lib/hadoop-hdfs:/sbin/nologin
故首先,需将当前hadoop默认用户设置为hdfs用户,才能执行如下命令:

[root@server254-20-22-11 cloudera]# export HADOOP_USER_NAME=hdfs
[root@server254-20-22-11 cloudera]# hdfs haadmin -transitionToActive namenode61
Automatic failover is enabled for NameNode at server254-20-22-12/254.20.22.12:8022
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.

可以添加--forcemanual 来规避默认的拒绝策略.

[root@server254-20-22-11 cloudera]# export HADOOP_USER_NAME=hdfs
[root@server254-20-22-11 cloudera]# hdfs haadmin -ns nameservice1 -transitionToActive --forcemanual namenode61

[root@server254-20-22-11 cloudera]# hdfs haadmin -ns nameservice1 -transitionToActive --forcemanual namenode61

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
20/06/17 11:44:24 WARN ha.HAAdmin: Proceeding with manual HA state management even though
automatic failover is enabled for NameNode at server254-20-22-12/254.20.22.12:8022
transitionToActive: Node namenode81 is already active
Usage: haadmin [-ns ] [-transitionToActive [--forceactive] ]

说明:
可以看到, 实际执行下来后, 节点并未切换到 namenode61 节点(即 server254-20-22-11).
不知道社区版hadoop ha环境下执行这条语句是否可以达到目标, 有这样环境的小伙伴可以把试验结果分享一下.

[root@server254-20-22-11 cloudera]# hdfs haadmin -ns nameservice1 -transitionToActive --forcemanual namenode81

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
20/06/17 11:45:09 WARN ha.HAAdmin: Proceeding with manual HA state management even though
automatic failover is enabled for NameNode at server254-20-22-11/254.20.22.11:8022
20/06/17 11:45:09 WARN ha.HAAdmin: Proceeding with manual HA state management even though
automatic failover is enabled for NameNode at server254-20-22-12/254.20.22.12:8022

说明:
实际的active节点即为 namenode81, 这条语句还是将active节点切换至 namenode81, 实际场景中, 这并没有意义.

你可能感兴趣的:(hadoop)