Hadoop HA namenode 活动节点迁移

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

haadmin

Usage:

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

COMMAND_OPTIONDescription
-checkHealthcheck the health of the given NameNode
-failoverinitiate a failover between two NameNodes
-getServiceStatedetermine whether the given NameNode is Active or Standby
-transitionToActivetransition the state of the given NameNode to Active (Warning: No fencing is done)
-transitionToStandbytransition 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 <nameserviceId>] [-transitionToActive [--forceactive] <serviceId>]

说明:
可以看到, 实际执行下来后, 节点并未切换到 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, 实际场景中, 这并没有意义.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值