判断namenode active

 

hdfs判断active节点

 

在hdfs文件系统里新建/tmp/_success文件,写入内容active

ifactive=`hadoop fs -cat hdfs://172.20.85.29/tmp/_success`
echo $ifactive
if [[ $ifactive =~ "active" ]]; then
nameservice=172.20.85.29
else
nameservice=172.20.85.39
fi
echo $nameservice

 

另外一个方法:

 

ifactive=`sudo -u hdfs hdfs haadmin -getServiceState namenode320`
echo $ifactive

if [[ $ifactive =~ "active" ]]; then

nameservice=10.30.18.10
else
nameservice=10.30.18.11
fi

echo $nameservice

 

sudo -u hdfs hdfs haadmin -getServiceState namenode320

sudo -u hdfs hdfs haadmin -getServiceState namenode321

 

namenode320是随机生成的

 

http://nn2:50070/dfshealth.html 查看

 

image

 

 

指定固定的id

在namenode1高级配置里添加

<property>
<name>dfs.ha.namenode.id</name>
<value>nn1</value>
</property>
在namenode2高级配置里添加

<property>
<name>dfs.ha.namenode.id</name>
<value>nn2</value>
</property>

您可以选择一种方式赞助本站

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

图片 表情