操作系统 Centos7.5
CDH6.3.2集群,需添加yarn服务、zookeeper服务
3.本文版本flink1.10, 20210315更新 : 实测 flink1.12.2可用
准备Git环境,maven环境 ,jdk环境(编译源码需要)
[root@node001 ~]# git --version
git version 1.8.3.1
[root@node001 ~]# mvn -version
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-05T03:00:29+08:00)
Maven home: /opt/module/apache-maven-3.6.1
Java version: 1.8.0_191, vendor: Oracle Corporation, runtime: /opt/module/jdk1.8.0_191/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-862.14.4.el7.x86_64", arch: "amd64", family: "unix"
[root@node001 ~]#
https://flink.apache.org/downloads.html
flink-shaded-10.0-src.tgz下载链接
https://www.apache.org/dyn/closer.lua/flink/flink-1.10.2/flink-1.10.2-src.tgz
flink-1.10.2-src.tgz下载链接
<mirror>
<id>alimavenid>
<mirrorOf>centralmirrorOf>
<name>aliyun mavenname>
<url>http://maven.aliyun.com/nexus/content/repositories/central/url>
mirror>
<mirror>
<id>alimavenid>
<name>aliyun mavenname>
<url>http://maven.aliyun.com/nexus/content/groups/public/url>
<mirrorOf>centralmirrorOf>
mirror>
<mirror>
<id>centralid>
<name>Maven Repository Switchboardname>
<url>http://repo1.maven.org/maven2/url>
<mirrorOf>centralmirrorOf>
mirror>
<mirror>
<id>repo2id>
<mirrorOf>centralmirrorOf>
<name>Human Readable Name for this Mirror.name>
<url>http://repo2.maven.org/maven2/url>
mirror>
<mirror>
<id>ibiblioid>
<mirrorOf>centralmirrorOf>
<name>Human Readable Name for this Mirror.name>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2/url>
mirror>
<mirror>
<id>jboss-public-repository-groupid>
<mirrorOf>centralmirrorOf>
<name>JBoss Public Repository Groupname>
<url>http://repository.jboss.org/nexus/content/groups/publicurl>
mirror>
<mirror>
<id>google-maven-centralid>
<name>Google Maven Centralname>
<url>https://maven-central.storage.googleapis.com
url>
<mirrorOf>centralmirrorOf>
mirror>
<mirror>
<id>maven.net.cnid>
<name>oneof the central mirrors in chinaname>
<url>http://maven.net.cn/content/groups/public/url>
<mirrorOf>centralmirrorOf>
mirror>
[root@node001 flink]# tar -xf flink-shaded-10.0-src.tgz
[root@node001 flink-shaded-10.0]# pwd
/opt/module/flink/flink-shaded-10.0
[root@node001 flink-shaded-10.0]# ll
总用量 80
drwxrwxrwx 4 vanas vanas 4096 11月 29 02:53 flink-shaded-asm-7
drwxrwxrwx 3 vanas vanas 4096 11月 29 02:53 flink-shaded-force-shading
drwxrwxrwx 4 vanas vanas 4096 11月 29 02:53 flink-shaded-guava-18
drwxrwxrwx 5 vanas vanas 4096 11月 29 02:53 flink-shaded-hadoop-2-parent
drwxrwxrwx 5 vanas vanas 4096 11月 29 02:53 flink-shaded-jackson-parent
drwxrwxrwx 4 vanas vanas 4096 11月 29 02:53 flink-shaded-netty-4
drwxrwxrwx 4 vanas vanas 4096 11月 29 02:53 flink-shaded-netty-tcnative-dynamic
drwxrwxrwx 3 vanas vanas 4096 2月 12 2020 flink-shaded-netty-tcnative-static
drwxrwxrwx 5 vanas vanas 4096 11月 29 02:53 flink-shaded-zookeeper-parent
-rwxrwxrwx 1 vanas vanas 11357 2月 12 2020 LICENSE
-rwxrwxrwx 1 vanas vanas 166 2月 12 2020 NOTICE
-rwxrwxrwx 1 vanas vanas 14151 11月 29 01:43 pom.xml
-rwxrwxrwx 1 vanas vanas 1767 2月 12 2020 README.md
drwxr-xr-x 3 root root 4096 11月 29 02:53 target
drwxrwxrwx 3 vanas vanas 4096 2月 12 2020 tools
[root@node001 flink-shaded-10.0]#
vim flink-shaded-10.0/pom.xml
在里面的profiles中添加如下配置参数:
<profile>
<id>vendor-reposid>
<activation>
<property>
<name>vendor-reposname>
property>
activation>
<repositories>
<repository>
<id>cloudera-releasesid>
<url>https://repository.cloudera.com/artifactory/cloudera-reposurl>
<releases>
<enabled>trueenabled>
releases>
<snapshots>
<enabled>falseenabled>
snapshots>
repository>
<repository>
<id>HDPReleasesid>
<name>HDP Releasesname>
<url>https://repo.hortonworks.com/content/repositories/releases/url>
<snapshots><enabled>falseenabled>snapshots>
<releases><enabled>trueenabled>releases>
repository>
<repository>
<id>HortonworksJettyHadoopid>
<name>HDP Jettyname>
<url>https://repo.hortonworks.com/content/repositories/jetty-hadoopurl>
<snapshots><enabled>falseenabled>snapshots>
<releases><enabled>trueenabled>releases>
repository>
<repository>
<id>mapr-releasesid>
<url>https://repository.mapr.com/maven/url>
<snapshots><enabled>falseenabled>snapshots>
<releases><enabled>trueenabled>releases>
repository>
repositories>
profile>
进入到flink-shaded-10.0文件夹下执行以下命令:
mvn clean install -DskipTests -Pvendor-repos -Dhadoop.version=3.0.0-cdh6.3.2 -Dscala-2.12 -Drat.skip=true -T10C
耐心等待编译,可能会失败多次,重复执行命令编译就行
[root@node001 flink]# tar -xf flink-1.10.2-src.tgz
mvn clean install -DskipTests -Dfast -Drat.skip=true -Dhaoop.version=3.0.0-cdh6.3.2 -Pvendor-repos -Dinclude-hadoop -Dscala-2.12 -T10C
[root@node001 flink-1.10.2-bin]# tar -zcf flink-1.10.2-bin-scala_2.12.tgz flink-1.10.2/
git clone https://github.com/pkeropen/flink-parcel.git
vim flink-parcel.properties
#FLINK 下载地址
FLINK_URL=https://mirrors.tuna.tsinghua.edu.cn/apache/flink/flink-1.10.2/flink-1.10.2-bin-scala_2.12.tgz
#flink版本号
FLINK_VERSION=1.10.2
#扩展版本号
EXTENS_VERSION=BIN-SCALA_2.12
#操作系统版本,以centos为例
OS_VERSION=7
#CDH 小版本
CDH_MIN_FULL=5.2
CDH_MAX_FULL=6.3.3
#CDH大版本
CDH_MIN=5
CDH_MAX=6
chmod +x build.sh
./build.sh parcel
./build.sh csd_on_yarn
./build.sh csd_standalone
cp FLINK-1.10.2.jar FLINK_ON_YARN-1.10.2.jar /opt/cloudera/csd/
## 创建目录
mkdir /var/www/html/flink-1.10.2
## 移动parcel文件 与 manidest.json到目录下
cp FLINK-1.10.2-BIN-SCALA_2.12_build/* /var/www/html/flink-1.10.2/
测试是否能正常访问
检查制作parcel包时配置文件参数是否正确
如果一致还报错,就修改httpd配置文件
vi /etc/httpd/conf/httpd.conf
去cm节点重启cm
systemctl start cloudera-scm-server
缺少hadoop依赖,进入前面编译好的flink-shaded-10.0目录,拷贝依赖到flink的lib目录,/opt/module是我的存放目录,具体根据你的实际目录
cp /opt/module/flink/flink-shaded-10.0/flink-shaded-hadoop-2-parent/flink-shaded-hadoop-2-uber/target/flink-shaded-hadoop-2-uber-3.0.0-cdh6.3.2-10.0.jar /opt/cloudera/parcels/FLINK/lib/flink/lib/
没有开启kerberos的话,需要删除这两项内容,否则启动失败