组件版本:

flink:1.13.0-1.12

cdh:5.16.1

概述:

为cdh集群搭建flink,需要编译flink的parcel包;

准备环境:

安装git和maven,并配置maven的环境变量(lunix安装maven可自行百度,注意镜像换成阿里云的)

进行安装:

1、下载parcel制作包,并修改配置文件

下载flink的parcel制作包(这是通过githup下载的):

git clone https://github.com/pkeropen/flink-parcel.git

通过githup下载有可能下载失败,这是可以直接通过github官网进行下载,然后放到lunix主机上解压;通过flink的parcel制作包,也可以在githup或者gitee上找其他的,这只是一个举例

进入目录会发现这些文件

 

cdh flume 添加配置 cdh安装flink集群_flink

修改flink-parcel.properties配置,修改后如图所示:

cdh flume 添加配置 cdh安装flink集群_cdh flume 添加配置_02

注意:CDH_MIN_FULL=5.14.0和CDH_MAX_FULL=5.14.999,我在实际操作中这是一个大坑,这个最大版本号和最小版本号如何按照实际的,在编译好parcel包后,放入parcel路径里面,可以在cm页面进行分配激活,但是在添加服务时无法检测到flink-yarn服务,通过重启cm服务

然后就会发现cm起不来了!!!  报错信息如下:

enclose compatibility range [CDH 5‥CDH 7.0.0)
	at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:409)
	at com.cloudera.server.cmf.Main.findBeanFactory(Main.java:456)
	at com.cloudera.server.cmf.Main.findRootApplicationContext(Main.java:451)
	at com.cloudera.server.cmf.Main.<init>(Main.java:267)
	at com.cloudera.server.cmf.Main.main(Main.java:216)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rootContext' defined in class path resource [webapp/WEB-INF/spring/beanRefFactory.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dssdToggleListener.PostCommit' defined in URL [jar:file:/opt/cloudera/cm-5.16.1/share/cmf/common_jars/server-5.16.1.jar!/com/cloudera/cmf/service/dssd/components/DssdToggleListener$PostCommit.class]: Unsatisfied dependency expressed through constructor argument with index 2 of type [com.cloudera.server.cmf.descriptor.components.DescriptorFactory]: : Error creating bean with name 'monitoringTypesInitializer': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Range [CDH 4.0.0‥CDH 6.0.0) does not enclose compatibility range [CDH 5‥CDH 7.0.0); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'monitoringTypesInitializer': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Range [CDH 4.0.0‥CDH 6.0.0) does not enclose compatibility range [CDH 5‥CDH 7.0.0)
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:288)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1079)
	at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:397)
	... 4 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dssdToggleListener.PostCommit' defined in URL [jar:file:/opt/cloudera/cm-5.16.1/share/cmf/common_jars/server-5.16.1.jar!/com/cloudera/cmf/service/dssd/components/DssdToggleListener$PostCommit.class]: Unsatisfied dependency expressed through constructor argument with index 2 of type [com.cloudera.server.cmf.descriptor.components.DescriptorFactory]: : Error creating bean with name 'monitoringTypesInitializer': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Range [CDH 4.0.0‥CDH 6.0.0) does not enclose compatibility range [CDH 5‥CDH 7.0.0); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'monitoringTypesInitializer': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Range [CDH 4.0.0‥CDH 6.0.0) does not enclose compatibility range [CDH 5‥CDH 7.0.0)

这个报错信息的意思就是,你编译的flinkparcel包,和cdh应该用的版本有冲突

这个时候cm也起不来了,应该怎么办呢?

幸亏我有先见之明,在搭建flink之前给集群(测试集群)做了快照

关于我如何确定CDH_MIN_FULL=5.14.0和CDH_MAX_FULL=5.14.999这两个值的,是因为我以前给集群安装过phoenix,通过查看本地Parcel 存储库路径查看 manifest.json文件,如下图所示

cdh flume 添加配置 cdh安装flink集群_大数据_03

来进行确定 CDH_MIN_FULL和CDH_MAX_FULL两个值的

关于https://archive.apache.org/dist/flink/flink-1.13.0/flink-1.13.0-bin-scala_2.12.tgz

可以访问https://archive.apache.org/dist/flink/找到自己对应的flink版本,然后对配置文件进行相应的修改

2、编译flink的parcel包:

chmod 774 build.sh 
./build.sh parcel  #制作parcel包

如果./build.sh parcel报错无法生成对应的flinkparcel包,就要检查一下是不是maven的问题,如果不是maven的问题

可以如下所示:

可以直接在本地下载放到lunix服务器上:https://github.com/cloudera/cm_ext.git 

也可以直接在lunix服务器上下载,但是这个时候通过lunix下载估计也会有网络的问题
wget https://github.com/cloudera/cm_ext.git 
unzip cm_ext-master.zip
mv cm_ext-master cm_ext

通过lunix下载flink-1.13.0-bin-scala_2.12.tgz会比较慢,也可以直接去官网下载,然后放到服务器上

当./build.sh parcel执行完成后继续执行编译生成csd文件

./build.sh csd_on_yarn

最后该目录如图所示:

cdh flume 添加配置 cdh安装flink集群_cdh flume 添加配置_04

3、cm添加flink 

拷贝csd文件到 csd文件夹

cp  FLINK_ON_YARN-1.13.0.jar /opt/cloudera/csd/

拷贝parcel文件夹下的两个文件到cm parcel-repo目录

cd cd FLINK-1.13.0-BIN-SCALA_2.12_build
cp FLINK-1.13.0-BIN-SCALA_2.12-el7.parcel /opt/cloudera/parcel-repo/
cp FLINK-1.13.0-BIN-SCALA_2.12-el7.parcel.sha /opt/cloudera/parcel-repo/

关于manifest.json,如果/opt/cloudera/parcel-repo/已经有了这个文件,那就查看一下flink编译后的manifest.json文件内容,如图所示:

cdh flume 添加配置 cdh安装flink集群_flink_05

 这个时候修改/opt/cloudera/parcel-repo/目录下的manifest.json,把flink编译后的manifest.json添加到尾部,并修改对应的lastUpdated,添加后如图所示:

cdh flume 添加配置 cdh安装flink集群_cdh flume 添加配置_06

如果/opt/cloudera/parcel-repo/目录下没有manifest.json,直接将编译flinkparcel包下的manifest.json拷贝过去

然后进入cm页面,检查新parcel,找到flink的parcel  分配激活,添加服务,如图所示:

cdh flume 添加配置 cdh安装flink集群_大数据_07

 

如果无法找到flink-yarn服务可以重启一下cm集群(一般就可以进行添加了),个人建议:在制作好flink-parcel包后,对集群做一下快照,避免出现cm集群无法启动的情况

可以添加服务时注意:

cdh flume 添加配置 cdh安装flink集群_apache_08

剩下的基本上没有什么了,


不同点:flink的版本号,编译配置文件中的CDH_MIN_FULL和CDH_MAX_FULL两个值,manifest.json文件的处理

注意:如何无法访问github或者不稳定,可以自行百度,这里不做讲解