大数据平台配置目录分离与Hadoop升级3.3.1版本

(一)配置目录分离

之前在写:🔗《从零开始学习大数据平台(Episode 1)》时,搭建了测试的大数据平台。
但是按照那时的配置,升级Hadoop,Spark等软件时容易弄丢配置,稍显不便。
所以最好将配置目录(Hadoop还包括HDFS数据目录)和软件目录分开。

1.1 Hadoop

指定:HADOOP_CONF_DIR,到软件目录以外。

$ vim .bashrc 
......
#hadoop
export HADOOP_HOME=/home/ac/hadoop_bin
export HADOOP_CONF_DIR=/home/ac/hadoop_conf #就是这句指定配置所在目录
export PATH=$PATH:${HADOOP_HOME}/sbin
export PATH=$PATH:${HADOOP_HOME}/bin
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib/native"
export LD_LIBRARY_PATH=$HADOOP_HOME/lib/native
......

因为有HDFS存储数据,所以数据目录也分离。
指定:dfs.namenode.name.dirdfs.namenode.name.dir,到软件目录以外。

$ vim $HADOOP_CONF_DIR/hdfs-site.xml
<configuration>
	......
	<property> <!--目录无需预先存在,会自动创建-->
		<name>dfs.namenode.name.dir</name>
		<value>/home/ac/hadoop_data/dfs/name</value><!---->
	</property>
	<property>  <!--目录无需预先存在,会自动创建-->
		<name>dfs.datanode.data.dir</name>
		<value>/home/ac/hadoop_data/dfs/data</value>
	</property>
	......
</configuration>

1.2 Spark

指定:SPARK_CONF_DIR,到软件目录以外。

$ vim .bashrc 
......
#Spark
export SPARK_HOME=/home/ac/spark
export SPARK_CONF_DIR=/home/ac/spark_conf
export PATH=$PATH:${SPARK_HOME}/bin
......

1.3 其他软件

比如:HBASE_CONF_DIR,等等类似……

(二)滚动升级Hadoop版本

2.1 停机升级

将配置目录和数据目录都分离后,更新软件版本只需要删除原有软件目录,将新版本解压到原来的目录名就可以了(直接替换)。

当然这样只适合小版本升级,如果升级跨度太大,还是仔细看官方文档吧。

升级完以后可以用指令看看版本号:

$ hadoop version

Hadoop 3.3.1
Source code repository https://github.com/apache/hadoop.git -r a3b9c37a397ad4188041dd80621bdeefc46885f2
Compiled by ubuntu on 2021-06-15T05:13Z
Compiled with protoc 3.7.1
From source with checksum 88a4ddb2299aca054416d6b7f81ca55
This command was run using /home/ac/hadoop_bin/share/hadoop/common/hadoop-common-3.3.1.jar

我这里之前是3.3.0。
如果软件目录替换后直接启动dfs则会发现NameNode无法启动。

$ start-dfs.sh
......
$ jps
1111 SecondaryNameNode
2222 Jps
3333 DataNode

需要先停下集群, 启动NameNode带上这个参数 “-rollingUpgrade started” .

$ hdfs --daemon start namenode -rollingUpgrade started

执行一次这个以后就可以正常启动了。

2.1 不停机的情况下升级

官方文档:

In an HA cluster, there are two or more NameNodes (NNs), many DataNodes (DNs), a few JournalNodes (JNs) and a few ZooKeeperNodes (ZKNs). JNs is relatively stable and does not require upgrade when upgrading HDFS in most of the cases. In the rolling upgrade procedure described here, only NNs and DNs are considered but JNs and ZKNs are not. Upgrading JNs and ZKNs may incur cluster downtime.

Upgrading Non-Federated Clusters
Suppose there are two namenodes NN1 and NN2, where NN1 and NN2 are respectively in active and standby states. The following are the steps for upgrading an HA cluster:

  1. Prepare Rolling Upgrade
    Run “hdfs dfsadmin -rollingUpgrade prepare” to create a fsimage for rollback.
    Run “hdfs dfsadmin -rollingUpgrade query” to check the status of the rollback image. Wait and re-run the command until the “Proceed with rolling upgrade” message is shown.
  2. Upgrade Active and Standby NNs
    Shutdown and upgrade NN2.
    Start NN2 as standby with the “-rollingUpgrade started” option.
    Failover from NN1 to NN2 so that NN2 becomes active and NN1 becomes standby.
    Shutdown and upgrade NN1.
    Start NN1 as standby with the “-rollingUpgrade started” option.
  3. Upgrade DNs
    Choose a small subset of datanodes (e.g. all datanodes under a particular rack).
    Run “hdfs dfsadmin -shutdownDatanode <DATANODE_HOST:IPC_PORT> upgrade” to shutdown one of the chosen datanodes.
    Run “hdfs dfsadmin -getDatanodeInfo <DATANODE_HOST:IPC_PORT>” to check and wait for the datanode to shutdown.
    Upgrade and restart the datanode.
    Perform the above steps for all the chosen datanodes in the subset in parallel.
    Repeat the above steps until all datanodes in the cluster are upgraded.
  4. Finalize Rolling Upgrade
    Run “hdfs dfsadmin -rollingUpgrade finalize” to finalize the rolling upgrade.

Upgrading Federated Clusters
In a federated cluster, there are multiple namespaces and a pair of active and standby NNs for each namespace. The procedure for upgrading a federated cluster is similar to upgrading a non-federated cluster except that Step 1 and Step 4 are performed on each namespace and Step 2 is performed on each pair of active and standby NNs, i.e.

  1. Prepare Rolling Upgrade for Each Namespace
  2. Upgrade Active and Standby NN pairs for Each Namespace
  3. Upgrade DNs
  4. Finalize Rolling Upgrade for Each Namespace

文档翻译:

‎在 高可用性集群中,有两个或多个‎‎NameNodes (NN)、‎‎许多‎‎DataNode (DN)、‎‎几个‎‎JournalNode (JN)‎‎和几个‎‎ZooKeeperNodes (ZKN)。‎‎JNs‎‎相对稳定,在大多数情况下,升级 HDFS 时不需要升级。在此处介绍的滚动升级过程中,仅考虑‎‎NN‎‎和‎‎DN,‎‎但不考虑‎‎NN‎‎和‎‎ZKN。‎‎升级‎‎JN‎‎和‎‎ZKN‎‎可能会导致群集停机。‎

‎升级非联合群集‎
‎假设有两个名称节点‎‎NN1‎‎和‎‎NN2,‎‎其中‎‎NN1‎‎和‎‎NN2‎‎分别处于活动和待机状态。以下是升级 HA 集群的步骤:‎

  1. ‎准备滚动升级‎
    ‎运行 “‎‎hdfs dfsadmin -rollingUpgrade prepare‎‎” 来创建一个用于回滚的文件系统镜像。‎
    ‎运行"‎‎hdfs dfsadmin -rollingUpgrade query"‎‎来检查回滚映像的状态。等待并重新运行该命令,直到显示"‎‎继续滚动升级‎‎"消息。‎
  2. ‎升级活动和备用‎‎NN‎
    ‎关机并升级‎‎NN2‎‎。‎
    ‎使用‎‎"-rollingUpgrade started"‎‎选项启动‎‎NN2‎‎作为备用数据库。‎
    ‎从‎‎NN1‎‎故障转移到‎‎NN2,‎‎以便‎‎NN2‎‎变为活动状态‎‎,NN1‎‎变为备用。‎
    ‎关机并升级‎‎NN1‎‎。‎
    ‎使用‎‎"-rollingUpgrade started"选项将‎‎NN1‎‎作为备用启动。‎
  3. ‎升级‎‎DN们
    ‎选择一小部分数据节点(例如,特定机架下的所有数据节点)。‎
    ‎运行"‎‎hdfs dfsadmin -shutdownDatanode <DATANODE_HOST:IPC_PORT> upgrade"‎‎以关闭其中一个选定的数据节点。‎
    ‎运行 “‎‎hdfs dfsadmin -getDatanodeInfo <DATANODE_HOST:IPC_PORT>‎‎” 进行检查并等待数据节点关闭。‎
    ‎升级并重新启动数据节点。‎
    ‎对子集中所有选定的数据节点并行执行上述步骤。‎
    ‎重复上述步骤,直到集群中的所有数据节点都升级。‎
  4. ‎完成滚动升级‎
    ‎运行"‎‎hdfs dfsadmin -rollingUpgrade finalize"‎‎以完成滚动升级。‎

‎升级联合集群‎
‎在联合群集中,有多个命名空间以及每个命名空间的一对活动和备用‎‎NN。‎‎升级联合集群的过程类似于升级非联合集群,不同之处在于步骤 1 和步骤 4 在每个命名空间上执行,步骤 2 在每对活动和备用‎‎N 上‎‎执行,即‎:

  1. ‎为每个命名空间准备滚动升级‎
  2. ‎升级每个命名空间的活动和备用‎‎NN‎‎对‎
  3. ‎升级‎‎域名‎
  4. ‎完成每个命名空间的滚动升级‎

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值