当前位置:   article > 正文

创建一个Flink项目_flink quickstart job

flink quickstart job

Flink 环境搭建

下载链接:https://archive.apache.org/dist/flink/flink-1.5.4/

直接下载bin包:flink-1.5.4-bin-hadoop24-scala_2.11.tgz ,解压后启动flink:

  1. jimmy@jimmy-ThinkPad-T420s:~/Downloads/flink-1.5.4/bin$ ./start-cluster.sh
  2. Starting cluster.
  3. Starting standalonesession daemon on host jimmy-ThinkPad-T420s.
  4. Starting taskexecutor daemon on host jimmy-ThinkPad-T420s.

打开WEB:http://127.0.0.1:8081

运行一个example

./bin/flink run ./examples/batch/WordCount.jar

  1. immy@jimmy-ThinkPad-T420s:~/Downloads/flink-1.9.3$ ./bin/flink run ./examples/batch/WordCount.jar
  2. Starting execution of program
  3. Executing WordCount example with default input data set.
  4. Use --input to specify file input.
  5. Printing result to stdout. Use --output to specify output path.
  6. (a,5)
  7. (action,1)
  8. (after,1)
  9. (against,1)
  10. (all,2)
  11. (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

  1. F:\eclipse-workspace\flink>mvn archetype:generate -DarchetypeCatalog=internal -DarchetypeGroupId=org.apache.flink -DarchetypeArtifactId=flink-quickstart-java -DarchetypeVersion=1.5.4
  2. [INFO] Scanning for projects...
  3. [INFO]
  4. [INFO] ------------------< org.apache.maven:standalone-pom >-------------------
  5. [INFO] Building Maven Stub Project (No POM) 1
  6. [INFO] --------------------------------[ pom ]---------------------------------
  7. [INFO]
  8. [INFO] >>> maven-archetype-plugin:3.2.0:generate (default-cli) > generate-sources @ standalone-pom >>>
  9. [INFO]
  10. [INFO] <<< maven-archetype-plugin:3.2.0:generate (default-cli) < generate-sources @ standalone-pom <<<
  11. [INFO]
  12. [INFO]
  13. [INFO] --- maven-archetype-plugin:3.2.0:generate (default-cli) @ standalone-pom ---
  14. [INFO] Generating project in Interactive mode
  15. [WARNING] Archetype not found in any catalog. Falling back to central repository.
  16. [WARNING] Add a repository with id 'archetype' in your settings.xml if archetype's repository is elsewhere.
  17. Define value for property 'groupId': com.company.test.flink
  18. Define value for property 'artifactId': test-flink
  19. Define value for property 'version' 1.0-SNAPSHOT: :
  20. Define value for property 'package' com.company.test.flink: :
  21. Confirm properties configuration:
  22. groupId: com.company.test.flink
  23. artifactId: test-flink
  24. version: 1.0-SNAPSHOT
  25. package: com.company.test.flink
  26. Y: :
  27. [INFO] ----------------------------------------------------------------------------
  28. [INFO] Using following parameters for creating project from Archetype: flink-quickstart-java:1.5.4
  29. [INFO] ----------------------------------------------------------------------------
  30. [INFO] Parameter: groupId, Value: com.company.test.flink
  31. [INFO] Parameter: artifactId, Value: test-flink
  32. [INFO] Parameter: version, Value: 1.0-SNAPSHOT
  33. [INFO] Parameter: package, Value: com.company.test.flink
  34. [INFO] Parameter: packageInPathFormat, Value: com/company/test/flink
  35. [INFO] Parameter: package, Value: com.company.test.flink
  36. [INFO] Parameter: version, Value: 1.0-SNAPSHOT
  37. [INFO] Parameter: groupId, Value: com.company.test.flink
  38. [INFO] Parameter: artifactId, Value: test-flink
  39. [WARNING] CP Don't override file F:\eclipse-workspace\flink\test-flink\src\main\resources
  40. [INFO] Project created from Archetype in dir: F:\eclipse-workspace\flink\test-flink
  41. [INFO] ------------------------------------------------------------------------
  42. [INFO] BUILD SUCCESS
  43. [INFO] ------------------------------------------------------------------------
  44. [INFO] Total time: 28.866 s
  45. [INFO] Finished at: 2020-09-24T17:06:45+08:00
  46. [INFO] ------------------------------------------------------------------------
  47. F:\eclipse-workspace\flink>

Eclipse导入工程

将maven项目转换成eclipse项目:mvn eclipse:eclipse

  1. jimmy@jimmy-ThinkPad-T420s:~/eclipse-workspace/flink/test-flink$ mvn eclipse:eclipse
  2. [INFO] Scanning for projects...
  3. Downloading from central: https://repo.maven.apache.org/maven2/org/eclipse/m2e/lifecycle-mapping/1.0.0/lifecycle-mapping-1.0.0.pom
  4. [WARNING] The POM for org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 is missing, no dependency information available
  5. Downloading from central: https://repo.maven.apache.org/maven2/org/eclipse/m2e/lifecycle-mapping/1.0.0/lifecycle-mapping-1.0.0.jar
  6. [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)
  7. Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-eclipse-plugin/maven-metadata.xml
  8. 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)
  9. Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-eclipse-plugin/2.10/maven-eclipse-plugin-2.10.pom
  10. 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)
  11. Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-eclipse-plugin/2.10/maven-eclipse-plugin-2.10.jar
  12. 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)
  13. [INFO]
  14. [INFO] ---------------------< com.test.flink:test-flink >----------------------
  15. [INFO] Building Flink Quickstart Job 1.0-SNAPSHOT
  16. [INFO] --------------------------------[ jar ]---------------------------------

file->import->maven->existing maven project

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小舞很执着/article/detail/760508
推荐阅读
相关标签
  

闽ICP备14008679号