Hadoop生态圈-通过CDH5.15.1部署spark1.6与spark2.3.0的版本兼容运行

时间:2021-10-14 19:37:45

             Hadoop生态圈-通过CDH5.15.1部署spark1.6与spark2.3.0的版本兼容运行                 

                                                  作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

  在我的CDH5.15.1集群中,默认安装的spark是1.6版本,开发的同事跟我抱怨,说之前的大数据平台(在ucloud上,属于云服务)用的就是spark1.6,好多java的API都用不了,有很多高级的功能没法在1.6版本上使用,因此*需要升级spark版本,他们要求升级到2.3.0或以上版本,经查阅相关资料,才总结了我部署spark2.3.0的部署笔记。当然你可以参考官网:https://www.cloudera.com/documentation/spark2/latest/topics/spark2_installing.html
  如果你使用CDH部署kafka的话,相信升级spark版本这个事情对你来说就是小菜一碟了,因为他们基本上是一个套路。如果你使用时CDH免费版本的话,我并不推荐你使用CDH集成kafka。因为里面有一些和奇葩的坑在等着你。
 
 
一.下载spark2.3的CSD的jar包
  和CDH集成kafka的套路一样,我们在安装spark版本的时候也需要下载相应的csd的jar包。下载地址:http://archive.cloudera.com/spark2/csd/
1>.选择csd版本
Hadoop生态圈-通过CDH5.15.1部署spark1.6与spark2.3.0的版本兼容运行
2>.安装下载的软件包(wget)
[root@node101 ~]# yum -y install wget
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
10gen | 2.5 kB ::
base | 3.6 kB ::
centosplus | 3.4 kB ::
epel | 3.2 kB ::
extras | 3.4 kB ::
mysql-connectors-community | 2.5 kB ::
mysql-tools-community | 2.5 kB ::
mysql56-community | 2.5 kB ::
updates | 3.4 kB ::
(/): epel/x86_64/updateinfo | kB ::
(/): epel/x86_64/primary | 3.6 MB ::
(/): updates//x86_64/primary_db | 6.0 MB ::
epel /
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 :1.14-.el7_4. will be installed
--> Finished Dependency Resolution Dependencies Resolved ===================================================================================================================================================================================================================
Package Arch Version Repository Size
===================================================================================================================================================================================================================
Installing:
wget x86_64 1.14-.el7_4. base k Transaction Summary
===================================================================================================================================================================================================================
Install Package Total download size: k
Installed size: 2.0 M
Downloading packages:
wget-1.14-.el7_4..x86_64.rpm | kB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : wget-1.14-.el7_4..x86_64 /
Verifying : wget-1.14-.el7_4..x86_64 / Installed:
wget.x86_64 :1.14-.el7_4. Complete!
[root@node101 ~]#

[root@node101 ~]# yum -y install wget

3>.下载csd的jar包
[root@node101 ~]# mkdir /opt/cloudera/csd && cd /opt/cloudera/csd
[root@node101 csd]#
[root@node101 csd]# wget http://archive.cloudera.com/spark2/csd/SPARK2_ON_YARN-2.3.0.cloudera4.jar
---- ::-- http://archive.cloudera.com/spark2/csd/SPARK2_ON_YARN-2.3.0.cloudera4.jar
Connecting to 10.9.137.250:... connected.
Proxy request sent, awaiting response... OK
Length: (19K) [application/java-archive]
Saving to: ‘SPARK2_ON_YARN-2.3..cloudera4.jar’ %[=========================================================================================================================================================================>] , --.-K/s in .002s -- :: (10.4 MB/s) - ‘SPARK2_ON_YARN-2.3..cloudera4.jar’ saved [/] [root@node101 csd]#
[root@node101 csd]# ll
total
-rw-r--r--. root root Oct : SPARK2_ON_YARN-2.3..cloudera4.jar
[root@node101 csd]#
4>.更改权限,让其属于cloudera-scm用户
[root@node101 csd]# ll
total
-rw-r--r--. root root Oct : SPARK2_ON_YARN-2.3..cloudera4.jar
[root@node101 csd]#
[root@node101 csd]#
[root@node101 csd]# id cloudera-scm
uid=(cloudera-scm) gid=(cloudera-scm) groups=(cloudera-scm)
[root@node101 csd]#
[root@node101 csd]#
[root@node101 csd]# chown cloudera-scm:cloudera-scm SPARK2_ON_YARN-2.3..cloudera4.jar
[root@node101 csd]#
[root@node101 csd]# ll
total
-rw-r--r--. cloudera-scm cloudera-scm Oct : SPARK2_ON_YARN-2.3..cloudera4.jar
[root@node101 csd]#

 

二.下载spark2.3的parcel安装包
  和CDH集成kafka的套路一样,我们在安装spark版本的时候也需要下载相应的parcel的jar包。下载地址:http://archive.cloudera.com/spark2/parcels/2.3.0.cloudera4/
1>.选择spark的版本,它需要和上面的csd的版本对应上,当然也得和你的操作系统的版本对应上。
Hadoop生态圈-通过CDH5.15.1部署spark1.6与spark2.3.0的版本兼容运行 
2>.进入下载目录,并将manifest.json文件进行备份操作
[root@node101 ~]# cd /opt/cloudera/parcel-repo/
[root@node101 parcel-repo]#
[root@node101 parcel-repo]# ll
total
-rwxr-xr-x. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel
-rwxr-xr-x. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel.sha
-rw-r-----. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel.torrent
-rwxr-xr-x. root root Oct : manifest.json
[root@node101 parcel-repo]#
[root@node101 parcel-repo]# mv manifest.json manifest.json.`date +%F`
[root@node101 parcel-repo]#
[root@node101 parcel-repo]# ll
total
-rwxr-xr-x. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel
-rwxr-xr-x. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel.sha
-rw-r-----. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel.torrent
-rwxr-xr-x. root root Oct : manifest.json.--
[root@node101 parcel-repo]#
3>.下载spark2.3版本对应的安装包
[root@node101 ~]# hostname
node101.yinzhengjie.org.cn
[root@node101 ~]#
[root@node101 ~]# cd /opt/cloudera/parcel-repo/
[root@node101 parcel-repo]#
[root@node101 parcel-repo]# ll
total
-rwxr-xr-x. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel
-rwxr-xr-x. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel.sha
-rw-r-----. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel.torrent
-rwxr-xr-x. root root Oct : manifest.json.--
[root@node101 parcel-repo]#
[root@node101 parcel-repo]# wget http://archive.cloudera.com/spark2/parcels/2.3.0.cloudera4/SPARK2-2.3.0.cloudera4-1.cdh5.13.3.p0.611179-el7.parcel
---- ::-- http://archive.cloudera.com/spark2/parcels/2.3.0.cloudera4/SPARK2-2.3.0.cloudera4-1.cdh5.13.3.p0.611179-el7.parcel
Connecting to 10.9.137.250:... connected.
Proxy request sent, awaiting response... OK
Length: (183M) [binary/octet-stream]
Saving to: ‘SPARK2-2.3..cloudera4-.cdh5.13.3.p0.-el7.parcel’ %[=========================================================================================================================================================================>] ,, 255KB/s in 22m 2s -- :: ( KB/s) - ‘SPARK2-2.3..cloudera4-.cdh5.13.3.p0.-el7.parcel’ saved [/] [root@node101 parcel-repo]# ll
total
-rwxr-xr-x. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel
-rwxr-xr-x. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel.sha
-rw-r-----. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel.torrent
-rwxr-xr-x. root root Oct : manifest.json.--
-rw-r--r--. root root Oct : SPARK2-2.3..cloudera4-.cdh5.13.3.p0.-el7.parcel
[root@node101 parcel-repo]#

下载spark2.3.0版本的parcel安装包([root@node101 parcel-repo]# wget http://archive.cloudera.com/spark2/parcels/2.3.0.cloudera4/SPARK2-2.3.0.cloudera4-1.cdh5.13.3.p0.611179-el7.parcel)

[root@node101 parcel-repo]# ll
total
-rwxr-xr-x. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel
-rwxr-xr-x. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel.sha
-rw-r-----. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel.torrent
-rwxr-xr-x. root root Oct : manifest.json.--
-rw-r--r--. root root Oct : SPARK2-2.3..cloudera4-.cdh5.13.3.p0.-el7.parcel
[root@node101 parcel-repo]#
[root@node101 parcel-repo]# wget http://archive.cloudera.com/spark2/parcels/2.3.0.cloudera4/SPARK2-2.3.0.cloudera4-1.cdh5.13.3.p0.611179-el7.parcel.sha1
---- ::-- http://archive.cloudera.com/spark2/parcels/2.3.0.cloudera4/SPARK2-2.3.0.cloudera4-1.cdh5.13.3.p0.611179-el7.parcel.sha1
Connecting to 10.9.137.250:... connected.
Proxy request sent, awaiting response... OK
Length: [binary/octet-stream]
Saving to: ‘SPARK2-2.3..cloudera4-.cdh5.13.3.p0.-el7.parcel.sha1’ %[=========================================================================================================================================================================>] --.-K/s in 0s -- :: (3.01 MB/s) - ‘SPARK2-2.3..cloudera4-.cdh5.13.3.p0.-el7.parcel.sha1’ saved [/] [root@node101 parcel-repo]# ll
total
-rwxr-xr-x. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel
-rwxr-xr-x. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel.sha
-rw-r-----. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel.torrent
-rwxr-xr-x. root root Oct : manifest.json.--
-rw-r--r--. root root Oct : SPARK2-2.3..cloudera4-.cdh5.13.3.p0.-el7.parcel
-rw-r--r--. root root Oct : SPARK2-2.3..cloudera4-.cdh5.13.3.p0.-el7.parcel.sha1
[root@node101 parcel-repo]#

下载spark2.3.0的parcel校验包([root@node101 parcel-repo]# wget http://archive.cloudera.com/spark2/parcels/2.3.0.cloudera4/SPARK2-2.3.0.cloudera4-1.cdh5.13.3.p0.611179-el7.parcel.sha1)

[root@node101 parcel-repo]# hostname
node101.yinzhengjie.org.cn
[root@node101 parcel-repo]#
[root@node101 parcel-repo]# pwd
/opt/cloudera/parcel-repo
[root@node101 parcel-repo]#
[root@node101 parcel-repo]# ll
total
-rwxr-xr-x. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel
-rwxr-xr-x. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel.sha
-rw-r-----. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel.torrent
-rwxr-xr-x. root root Oct : manifest.json.--
-rw-r--r--. root root Oct : SPARK2-2.3..cloudera4-.cdh5.13.3.p0.-el7.parcel
-rw-r--r--. root root Oct : SPARK2-2.3..cloudera4-.cdh5.13.3.p0.-el7.parcel.sha1
[root@node101 parcel-repo]#
[root@node101 parcel-repo]#
[root@node101 parcel-repo]# mv SPARK2-2.3..cloudera4-.cdh5.13.3.p0.-el7.parcel.sha1 SPARK2-2.3..cloudera4-.cdh5.13.3.p0.-el7.parcel.sha
[root@node101 parcel-repo]#
[root@node101 parcel-repo]# ll
total
-rwxr-xr-x. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel
-rwxr-xr-x. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel.sha
-rw-r-----. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel.torrent
-rwxr-xr-x. root root Oct : manifest.json.--
-rw-r--r--. root root Oct : SPARK2-2.3..cloudera4-.cdh5.13.3.p0.-el7.parcel
-rw-r--r--. root root Oct : SPARK2-2.3..cloudera4-.cdh5.13.3.p0.-el7.parcel.sha
[root@node101 parcel-repo]#

对下载的校验包进行重命名操作([root@node101 parcel-repo]# mv SPARK2-2.3.0.cloudera4-1.cdh5.13.3.p0.611179-el7.parcel.sha1 SPARK2-2.3.0.cloudera4-1.cdh5.13.3.p0.611179-el7.parcel.sha)

[root@node101 parcel-repo]# hostname
node101.yinzhengjie.org.cn
[root@node101 parcel-repo]#
[root@node101 parcel-repo]# pwd
/opt/cloudera/parcel-repo
[root@node101 parcel-repo]#
[root@node101 parcel-repo]# ll
total
-rwxr-xr-x. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel
-rwxr-xr-x. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel.sha
-rw-r-----. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel.torrent
-rwxr-xr-x. root root Oct : manifest.json.--
-rw-r--r--. root root Oct : SPARK2-2.3..cloudera4-.cdh5.13.3.p0.-el7.parcel
-rw-r--r--. root root Oct : SPARK2-2.3..cloudera4-.cdh5.13.3.p0.-el7.parcel.sha
[root@node101 parcel-repo]#
[root@node101 parcel-repo]# wget http://archive.cloudera.com/spark2/parcels/2.1.0.cloudera1/manifest.json
---- ::-- http://archive.cloudera.com/spark2/parcels/2.1.0.cloudera1/manifest.json
Connecting to 10.9.137.250:... connected.
Proxy request sent, awaiting response... OK
Length: (.6K) [application/json]
Saving to: ‘manifest.json’ %[=========================================================================================================================================================================>] , --.-K/s in 0s -- :: ( MB/s) - ‘manifest.json’ saved [/] [root@node101 parcel-repo]#
[root@node101 parcel-repo]# ll
total
-rwxr-xr-x. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel
-rwxr-xr-x. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel.sha
-rw-r-----. root root Oct : CDH-5.15.-.cdh5.15.1.p0.-el7.parcel.torrent
-rw-r--r--. root root Feb manifest.json
-rwxr-xr-x. root root Oct : manifest.json.--
-rw-r--r--. root root Oct : SPARK2-2.3..cloudera4-.cdh5.13.3.p0.-el7.parcel
-rw-r--r--. root root Oct : SPARK2-2.3..cloudera4-.cdh5.13.3.p0.-el7.parcel.sha
[root@node101 parcel-repo]#

下载manifest.json的安装包([root@node101 parcel-repo]# wget http://archive.cloudera.com/spark2/parcels/2.1.0.cloudera1/manifest.json)

4>.重启Cloudera manager的服务端(我是离线方式部署的CDH)

[root@node101 ~]# hostname
node101.yinzhengjie.org.cn
[root@node101 ~]#
[root@node101 ~]# cd /opt/cloudera-manager/cm-5.15./etc/init.d/
[root@node101 init.d]#
[root@node101 init.d]# ll
total
-rwxr-xr-x. Jul : cloudera-scm-agent
-rwxr-xr-x. Jul : cloudera-scm-server
-rwxr-xr-x. Jul : cloudera-scm-server-db
[root@node101 init.d]#
[root@node101 init.d]# ./cloudera-scm-server restart
Stopping cloudera-scm-server: [ OK ]
Starting cloudera-scm-server: [ OK ]
[root@node101 init.d]#
 
三.通过CDH部署spark2.3.0
1>.点击Parcel
Hadoop生态圈-通过CDH5.15.1部署spark1.6与spark2.3.0的版本兼容运行
2>.点击分配
Hadoop生态圈-通过CDH5.15.1部署spark1.6与spark2.3.0的版本兼容运行
3>.点击激活
Hadoop生态圈-通过CDH5.15.1部署spark1.6与spark2.3.0的版本兼容运行
4>.点击确定
Hadoop生态圈-通过CDH5.15.1部署spark1.6与spark2.3.0的版本兼容运行
5>.激活完成
Hadoop生态圈-通过CDH5.15.1部署spark1.6与spark2.3.0的版本兼容运行
6>.点击添加服务
Hadoop生态圈-通过CDH5.15.1部署spark1.6与spark2.3.0的版本兼容运行
7>.选择Spark2,并点击继续
 Hadoop生态圈-通过CDH5.15.1部署spark1.6与spark2.3.0的版本兼容运行
8>.为spark2.3.0版本分配角色
Hadoop生态圈-通过CDH5.15.1部署spark1.6与spark2.3.0的版本兼容运行
9>.点击继续
Hadoop生态圈-通过CDH5.15.1部署spark1.6与spark2.3.0的版本兼容运行
10>.等待服务部署完成
Hadoop生态圈-通过CDH5.15.1部署spark1.6与spark2.3.0的版本兼容运行
11>.spark2.3.0服务添加成功
Hadoop生态圈-通过CDH5.15.1部署spark1.6与spark2.3.0的版本兼容运行
12>.在cloudera manager主界面查看spark2.3.0服务
Hadoop生态圈-通过CDH5.15.1部署spark1.6与spark2.3.0的版本兼容运行

 13>.在部署有gateway主机上运行spark2.3.0版本环境

Hadoop生态圈-通过CDH5.15.1部署spark1.6与spark2.3.0的版本兼容运行

 
四.部署spark可能会遇到的报错处理
1>.缺少YARN组建,spark有两种模式,一种时独立模式,一种时yarn模式,
  部署spark时报错提示如下:
      必须提供“YARN (MR2 Included)”类型的有效依赖服务才能创建“Spark 2”类型的新服务。
Hadoop生态圈-通过CDH5.15.1部署spark1.6与spark2.3.0的版本兼容运行

  解决方案:

    很简单,我们在部署spark和spark2时,如果选择的时on yarn模式的话,人家已经指名道姓的让你安装YARN服务,因此我们只需要把yarn服务安装好再来安装spark2.3.0版本即可。

2>. 执行内存小雨分配最大内存。

  启动spark2时报错如下:

    Required executor memory (1024+384 MB) is above the max threshold (1024 MB) of this cluster! Please check the values of 'yarn.scheduler.maximum-allocation-mb' and/or 'yarn.nodemanager.resource.memory-mb'. 

Hadoop生态圈-通过CDH5.15.1部署spark1.6与spark2.3.0的版本兼容运行

  解决方案:

    按照上图的报错信息提示,执行的内存超过来你分配的最大内存,因此按照提示去yarn服务的配置文件修改最大容器内存(yarn.scheduler.maximum-allocation-mb)和容器内存(yarn.nodemanager.resource.memory-mb)的值即可。我的建议是不要把操作系统的所有内存都分配出去,需要给操作系统预留点内存,推荐遵循二八法则(20%的内存分配给操作系统,80%的内存分配给服务)。