总体步骤3步
1.下载源码
2.打包代码
3.启动flink集群
第一步(下载源码):
在flink的github仓库下载源码链接如下:https://github.com/apache/flink
第二步(打包代码):
在打包过程中我遇到两个问题
1.由于该项目包含很多doc以及test代码,很多代码文件是没有如下的证书说明,会导致报错Too many files with unapproved license。所以我们在打包时需要加参数-Dlicense.skip=true -Drat.ignoreErrors=true
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
2.第二个问题是关于npm,打包过程中会有如下报错
flink-runtime-web_2.11: Failed to run task: 'npm install --cache-max=0 --no-save' failed
这里涉及到flink runtime web,如果不需要看web的同学可以用方法1,不过web对于flink的理解还是很重要的,所以我们不选择加打包参数的方法,使用方法2(原因就是npm仓库访问问题,我们改为淘宝的仓库即可)
1.直接加maven打包参数-Dskip.npm即可搞定
2.修改flink-runtime-web/pom.xml的<id>npm install</id>处的configuration为install -g -registry=https://registry.npm.taobao
.org --cache-max=0 --no-save
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install -g -registry=https://registry.npm.taobao
.org --cache-max=0 --no-save</arguments>
</configuration>
</execution>
然后我们就可以打包了,具体的打包命令是
mvn clean install -Dmaven.test.skip=true -Dhadoop.version=2.7.6 -Dmaven.javadoc.skip=true -Dcheckstyle.skip=true -Dlicense.skip=true -Drat.ignoreErrors=true
第三步(启动flink集群)
首先要注意:这里我们的执行路径是flink-blink/flink-dist/target/flink-1.5.1-bin/flink-1.5.1/bin,千万不要在源码中的flink-dist目录中执行。如果执行路径错误会报各种文件找不到的错误,因为打包过程中创建了很多配置文件在target中,所以要在target下执行。
如果是windows执行start-cluster.bat,unix执行start-cluster.sh
启动后可能会有页面403的情况,这是因为flink-runtime-web启动的8081端口被系统占用,我们可以修改flink-blink/flink-dist/target/flink-1.5.1-bin/flink-1.5.1/conf/flink-conf.yaml的rest.port参数来更换flink-runtime-web端口,例如改为8082.现在访问http://localhost:8082就搞定了