Hadoop有两个核心组件:HDFS和YARN。HDFS用于存储数据,YARN用于处理数据。HDFS是Hadoop分布式文件系统,它有Namenode作为Master服务,Datanode作为Slave服务。
Namenode是Hadoop的关键组件,它存储HDFS中数据的元数据。如果Namenode宕机,整个集群将无法访问,这就是单点故障(SPOF)。因此,生产环境将具有Namenode高可用性,以避免如果一个Namenode由于各种原因(例如机器崩溃、计划维护活动等)出现故障而导致生产中断。
Hadoop 2.x提供了我们可以拥有两个Namenode 的可行性,一个是Active Namenode,另一个是Standby Namenode。
- Active Namenode – 它管理所有客户端操作。
- 备用Namenode – 它是活动Namenode的冗余。如果Active NN出现故障,则Standby NN将承担Active NN的所有责任。
启用Namenode高可用性需要Zookeeper,这是自动故障转移所必需的。ZKFC(Zookeeper Failover Controller)是一个Zookeeper客户端,用于维护Namenode的状态。
要求
- 在 CentOS/RHEL 7 上部署 Hadoop 服务器的最佳实践 – 第 1 部分
- 设置 Hadoop 先决条件和安全强化 – 第 2 部分
- 如何在 CentOS/RHEL 7 上安装和配置 Cloudera Manager – 第 3 部分
- 如何在 CentOS/RHEL 7 上安装 CDH 并配置服务放置 – 第 4 部分
在本文中,我们将在Cloudera Manager中启用Namenode 高可用性。
第1步:安装Zookeeper
1.登录Cloudera Manager。
http://您的IP:7180/cmf/home
2.在集群(示例)操作提示中,选择“添加服务”。
3.选择服务“ Zookeeper ”。
4. Select the servers where we are going to have Zookeeper installed.
5. We are going to have 3 Zookeepers to form Zookeeper Quorum. Select the servers as mentioned below.
6. Configure the Zookeeper properties, here we are having the default ones. In real-time, you have to have separate directory/mount points for storing Zookeeper data. In Part-1, we have explained about storage configuration for each service. Click ‘continue’ to proceed.
7. Installation will begin, once installed Zookeeper will be started. You can view the background operations here.
8. After successful completion of the above step, Status will be ‘Finished’.
9. Now, Zookeeper is successfully Installed and Configured. Click the ‘Finish’.
10. You can view the Zookeeper service on the Cloudera Manager Dashboard.
Step 2: Enabling Namenode High Availability
11. Go to Cloudera Manager –> HDFS –> Actions –> Enable High Availability.
12. Enter the Nameservice Name as “nameservice1” – This is a common Namespace for both Active and standby Namenode.
13. Select the Second Namenode where we are going to have standby Namenode.
14. Here we are selecting master2.example.com for standby Namenode.
15. Select the Journal nodes, these are mandatory services for synchronizing Active and Standby Namenode.
16. We are making Quorum Journal by placing the Journal node in 3 servers as mentioned below. Select 3 servers and click ‘OK’.
17. Click ‘Continue’ to proceed.
18.输入日志节点目录路径。只是我们需要在安装时提及路径,该目录将由服务本身自动创建。我们提到的是‘/jn’
。单击“继续”继续。
19.它将开始启用高可用性。
20.一旦完成所有后台进程,我们将获得“已完成”状态。
21.最后,我们将收到一条通知“成功启用高可用性”。单击“完成”。
22.通过转到Cloudera Manager –> HDFS –> Instances验证活动和备用 Namenode。
23.在这里,您可以看到两个Namenode,一个处于“ Active ”状态,另一个处于“ Standby ”状态。
结论
在本文中,我们逐步完成了启用Namenode 高可用性的过程。强烈建议在实时环境中的所有集群中都具有Namenode高可用性。如果您在执行此过程时遇到任何错误,请提出您的疑问。我们将在下一篇文章中看到资源管理器高可用性。