Hadoop运维笔记 之 CDH5.0.0升级到CDH5.3.0


参考资料:
Hadoop: http://www.cloudera.com/content/cloudera/en/documentation/core/v5-3-x/topics/cdh_ig_earlier_cdh5_upgrade.html?scroll=topic_8
Oozie: http://www.cloudera.com/content/cloudera/en/documentation/core/v5-3-x/topics/cdh_ig_oozie_upgrade.html
Hive: http://www.cloudera.com/content/cloudera/en/documentation/core/v5-3-x/topics/cdh_ig_hive_upgrade.html
Pig: http://www.cloudera.com/content/cloudera/en/documentation/core/v5-3-x/topics/cdh_ig_pig_upgrade.html

1. 在所有Hadoop服务器上停止Monit(我们线上使用了Monit来监听进程)
登录idc2-admin1(我们线上使用了idc2-admin1作为管理机以及Yum repo服务器)
# mkdir /root/cdh530_upgrade_from_500
# cd /root/cdh530_upgrade_from_500
# pssh -i -h idc2-hnn-rm-hive 'service monit stop'
# pssh -i -h idc2-hmr.active 'service monit stop'

2. 确认本地的CDH5.3.0的Yum repo服务器已经就绪
http://idc2-admin1/repo/cdh/5.3.0/
http://idc2-admin1/repo/cloudera-gplextras5.3.0/

3. 在Ansible中更新相应的repo模板(我们线上使用了Ansible作为配置管理工具)

{% if "idc2" in group_names %}

...

{% if "cdh5-all" in group_names %}
[heylinux.el6.cloudera-cdh5.3.0]
name= el6 yum cloudera cdh5.3.0
baseurl=http://idc2-admin1/repo/cdh/5.3.0
enabled=1
gpgcheck=0

[heylinux.el6.cloudera-gplextras5.3.0]
name= el6 yum cloudera gplextras5.3.0
baseurl=http://idc2-admin1/repo/cloudera-gplextras5.3.0
enabled=1
gpgcheck=0
{% else %}

...

{% endif %}

4. 更新所有Hadoop服务器的repo文件(/etc/yum.repos.d/heylinux.repo)
# ansible-playbook --private-key /path/to/key_root -u root --vault-password-file=/path/to/vault_passwd.file base.yml -i hosts.idc2 --tags localrepos --limit cdh5-all

5. 升级HDFS相关内容
5.1. 获取当前的Activie Namenode(我们在线上的DNS服务器中创建了一个始终检查并指向Active Namenode的CNAME)
# host active-idc2-hnn
active-idc2-hnn.heylinux.com is an alias for idc2-hnn2.heylinux.com
idc2-hnn2.heylinux.com has address 172.16.2.12

5.2. 在Active NameNode上进入safe mode并生成新的fsimage,并等待整个过程结束。
# sudo -u hdfs hdfs dfsadmin -safemode enter
# sudo -u hdfs hdfs dfsadmin -saveNamespace

5.3 关闭所有的Hadoop服务
回到idc2-admin1上的工作目录
# cd /root/cdh530_upgrade_from_500

首先通过pssh批量关闭Namenode,ResourceManager以及Hive服务器上的Hadoop相关进程(将对应的服务器地址或主机名列表写入到idc2-hnn-rm-hive与idc2-hmr.active)
# pssh -i -h idc2-hnn-rm-hive 'for x in `cd /etc/init.d ; ls hadoop-*` ; do sudo service $x status ; done'
# pssh -i -h idc2-hmr.active 'for x in `cd /etc/init.d ; ls hadoop-*` ; do sudo service $x status ; done'

# pssh -i -h idc2-hnn-rm-hive 'for x in `cd /etc/init.d ; ls hadoop-*` ; do sudo service $x stop ; done'
# pssh -i -h idc2-hmr.active 'for x in `cd /etc/init.d ; ls hadoop-*` ; do sudo service $x stop ; done'

# 检查如果存在与新版本相冲突的libhadoop.so文件,如果存在则删除(我们线上安装了Snappy,它会自己生成一个与CDH5.3.0自带的libhadoop.so相冲突的文件并放置到当前的JDK lib目录下面)。
# pssh -i -h idc2-hnn-rm-hive 'rm -f /usr/java/jdk1.7.0_45/jre/lib/amd64/libhadoop.so'
# pssh -i -h idc2-hmr.active 'rm -f /usr/java/jdk1.7.0_45/jre/lib/amd64/libhadoop.so'
Backup the HDFS metadata on the NameNodes

在Namenodes上备份metadata文件(我们线上有两个Namenode组成的HA,分别为idc2-hnn1与idc2-hnn2:
# mkdir /root/cdh530upgrade
# cd /root/cdh530upgrade
# tar -cf /root/nn_backup_data.data1.`date +%Y%m%d`.tar /data1/dfs/nn
# tar -cf /root/nn_backup_data.data2.`date +%Y%m%d`.tar /data2/dfs/nn

6. 升级Hadoop相关软件包
登录并升级Hive服务器idc2-hive1
# yum clean all; yum upgrade hadoop

登录并升级ResourceManager服务器idc2-rm1与idc2-rm2
# yum clean all; yum upgrade hadoop

回到idc2-admin1并升级所有的Datanode服务器idc2-hmr*
# pssh -i -h idc2-hmr.active 'yum clean all; yum upgrade hadoop hadoop-lzo -y'

登录并升级idc2-hnn1(Standby Namenode,由之前的host active-idc2-hnn命令判断得来)
# yum clean all; yum upgrade hadoop hadoop-lzo

登录并升级idc2-hnn2(Active Namenode,由之前的host active-idc2-hnn命令判断得来)
# yum clean all; yum upgrade hadoop hadoop-lzo

回到idc2-admin1并升级所有的Hadoop Clients
# pssh -i -h idc2-client 'yum clean all; yum upgrade hadoop -y'

7. 启动相关服务
登录并启动Journal Nodes服务(我们线上为idc2-hnn1, idc2-hnn2, idc2-rm1三台服务器)
# service hadoop-hdfs-journalnode start

登录所有的DataNode并启动服务(我们线上为idc2-hmr*服务器)
# service hadoop-hdfs-datanode start

登录Active NameNode并更新HDFS Metadata
# service hadoop-hdfs-namenode upgrade
# tailf /var/log/hadoop/hadoop-hdfs-namenode-`hostname -s`.heylinux.com.log

一直等待直到整个过程结束,例如在Log中出现如下类似内容:
/var/lib/hadoop-hdfs/cache/hadoop/dfs/<name> is complete.

等待直至NameNode退出Safe Mode,然后重启Standby NameNode

登录Standby NameNode并重启服务
# sudo -u hdfs hdfs namenode -bootstrapStandby
# service hadoop-hdfs-namenode start

登录所有的ResourceManager并启动服务
# service hadoop-yarn-resourcemanager start

登录所有的NodeManager并启动服务(我们线上为idc2-hmr*服务器)
# service hadoop-yarn-nodemanager start

在Active ResourceManager上启动HistoryServer(我们线上为idc2-rm1服务器)
# service hadoop-mapreduce-historyserver start

至此,整个Hadoop相关的升级就结束了,下面,将对Hive,Oozie和Pig的升级做相应的介绍。

8. 升级Hive与Oozie服务器(我们线上统一安装到了一台机器idc2-hive1)
8.1 升级Hive服务器
备份Metastore数据库
# mkdir -p /root/backupfiles/hive
# cd /root/backupfiles/hive
# mysqldump -uoozie -pheylinux metastore > metastore.sql.bak.`date +%Y%m%d`

更新hive-site.xml

Confirm the following settings are present in hive-site.xml
<property>
  <name>datanucleus.autoCreateSchema</name>
  <value>false</value>
</property>
  <property>
  <name>datanucleus.fixedDatastore</name>
  <value>true</value>
</property>

停止Hive相关服务
# service hive-server2 stop
# service hive-metastore stop

升级Hive相关软件包
# yum upgrade hive hive-metastore hive-server2 hive-jdbc
# yum install hive-hbase hive-hcatalog hive-webhcat

升级Hive的Metastore
# sudo -u oozie /usr/lib/hive/bin/schematool -dbType mysql -upgradeSchemaFrom 0.12.0

启动Hive服务
# service hive-metastore start
# service hive-server2 start

8.2 升级Oozie服务器
备份Oozie数据库
# mkdir -p /root/backupfiles/hive
# cd /root/backupfiles/hive
# mysqldump -uoozie -pheylinux oozie > oozie.sql.bak.`date +%Y%m%d`

备份Oozie配置文件
# tar cf oozie.conf.bak.`date +%Y%m%d` /etc/oozie/conf

停止Oozie
# service oozie stop

升级Oozie软件包
# yum upgrade oozie oozie-client

仔细校对新的配置文件中与原有配置文件中的参数,并将原有配置文件中的参数更新到新的配置文件

备份Oozie lib目录
# tar cf oozie.lib.bak.`date +%Y%m%d` /var/lib/oozie

升级Oozie数据库
# sudo -u oozie /usr/lib/oozie/bin/ooziedb.sh upgrade -run

升级Oozie Shared Library
# sudo -u oozie hadoop fs -mv /user/oozie/share /user/oozie/share.orig.`date +%Y%m%d`
# sudo oozie-setup sharelib create -fs hdfs://idc1-hnn2:8020 -locallib /usr/lib/oozie/oozie-sharelib-yarn.tar.gz

将所有的library从目录/user/oozie/share/lib/lib_<new_date_string>移动到/user/oozie/share/lib(<new_date_string>为目录生成后上面的时间戳)
# sudo -u oozie mv /user/oozie/share/lib/lib_<new_date_string>/* /user/oozie/share/lib/

检查HDFS中/user/oozie/share目录下的所有文件,并与备份后的share.orig.`date +%Y%m%d`中的文件进行一一对比,除了带有"cdh5"版本字样的软件包仅保留更新的以外,其它的都复制到新的lib目录下。

启动Oozie服务器
# service oozie start

9. 升级Pig
杀掉所有正在运行的Pig进程
# pkill -kill -f pig

更新Pig软件包
# yum upgrade pig

10. 在所有的软件包都升级完毕,并且HDFS也能正常工作的情况下,执行finalizeUpgrade命令做最后的收尾
登录Active Namenode并执行以下命令
# sudo -u hdfs hdfs dfsadmin -finalizeUpgrade

, , , , , ,

  1. No comments yet.
(will not be published)
*