Flink 环境搭建
下载链接https://archive.apache.org/dist/flink/flink-1.5.4/
直接下载bin包flink-1.5.4-bin-hadoop24-scala_2.11.tgz 解压后启动flink
jimmyjimmy-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.
打开WEBhttp://127.0.0.1:8081
运行一个example
./bin/flink run ./examples/batch/WordCount.jar
immyjimmy-ThinkPad-T420s:~/Downloads/flink-1.9.3$ ./bin/flink run ./examples/batch/WordCount.jarStarting execution of programExecuting 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 -DarchetypeCataloginternal -DarchetypeGroupIdorg.apache.flink -DarchetypeArtifactIdflink-quickstart-java -DarchetypeVersion1.5.4
F:\eclipse-workspace\flink>mvn archetype:generate -DarchetypeCataloginternal -DarchetypeGroupIdorg.apache.flink -DarchetypeArtifactIdflink-quickstart-java -DarchetypeVersion1.5.4[INFO] Scanning for projects...[INFO][INFO] -------------------------------------[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项目转换成eclipse项目mvn eclipse:eclipse jimmyjimmy-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 availableDownloading 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.xmlDownloaded 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.pomDownloaded 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.jarDownloaded 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] -------------------------------------------[INFO] Building Flink Quickstart Job 1.0-SNAPSHOT[INFO] --------------------------------[ jar ]--------------------------------- file->import->maven->existing maven project Eclipse导入工程