Flink 环境搭建
下载链接:https://archive.apache.org/dist/flink/flink-1.5.4/
直接下载bin包:flink-1.5.4-bin-hadoop24-scala_2.11.tgz ,解压后启动flink:
jimmy@jimmy-ThinkPad-T420s:~/Downloads/flink-1.5.4/bin$ ./start-cluster.sh
Starting cluster.
Starting standalonesession daemon on host jimmy-ThinkPad-T420s.
Starting taskexecutor daemon on host jimmy-ThinkPad-T420s.
打开WEB:http://127.0.0.1:8081
运行一个example
./bin/flink run ./examples/batch/WordCount.jar
immy@jimmy-ThinkPad-T420s:~/Downloads/flink-1.9.3$ ./bin/flink run ./examples/batch/WordCount.jar
Starting execution of program
Executing WordCount example with default input data set.
Use --input to specify file input.
Printing result to stdout. Use --output to specify output path.
(a,5)
(action,1)
(after,1)
(against,1)
(all,2)
(and,12)
注:如果example运行不成功,应该是jdk版本不匹配导致
mvn 产生一个flink项目框架
flink版本1.5.4
mvn archetype:generate -DarchetypeCatalog=internal -DarchetypeGroupId=org.apache.flink -DarchetypeArtifactId=flink-quickstart-java -DarchetypeVersion=1.5.4
F:\eclipse-workspace\flink>mvn archetype:generate -DarchetypeCatalog=internal -DarchetypeGroupId=org.apache.flink -DarchetypeArtifactId=flink-quickstart-java -DarchetypeVersion=1.5.4
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.2.0:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.2.0:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO]
[INFO] --- maven-archetype-plugin:3.2.0:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[WARNING] Archetype not found in any catalog. Falling back to central repository.
[WARNING] Add a repository with id 'archetype' in your settings.xml if archetype's repository is elsewhere.
Define value for property 'groupId': com.company.test.flink
Define value for property 'artifactId': test-flink
Define value for property 'version' 1.0-SNAPSHOT: :
Define value for property 'package' com.company.test.flink: :
Confirm properties configuration:
groupId: com.company.test.flink
artifactId: test-flink
version: 1.0-SNAPSHOT
package: com.company.test.flink
Y: :
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: flink-quickstart-java:1.5.4
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.company.test.flink
[INFO] Parameter: artifactId, Value: test-flink
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.company.test.flink
[INFO] Parameter: packageInPathFormat, Value: com/company/test/flink
[INFO] Parameter: package, Value: com.company.test.flink
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: com.company.test.flink
[INFO] Parameter: artifactId, Value: test-flink
[WARNING] CP Don't override file F:\eclipse-workspace\flink\test-flink\src\main\resources
[INFO] Project created from Archetype in dir: F:\eclipse-workspace\flink\test-flink
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 28.866 s
[INFO] Finished at: 2020-09-24T17:06:45+08:00
[INFO] ------------------------------------------------------------------------
F:\eclipse-workspace\flink>
Eclipse导入工程
将maven项目转换成eclipse项目:mvn eclipse:eclipse
jimmy@jimmy-ThinkPad-T420s:~/eclipse-workspace/flink/test-flink$ mvn eclipse:eclipse
[INFO] Scanning for projects...
Downloading from central: https://repo.maven.apache.org/maven2/org/eclipse/m2e/lifecycle-mapping/1.0.0/lifecycle-mapping-1.0.0.pom
[WARNING] The POM for org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 is missing, no dependency information available
Downloading from central: https://repo.maven.apache.org/maven2/org/eclipse/m2e/lifecycle-mapping/1.0.0/lifecycle-mapping-1.0.0.jar
[WARNING] Failed to retrieve plugin descriptor for org.eclipse.m2e:lifecycle-mapping:1.0.0: Plugin org.eclipse.m2e:lifecycle-mapping:1.0.0 or one of its dependencies could not be resolved: Could not find artifact org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 in central (https://repo.maven.apache.org/maven2)
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-eclipse-plugin/maven-metadata.xml
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-eclipse-plugin/maven-metadata.xml (741 B at 491 B/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-eclipse-plugin/2.10/maven-eclipse-plugin-2.10.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-eclipse-plugin/2.10/maven-eclipse-plugin-2.10.pom (19 kB at 18 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-eclipse-plugin/2.10/maven-eclipse-plugin-2.10.jar
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-eclipse-plugin/2.10/maven-eclipse-plugin-2.10.jar (224 kB at 108 kB/s)
[INFO]
[INFO] ---------------------< com.test.flink:test-flink >----------------------
[INFO] Building Flink Quickstart Job 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
file->import->maven->existing maven project