旧版本:3.1.3
升级版本:3.2.4
旧版本安装路径:/ddhome/bin/hadoop/
新版本安装路径:/ddhome/bin/hadoop-3.2.4
# 解压安装包到相应目录下
tar -zxvf /ddhome/tools/hadoop-3.2.4.tar.gz -C /ddhome/bin/
# 复制3.1.3的配置文件到3.2.4中
cd /ddhome/bin/hadoop/etc/hadoop/
cp -r hdfs-site.xml core-site.xml mapred-site.xml yarn-site.xml workers /ddhome/bin/hadoop-3.2.4/etc/hadoop/
# 分发安装包到其余节点中
# 查看原NameNode中元数据的存储位置
# hdfs-site.xml
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/ddhome/bin/hadoop/tmp/hdfs/name</value>
</property>
# 备份(每台节点上执行)
cp -r /ddhome/bin/hadoop/tmp /ddhome/bin/hadoop-3.2.4/
<property>
<name>dfs.namenode.duringRollingUpgrade.enablename>
<value>truevalue>
property>
/ddhome/bin/hadoop/bin/hdfs dfsadmin -rollingUpgrade prepare
/ddhome/bin/hadoop/bin/hdfs dfsadmin -rollingUpgrade query
# 查看NameNode节点的状态
hdfs haadmin -getServiceState nn1
hdfs haadmin -getServiceState nn2
# 在standby节点中关闭NameNode进程
# 在原3.1.3版本中的hadoop相关环境中执行
/ddhome/bin/hadoop/bin/hdfs --daemon stop namenode
# 在新版本3.2.4中的hadoop相关环境中执行
/ddhome/bin/hadoop-3.2.4/bin/hdfs --daemon start namenode -rollingUpgrade started -upgrade
# 执行完毕后,可以通过jps查看进程是否启动
# 在standby节点中关闭NameNode进程
# 在原3.1.3版本中的hadoop相关环境中执行
/ddhome/bin/hadoop/bin/hdfs --daemon stop namenode
# 在新版本3.2.4中的hadoop相关环境中执行
/ddhome/bin/hadoop-3.2.4/bin/hdfs --daemon start namenode -rollingUpgrade started
# 执行完毕后,可以通过jps查看进程是否启动
# 先关闭active状态的NameNode
/ddhome/bin/hadoop-3.2.4/bin/hdfs --daemon stop namenode
# 通过查看节点是否可以实现状态切换
hdfs haadmin -getServiceState nn1
hdfs haadmin -getServiceState nn2
# 如果可以切换,则启动刚关闭NameNode进程
# 查看hdfs-site.xml中的rpc相关设置
<property>
<name>dfs.namenode.rpc-address.masters.nn1</name>
<value>ddcva:9000</value>
</property>
hdfs dfsadmin -shutdownDatanode <DATANODE_HOST:IPC_PORT>
hdfs dfsadmin -getDatanodeInfo <DATANODE_HOST:IPC_PORT>
# 备注:此处的PORT每个版本不固定,使用get命令逐个获取监听PORT的返回值,有个返回值中携带版本号,就是这个PORT
/ddhome/bin/hadoop-3.2.4/bin/hdfs --daemon stop datanode
/ddhome/bin/hadoop-3.2.4/bin/hdfs --daemon start datanode
/ddhome/bin/hadoop-3.2.4/bin/hdfs dfsadmin -rollingUpgrade Finalize
/ddhome/bin/hadoop-3.2.4/bin/hdfs --daemon start journalnode
/ddhome/bin/hadoop-3.2.4/bin/hdfs --daemon start zkfc
/ddhome/bin/hadoop-3.2.4/bin/yarn --daemon start resourcemanager
/ddhome/bin/hadoop-3.2.4/bin/yarn --daemon start nodemanager
# 关闭yarn
/ddhome/bin/hadoop-3.2.4/bin/yarn --daemon stop resourcemanager
/ddhome/bin/hadoop-3.2.4/bin/yarn --daemon stop nodemanager
# 关闭hdfs
/ddhome/bin/hadoop-3.2.4/bin/hdfs --daemon stop datanode
/ddhome/bin/hadoop-3.2.4/bin/hdfs --daemon stop namenode
/ddhome/bin/hadoop-3.2.4/bin/hdfs --daemon stop zkfc
/ddhome/bin/hadoop-3.2.4/bin/hdfs --daemon stop journalnode
cd /ddhome/bin
mv hadoop hadoop-3.1.3
cd /ddhome/bin
mv hadoop-3.2.4 hadoop
# 全部开启
start-all.sh
# 此时namenode可能都启动不了,需单独启动
# 通过日志文件可以查看,dava中,执行
hdfs --daemon start namenode -rollingUpgrade started -upgrade
# 在ddvab中,同步主节点数据
hdfs namenode -bootstrapStandby
# 在ddavb中启动NameNode
hdfs --daemon start namenode