0
点赞
收藏
分享

微信扫一扫

0479-如何禁用HDP2.6.5的HDFS HA

M4Y 2022-09-08 阅读 50

温馨提示:如果使用电脑查看图片不清晰,可以使用手机打开文章单击文中的图片放大查看高清原图。


Fayson的github:

​​https://github.com/fayson/cdhproject​​


提示:代码块部分可以左右滑动查看噢


1

文档编写目的


Fayson为了方便接下来从HDP迁移到CDH的工作,这里先补充一篇如何禁用HDP的HDFS的HA,从HDP原地迁移到CDH,如果你的原HDP集群有HA的话,为了因为Zookeeper,JournalNode配置带来的不适应,先取消HA会更保险一些。这里还是要吐槽一下HDP的HDFS HA功能,使用Ambari可以界面化的启用HA,但是要禁用会非常非常麻烦,需要手动做很多个步骤才能最终取消成功。Cloudera Manager还是要方便很多,这一块可以参考Fayson之前的文章《​​如何使用Cloudera Manager启用HDFS的HA​​》和《​​如何使用Cloudera Manager禁用HDFS HA​​》。本文Fayson主要是介绍如何手动禁用HDP的HDFS的HA。前置条件当然是你使用Ambari开启了HDFS的HA了,如何开启Fayson在本文就不会再做描述了。


  • 内容概述

1.测试环境说明

2.禁用HDFS的HA

3.组件服务验证

4.总结


  • 测试环境

1.HDP2.6.5

2.Ambari2.6.2.2

3.集群已启用HDFS HA

4.Redhat7.4

5.集群未启用Kerberos

6.采用root用户操作


2

测试环境说明


1.首先Fayson已经预先在4台机器预先安装好了HDP,安装了一些常见服务,HDFS已经启用了HA,并且在HDFS,Hive表和HBase中都导入了数据。


0479-如何禁用HDP2.6.5的HDFS HA_zookeeper


2.集群主要角色划分如下,因为禁用HDFS的HA主要跟Ambari和HDFS服务相关,所以其他角色不做介绍。


主机名

IP地址

角色

ip-172-31-1-163.ap-southeast-1.compute.internal

172.31.1.163

Active  NameNode,ZooKeeper,DataNode,ZKFC,JournalNode

ip-172-31-12-114.ap-southeast-1.compute.internal

172.31.12.114

ZooKeeper,DataNode,JournalNode

ip-172-31-13-13.ap-southeast-1.compute.internal

172.31.13.13

ZooKeeper,DataNode

ip-172-31-4-109.ap-southeast-1.compute.internal

172.31.4.109

ZKFC,Standby  NameNode,JournalNode


3.Ambari Server安装在172.31.4.109节点上,账号密码是默认的admin/admin,端口是默认的8080,禁用HA以后NameNode将会在172.31.4.109节点,使用172.31.12.114节点作为Secondary NameNode,2个ZKFC和3个JournalNode角色都将会删除。


3

禁用HDFS的HA

3.1

停止HBase服务


1.这一步官网单独拎出来,估计主要因为担心HBase还有数据写入,而HBase的数据又是保存在HDFS上的,会影响后面的HDFS保存元数据的检查点。

2.操作比较简单,直接在Ambari页面上进行操作。


0479-如何禁用HDP2.6.5的HDFS HA_hdfs_02

0479-如何禁用HDP2.6.5的HDFS HA_hdfs_03

0479-如何禁用HDP2.6.5的HDFS HA_ambari_04


3.2

保存Active NameNode的检查点


为了阻断HDFS的写入,这里先将HDFS进入安全模式,并持久化保存HDFS元数据。


1.确认集群的Active NameNode节点


0479-如何禁用HDP2.6.5的HDFS HA_zookeeper_05


2.在集群的Active NameNode上执行以下命令:


sudo -u hdfs hdfs dfsadmin -safemode enter 
sudo -u hdfs hdfs dfsadmin -saveNamespace


0479-如何禁用HDP2.6.5的HDFS HA_ambari_06


3.3

停止集群所有服务


0479-如何禁用HDP2.6.5的HDFS HA_hdfs_07

0479-如何禁用HDP2.6.5的HDFS HA_ambari_08

0479-如何禁用HDP2.6.5的HDFS HA_hdfs_09


3.4

确认HBase的HDFS数据目录配置


1.在Ambari节点上执行以下命令


/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=get --host=localhost --cluster=Cluster1 --config-type=hbase-site


注意以上参数需要替换为集群的实际名称,包括user,password,port,cluster等,Fayson的HDP集群名称为Cluster1,注意本文Fayson这里只做一次说明,后面的所有命令将不在注释。


0479-如何禁用HDP2.6.5的HDFS HA_hdfs_10


2.主要是确认hbase.rootdir的配置,如上图所示,如果你跟Fayson的集群情况一样不是绝对路径而是/apps/hbase/data,则跳过这步,不用做操作。否则你需要做如下操作:


"hbase.rootdir":"hdfs://<name-service-id>:8020/apps/hbase/data"


修改为


"hbase.rootdir":"hdfs://<nn01.mycompany.com>:8020/apps/hbase/data"


3.5

删除ZKFC


1.在Ambari节点上执行一下命令确认ZKFC的两个节点


curl -u admin:admin -H "X-Requested-By: ambari" -i http://localhost:8080/api/v1/clusters/Cluster1/host_components?HostRoles/component_name=ZKFC


0479-如何禁用HDP2.6.5的HDFS HA_ambari_11


2.删除这2个节点的ZKFC角色


curl -u admin:admin -H "X-Requested-By: ambari" -i -X DELETE http://localhost:8080/api/v1/clusters/Cluster1/hosts/ip-172-31-1-163.ap-southeast-1.compute.internal/host_components/ZKFC 

curl -u admin:admin -H "X-Requested-By: ambari" -i -X DELETE http://localhost:8080/api/v1/clusters/Cluster1/hosts/ip-172-31-4-109.ap-southeast-1.compute.internal/host_components/ZKFC


0479-如何禁用HDP2.6.5的HDFS HA_zookeeper_12


3.再次确认已经删除成功,就是执行第一步的命令


curl -u admin:admin -H "X-Requested-By: ambari" -i http://localhost:8080/api/v1/clusters/Cluster1/host_components?HostRoles/component_name=ZKFC


0479-如何禁用HDP2.6.5的HDFS HA_zookeeper_13

“items”为空表明删除成功


3.6

修改HDFS配置


主要是删除hdfs-site.xml和core-site.xml里跟HA配置相关的操作,这一个步骤是操作内容最多也最复杂的,如果不仔细容易少删或者多删配置项而最终导致HA禁用不成功。


1.首先是在Ambari节点上执行以下命令检查hdfs-site.xml的配置项


/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=get --host=localhost --cluster=Cluster1 --config-type=hdfs-site


0479-如何禁用HDP2.6.5的HDFS HA_zookeeper_14

0479-如何禁用HDP2.6.5的HDFS HA_hdfs_15


2.执行以下命令删除HA相关的配置


/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.nameservices
/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.internal.nameservices
/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.client.failover.proxy.provider.nameservice1
/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.ha.namenodes.nameservice1
/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.ha.fencing.methods
/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.ha.automatic-failover.enabled
/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.namenode.http-address.nameservice1.nn1
/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.namenode.http-address.nameservice1.nn2
/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.namenode.https-address.nameservice1.nn1
/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.namenode.https-address.nameservice1.nn2
/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.namenode.rpc-address.nameservice1.nn1
/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.namenode.rpc-address.nameservice1.nn2
/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.namenode.shared.edits.dir
/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.journalnode.edits.dir
/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.journalnode.http-address
/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.journalnode.https-address
/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.journalnode.kerberos.internal.spnego.principal
/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.journalnode.kerberos.principal
/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.journalnode.keytab.file


注意nameservice1需要根据实际情况进行替换。


0479-如何禁用HDP2.6.5的HDFS HA_ambari_16


这里理论应该将这些参数与第一步的打印结果进行比较,对于存在的则删除,具体的参数官网有列出来,参考:


https://docs.hortonworks.com/HDPDocuments/Ambari-2.6.2.2/bk_ambari-operations/content/modify_hdfs_configurations.html


为了方便比较,可以写一个脚本进行校验,这里时间关系Fayson没有再准备。


3.注意HDP官网的配置项少列了两个,如果不删除,后面依旧会导致HDFS服务无法正常启动,如下


/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.namenode.https-address.nameservice1.nn1
/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.namenode.https-address.nameservice1.nn2


4.另外还要增加以下配置,单个NameNode的http地址,这也是官方没有说明的。


/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=set --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.namenode.http-address -v "ip-172-31-4-109.ap-southeast-1.compute.internal:50070"

/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=set --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.namenode.https-address -v "ip-172-31-4-109.ap-southeast-1.compute.internal:50470"


0479-如何禁用HDP2.6.5的HDFS HA_hdfs_17


5.再次检查hdfs-site.xml的配置


/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=get --host=localhost --cluster=Cluster1 --config-type=hdfs-site


0479-如何禁用HDP2.6.5的HDFS HA_hdfs_18


请确认所有HA相关的配置项都已经删除。


6.通过以下命令检查core-site.xml文件的配置。


/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=get --host=localhost --cluster=Cluster1 --config-type=core-site


0479-如何禁用HDP2.6.5的HDFS HA_zookeeper_19


7.删除配置项ha.zookeeper.quorum


/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=delete --host=localhost --cluster=Cluster1 --config-type=core-site -k ha.zookeeper.quorum


0479-如何禁用HDP2.6.5的HDFS HA_ambari_20


8.重新设置参数fs.defaultFS


/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=set --host=localhost --cluster=Cluster1 --config-type=core-site -k fs.defaultFS -v hdfs://ip-172-31-4-109.ap-southeast-1.compute.internal


0479-如何禁用HDP2.6.5的HDFS HA_hdfs_21


9.检查ha.zookeeper.quorum删除成功,fs.defaultFS重新配置成功


/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=get --host=localhost --cluster=Cluster1 --config-type=core-sitere-site -k fs.defaultFS -v hdfs://ip-172-31-4-109.ap-southeast-1.compute.internal


0479-如何禁用HDP2.6.5的HDFS HA_zookeeper_22


3.7

重新创建Secondary NameNode


1.首先确认集群里没有Secondary NameNode角色


curl -u admin:admin -H "X-Requested-By: ambari" -i -X GET http://localhost:8080/api/v1/clusters/Cluster1/host_components?HostRoles/component_name=SECONDARY_NAMENODE


0479-如何禁用HDP2.6.5的HDFS HA_zookeeper_23

“items”为空符合预期


2.创建Secondary NameNode角色


curl -u admin:admin -H "X-Requested-By: ambari" -i -X POST -d '{"host_components" : [{"HostRoles":{"component_name":"SECONDARY_NAMENODE"}}] }' http://localhost:8080/api/v1/clusters/Cluster1/hosts?Hosts/host_name=ip-172-31-12-114.ap-southeast-1.compute.internal


0479-如何禁用HDP2.6.5的HDFS HA_hdfs_24


3.检查角色创建成功


curl -u admin:admin -H "X-Requested-By: ambari" -i -X GET http://localhost:8080/api/v1/clusters/Cluster1/host_components?HostRoles/component_name=SECONDARY_NAMENODE


0479-如何禁用HDP2.6.5的HDFS HA_zookeeper_25


3.8

重新启用Secondary NameNode


1.重新启用Secondary NameNode


curl -u admin:admin -H "X-Requested-By: ambari" -i -X PUT -d '{"RequestInfo":{"context":"Enable Secondary NameNode"},"Body":{"HostRoles":{"state":"INSTALLED"}}}' http://localhost:8080/api/v1/clusters/Cluster1/hosts/ip-172-31-12-114.ap-southeast-1.compute.internal/host_components/SECONDARY_NAMENODE


0479-如何禁用HDP2.6.5的HDFS HA_hdfs_26


这里需要注意,如果执行命令后返回200,则直接跳过一下步骤到下一个步骤删除JournalNode角色,如果返回202,则等待几分钟后执行以下命令。


2.Fayson这里的环境返回的是202,等待几分钟后再次执行以下命令


curl -u admin:admin -H "X-Requested-By: ambari" -i -X GET "http://localhost:8080/api/v1/clusters/Cluster1/host_components?HostRoles/component_name=SECONDARY_NAMENODE&fields=HostRoles/state"


0479-如何禁用HDP2.6.5的HDFS HA_zookeeper_27


如果"state": "INSTALLED"不是INSTALLED,则继续等待然后重复执行。

3.为Secondary NameNode角色添加http端口配置


/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=set --host=localhost --cluster=Cluster1 --config-type=hdfs-site -k dfs.namenode.secondary.http-address -v "ip-172-31-12-114.ap-southeast-1.compute.internal:50090"

注意:该步骤是官网文档里不包含的,如果不重新set这个参数,则HDFS回头启动时,Secondary NameNode角色会报异常。


4.检查配置增加成功


/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=get --host=localhost --cluster=Cluster1 --config-type=hdfs-site


0479-如何禁用HDP2.6.5的HDFS HA_ambari_28


3.9

删除三个JournalNode


1.首先确认三个JournalNode在哪3个主机


curl -u admin:admin -H "X-Requested-By: ambari" -i http://localhost:8080/api/v1/clusters/Cluster1/host_components?HostRoles/component_name=JOURNALNODE


0479-如何禁用HDP2.6.5的HDFS HA_ambari_29


2.删除这3个节点上的JournalNode角色


curl -u admin:admin -H "X-Requested-By: ambari" -i -X DELETE http://localhost:8080/api/v1/clusters/Cluster1/hosts/ip-172-31-1-163.ap-southeast-1.compute.internal/host_components/JOURNALNODE
curl -u admin:admin -H "X-Requested-By: ambari" -i -X DELETE http://localhost:8080/api/v1/clusters/Cluster1/hosts/ip-172-31-12-114.ap-southeast-1.compute.internal/host_components/JOURNALNODE
curl -u admin:admin -H "X-Requested-By: ambari" -i -X DELETE http://localhost:8080/api/v1/clusters/Cluster1/hosts/ip-172-31-4-109.ap-southeast-1.compute.internal/host_components/JOURNALNODE


0479-如何禁用HDP2.6.5的HDFS HA_zookeeper_30


3.确认已经删除成功


curl -u admin:admin -H "X-Requested-By: ambari" -i http://localhost:8080/api/v1/clusters/Cluster1/host_components?HostRoles/component_name=JOURNALNODE


0479-如何禁用HDP2.6.5的HDFS HA_zookeeper_31

“items”返回为空则表明删除成功


3.10

删除Standby NameNode


1.检查NameNode所在的2个节点


curl -u admin:admin -H "X-Requested-By: ambari" -i http://localhost:8080/api/v1/clusters/Cluster1/host_components?HostRoles/component_name=NAMENODE


0479-如何禁用HDP2.6.5的HDFS HA_hdfs_32


2.删除其中一个NameNode


curl -u admin:admin -H "X-Requested-By: ambari" -i -X DELETE http://localhost:8080/api/v1/clusters/Cluster1/hosts/ip-172-31-1-163.ap-southeast-1.compute.internal/host_components/NAMENODE


0479-如何禁用HDP2.6.5的HDFS HA_zookeeper_33


3.确认已经删除成功


curl -u admin:admin -H "X-Requested-By: ambari" -i http://localhost:8080/api/v1/clusters/Cluster1/host_components?HostRoles/component_name=NAMENODE


0479-如何禁用HDP2.6.5的HDFS HA_zookeeper_34

显示只有1个NameNode


3.11

确认HDFS服务的相关角色


1.使用Ambari回到HDFS主页面,查看HDFS服务应该包含NameNode,Secondary NameNode和DataNode,不包含JournalNode和Standby NameNode,表明上述的操作成功。


0479-如何禁用HDP2.6.5的HDFS HA_ambari_35


3.12

重新启动HDFS服务


1.使用Ambari界面操作HDFS服务启动


0479-如何禁用HDP2.6.5的HDFS HA_hdfs_36

0479-如何禁用HDP2.6.5的HDFS HA_ambari_37

0479-如何禁用HDP2.6.5的HDFS HA_zookeeper_38

0479-如何禁用HDP2.6.5的HDFS HA_hdfs_39


提示NameNode没有启用HA的警告,这里忽略

2.根据需要重新启动其他的服务


0479-如何禁用HDP2.6.5的HDFS HA_zookeeper_40


4

组件服务验证

4.1

HDFS


[root@ip-172-31-4-109 ~]# hadoop fs -ls /
[root@ip-172-31-4-109 ~]# hadoop fs -cat /tpcds/10/call_center/data-m-00009 | head -1


0479-如何禁用HDP2.6.5的HDFS HA_hdfs_41


4.2

HBase


[root@ip-172-31-4-109 ~]# hbase shell
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.1.2.2.6.5.0-292, r897822d4dd5956ca186974c10382e9094683fa29, Fri May 11 08:00:59 UTC 2018

hbase(main):001:0> list
TABLE
TestTable
1 row(s) in 0.4850 seconds

=> ["TestTable"]
hbase(main):002:0> scan 'TestTable',{LIMIT=>10}


0479-如何禁用HDP2.6.5的HDFS HA_ambari_42


4.3

Hive


[root@ip-172-31-12-114 nameservice1]# hive
hive> show databases;
hive> use tpcds_text_10;
hive> select * from call_center limit 1;
hive> select count(*) from;


0479-如何禁用HDP2.6.5的HDFS HA_zookeeper_43


5

总结


1.在HDP中,启用HDFS HA可以在Ambari界面上直接向导式操作,但是禁用比较麻烦,没办法界面直接操作,得手动一个一个配置项修改,是非常复杂的事情,稍有不慎就有可能操作失败。


2.本文是严格按照官网的文档的步骤来进行操作的,实际可以考虑对于很多配置项的delete和set可以考虑使用Ambari的配置版本管理回滚,尤其是HDFS的hdfs-site.xml和core-site.xml回滚到启用HA之前的状态,这样可以大大节省工作量,也即是本文第三章描述的“3.6 修改HDFS配置”,Fayson没有再实测了,理论可行,网上有这么个玩法的。


3.按照HDP官网的操作步骤有一些坑,会导致后面服务没办法正常启动。


对于hdfs-site.xml需要额外删除以下2个HA相关的参数:

dfs.namenode.https-address.nameservice1.nn1
dfs.namenode.https-address.nameservice1.nn2


另外还需要添加以下配置:

dfs.namenode.http-address
dfs.namenode.https-address


具体参考“3.6 修改HDFS配置”有重点说明


对于Secondary NameNode还需要额外添加以下配置,否则Secondary NameNode服务会告警

dfs.namenode.secondary.http-address


具体参考“3.8 重新启用Secondary NameNode”有重点说明


4.对于HDP官网的步骤缺失问题,有国外网友到HDP社区提问,但是没人理他,他自己找到答案了并解决了。参考如下地址:


dfs.namenode.secondary.http-address


0479-如何禁用HDP2.6.5的HDFS HA_zookeeper_44

“@Hortonworks社区

没有人帮我,但是我自己找到了解决办法,我认为这些应该加入到官网的“手动回滚NameNode HA”手册的“modify_hdfs_configurations”章节,因为手册的描述有些地方并不清楚。”





提示:代码块部分可以左右滑动查看噢


为天地立心,为生民立命,为往圣继绝学,为万世开太平。

温馨提示:如果使用电脑查看图片不清晰,可以使用手机打开文章单击文中的图片放大查看高清原图。


推荐关注Hadoop实操,第一时间,分享更多Hadoop干货,欢迎转发和分享。

0479-如何禁用HDP2.6.5的HDFS HA_zookeeper_45


举报

相关推荐

0 条评论