升级CDH到5.7.0

升级CDH到5.7.0

最近对CDH进行升级,从5.4.8升级到5.7.0,主要想升级spark和hbase。

What’s New In CDH 5.7.x

详细信息参考What’s New In CDH 5.7.x

  1. 操作系统支持 RHEL/CentOS 6.6, 6.7, 7.1, 7.2
  2. JDK版本必须1.7或以上。
  3. Spark升级到1.6.0,支持hive on spark
  4. 各服务版本:
Component Package Version
Apache Hadoop hadoop-2.6.0+cdh5.7.0+1280
HBase hbase-1.2.0+cdh5.7.0+129
Apache Hive hive-1.1.0+cdh5.7.0+522
Hue hue-3.9.0+cdh5.7.0+1759
Apache Impala impala-2.5.0+cdh5.7.0+0
Apache Oozie oozie-4.1.0+cdh5.7.0+267
Apache Sentry sentry-1.5.1+cdh5.7.0+184
Apache Spark spark-1.6.0+cdh5.7.0+180
Apache Sqoop sqoop-1.4.6+cdh5.7.0+56
Apache Sqoop2 sqoop2-1.99.5+cdh5.7.0+38
Zookeeper zookeeper-3.4.5+cdh5.7.0+94

更多服务的版本和下载地址参考: CDH 5.7.x Packaging and Tarball Information

CDH升级

数据库备份

cloudera manager数据备份

cloudera manager使用postgres来存储,数据库信息可以在/etc/cloudera-scm-server/db.properties中找到。

备份命令:

1
pg_dump -p 7432 -U scm > /data/backup/scm_server_db_backup.$(date +%Y%m%d)

服务数据备份

使用的是mysql,涉及的库有hive, hue, sentry, oozie, sqoop

  • mysqldump -h vlnx107010 -uroot -p hive > /data/backup/hive-backup.$(date +%Y%m%d).sql
  • mysqldump -h vlnx107010 -uroot -p hue > /data/backup/hue-backup.$(date +%Y%m%d).sql
  • mysqldump -h vlnx107010 -uroot -p sentry > /data/backup/sentry-backup.$(date +%Y%m%d).sql
  • mysqldump -h vlnx107010 -uroot -p oozie_oozie_server > /data/backup/oozie-backup.$(date +%Y%m%d).sql
  • mysqldump -h vlnx107010 -uroot -p sqoop > /data/backup/sqoop-backup.$(date +%Y%m%d).sql

更新cloudera manager server

使用packages方式更新。

停止cloudera manager server, database, agent

  1. 停止正在运行的命令
  2. 停止cloudera-manager服务

    1
    $ sudo service cloudera-scm-server stop
  1. 使用内嵌的PostgreSQL数据库的话,停止此服务

    1
    $ sudo service cloudera-scm-server-db stop

    ==Important:== If you are not running the embedded database service and you attempt to stop it, you receive a message indicating that the service cannot be found. If instead you get a message that the shutdown failed, the embedded database is still running, probably because services are connected to the Hive metastore. If the database shutdown fails due to connected services, issue the following command:
    RHEL-compatible 7 and higher:

    1
    2
    3
    4
    5
    $ sudo service cloudera-scm-server-db next_stop_fast
    $ sudo service cloudera-scm-server-db stop
    ```
    All other Linux distributions:
    >

    sudo service cloudera-scm-server-db fast_stop

    1
    2
    3
    4
    5
    4. 停止cloudera-agent服务
    ``` bash
    $ sudo service cloudera-scm-agent stop

设置repo

在线升级,使用cloudera源

如果网络速度比较快,可以直接新建cloudera-manager.repo:

1
2
3
4
5
6
[cloudera-manager]
# Packages for Cloudera Manager, Version 5, on RHEL or CentOS 6 x86_64
name = Cloudera Manager
baseurl = https://archive.cloudera.com/cm5/redhat/6/x86_64/cm/5/
gpgkey = https://archive.cloudera.com/cm5/redhat/6/x86_64/cm/RPM-GPG-KEY-cloudera
gpgcheck = 1
搭建本地源

如果访问cloudera源不太稳定,可以搭建本地的repo源。

  1. 安装vsftp

    使用vsftp作为ftp服务器,配置文件在/etc/vsftpd/下,ftp路径在/var/ftp/下。

    1
    2
    $ yum install vsftpd
    $ service vsftpd start
  2. 下载rpm包和repodata

    新建目录/var/ftp/pub/cloudera-repo作为repo源目录,从https://archive.cloudera.com/cm5/redhat/6/x86_64/cm/5/按下载所需的rpm包和repodata目录,完成后目录结构如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    $ tree /var/ftp/pub/cloudera-repo/
    /var/ftp/pub/cloudera-repo/
    ├── repodata
    │   ├── filelists.xml.gz
    │   ├── filelists.xml.gz.asc
    │   ├── other.xml.gz
    │   ├── other.xml.gz.asc
    │   ├── primary.xml.gz
    │   ├── primary.xml.gz.asc
    │   ├── repomd.xml
    │   └── repomd.xml.asc
    └── RPMS
    └── x86_64
    ├── cloudera-manager-agent-5.7.0-1.cm570.p0.76.el6.x86_64.rpm
    ├── cloudera-manager-daemons-5.7.0-1.cm570.p0.76.el6.x86_64.rpm
    ├── cloudera-manager-server-5.7.0-1.cm570.p0.76.el6.x86_64.rpm
    └── cloudera-manager-server-db-2-5.7.0-1.cm570.p0.76.el6.x86_64.rpm
  1. 新建本地repocloudera-manager.repo如下:

    1
    2
    3
    4
    [cloudera-manager]
    name = Cloudera Manager, Version 5.7.0
    baseurl = ftp://${local-repo-ip}/pub/cloudera-repo
    gpgcheck = 0
    • 如果手动升级各机器的cloudera-manager-agent,需要将cloudera-manager.repo更新到所有节点上
    • 如果使用cloudera升级各机器的cloudera-manager-agent,在升级时注意选择Custom Repository,填写repository地址为ftp://${local-repo-ip}/pub/cloudera-repo

进行升级

1
2
$ sudo yum clean all
$ sudo yum upgrade cloudera-manager-server cloudera-manager-daemons cloudera-manager-server-db-2 cloudera-manager-agent

重启cloudera manager服务

1
2
$ sudo service cloudera-scm-server-db start
$ sudo service cloudera-scm-server start

更新cloudera manager agent

==Important:== All hosts in the cluster must have access to the Internet if you plan to use archive.cloudera.com as the source for installation files. If you do not have Internet access, create a custom repository.

以下两种升级任选一种。

使用cloudera进行升级

进入cloudera manager后,会自动弹出升级页面,选择Yes, I would like to upgrade the Cloudera Manager Agent packages now,然后一步步进行。

在选择Cloudera Manager Agent Release时,有两种选择

  1. 如果进行在线升级,选择Matched Release for this Cloudera Manager Server,这样会直接从https://archive.cloudera.com/cm5/redhat/6/x86_64/cm/5/进行更新。
  2. 如果自己下载了rpm包,并建立了本地repo源,选择Custom Repository,然后填写本地repo源地址。

这两种方式都会在每台机器/etc/yum.repos.d/目录下生成cloudera-manager.repo,不过其中的baseurl参数不同。

手动进行更新

  1. 在每台机器上添加cloudera-manager.repo并清理yum cache,yum clean all
  2. 停止cloudera-scm-agent服务: service cloudera-scm-agent stop
  3. 更新cloudera-manager-agent: yum upgrade cloudera-manager-server cloudera-manager-daemons cloudera-manager-server-db-2 cloudera-manager-agent
  4. 启动cloudera-scm-agent服务: service cloudera-scm-agent start

验证CDH升级是否成功

在页面上hosts页面,点击Inspect All Hosts,检测完成后可以查看结果,能够比较详细的查看各机器情况。

服务升级

CDH升级后,更要重的是对CDH管理的服务进行升级,这里使用parcels进行升级。

创建临时远程仓库

  1. 新建目录/data/cloudera-parcel-server
  2. 下载CDH parcel和manifest.json

    1
    2
    $ wget http://archive.cloudera.com/cdh5/parcels/5/CDH-5.7.0-1.cdh5.7.0.p0.45-el6.parcel
    $ wget http://archive.cloudera.com/cdh5/parcels/5/manifest.json
  1. 下载kafka parcel和manifest.json

    1
    2
    $ wget http://archive.cloudera.com/kafka/parcels/2/KAFKA-2.0.1-1.2.0.1.p0.5-el6.parcel
    $ wget http://archive.cloudera.com/kafka/parcels/2/manifest.json
  2. 下载gplextras5和manifest.json

    1
    2
    $ wget http://archive.cloudera.com/gplextras5/parcels/5/GPLEXTRAS-5.6.1-1.cdh5.6.1.p0.5-el6.parcel
    $ wget http://archive.cloudera.com/gplextras5/parcels/5/manifest.json
  1. 整体目录结构如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    $ tree /data/cloudera-parcel-server/
    /data/cloudera-parcel-server/
    ├── cdh
    │   ├── CDH-5.7.0-1.cdh5.7.0.p0.45-el6.parcel
    │   └── manifest.json
    ├── gplextras
    │   ├── GPLEXTRAS-5.6.1-1.cdh5.6.1.p0.5-el6.parcel
    │   └── manifest.json
    └── kafka
    ├── KAFKA-2.0.1-1.2.0.1.p0.5-el6.parcel
    └── manifest.json
    3 directories, 6 files
  2. 启动一个server

    1
    $ python -m SimpleHTTPServer 8080

在浏览器中打开链接查看是否启动成功,http://{http-server-ip}:8080,成功后可以在parcels的配置Remote Parcel Repository URLs中添加相关的parcel地址:

  • http://{http-server-ip}:8080/cdh/
  • http://{http-server-ip}:8080/kafka/
  • http://{http-server-ip}:8080/gplextras/

CDH Parcel(服务)升级

参考Upgrading to CDH 5.7 Using Parcels

  1. Hosts -> Parcels处设置上一个步骤中的parcel临时远程仓库
  2. 在首页cluster名右侧小三角处点击『Upgrade Cluster』,仔细阅读升级前的准备,并提前准备好
  3. 在节点检测完后,选择Let me upgrade the cluster,手动进行重启服务以避免服务不可用。
  4. 升级Oozie ShareLib,在Oozie服务页面,点击Actions > Install Oozie ShareLib
  5. 升级Sqoop2,在Sqoop2页面,点击Actions > Upgrade Sqoop
  6. 升级Spark,在spark页面,点击Actions > Install Spark JARActions > Create Spark History Log Dir
  7. 手动将服务一个个重启,可以在每个服务的InstancesTab页,一个实例一个实例的重启,这样可以避免服务不可用。
  8. 重启完后,运行Deploy Client Configuration
  9. 在parcels页面可以删除之前的parcel。

另外的途径可以在Hosts > parcels页面手动进行DistributeActive,然后进行上面的步骤4–步骤9。

KAFKA Parcel升级

Hosts > parcels页面手动对Kafka Parcel进行DistributeActive,然后对Kafka Broker一台台进行重启,确定没问题后可以删除旧的parcel。

GPLEXTRAS Parcel升级(添加对lzo的支持)

参考Configuring Services to Use the GPL Extras Parcel

  1. Hosts > parcels页面手动对gplextras parcel进行DistributeActive
  2. HDFS服务中修改配置Compression Codecs,添加com.hadoop.compression.lzo.LzoCodeccom.hadoop.compression.lzo.LzopCodec,重启HDFS。
  3. 在每台Oozie Server上建立hadoop-lzo.jar的软链接,ln -sf /opt/cloudera/parcels/GPLEXTRAS/lib/hadoop/lib/hadoop-lzo.jar /var/lib/ooziehadoop-lzo.jar,重启Oozie。
  4. Sqoop2服务中修改配置Sqoop Service Environment Advanced Configuration Snippet,添加HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/opt/cloudera/parcels/GPLEXTRAS/lib/hadoop/lib/*JAVA_LIBRARY_PATH=$JAVA_LIBRARY_PATH:/opt/cloudera/parcels/GPLEXTRAS/lib/hadoop/lib/native,重启Sqoop2。
  5. 重启其他需要重启的服务。
  6. 运行Deploy Client Configuration

CDH Client(Gateway)升级

在升级后,发现各Client中的命令引用没有更新,需要手动将/etc/alternatives/目录下CDH相关更新为最新。
spark-shell为例。

  1. 执行which spark-shell,发现指向/usr/bin/spark-shell
  2. 执行ls -l /usr/bin/spark-shell,发现是个软链接并指向了/etc/alternatives/spark-shell
  3. 执行ls -l /etc/alternatives/spark-shell,发现是个软链接并指向了/opt/cloudera/parcels/CDH-5.4.8-1.cdh5.4.8.p0.4/bin/spark-shell,明显还指向升级前的版本。
  4. 执行ln -sf /opt/cloudera/parcels/CDH/bin/spark-shell /etc/alternatives/spark-shell将其指向最新的版本。

可以使用shell脚本批量将/etc/alternatives下CDH相关软链接指向最新的版本。

参考

  1. Upgrading Cloudera Manager 5 to the Latest Cloudera Manager: http://www.cloudera.com/documentation/enterprise/latest/topics/cm_ag_upgrade_cm5.html
  2. Upgrading CDH and Managed Services Using Cloudera Manager: http://www.cloudera.com/documentation/enterprise/latest/topics/cm_mc_upgrading_cdh.html
  3. Upgrading to CDH 5.7 Using Parcels: http://www.cloudera.com/documentation/enterprise/latest/topics/install_upgrade_to_cdh57_parcels.html
  4. Creating a Temporary Remote Repository: http://www.cloudera.com/documentation/enterprise/latest/topics/cm_ig_create_local_parcel_repo.html
  5. postgresql常用命令: http://blog.chinaunix.net/uid-26642180-id-3485465.html
  6. Running Hive on Spark: http://www.cloudera.com/documentation/enterprise/latest/topics/admin_hos_oview.html
  7. Configuring Services to Use the GPL Extras Parcel: http://www.cloudera.com/documentation/enterprise/latest/topics/cm_mc_gpl_extras.html
  8. CDH 5.7.0 Properties: http://www.cloudera.com/documentation/enterprise/latest/topics/cm_props_cdh570.html

你可能感兴趣的:(升级CDH到5.7.0)