命令1: bin/flink run -m yarn-cluster -yn 2 -yjm 2048 -ytm 5120 ./examples/batch/WordCount.jar --input hdfs://nameservice1/user/root/test/LICENSE --output hdfs://nameservice1/user/root/test/result4.txt
以下是给定命令的各参数含义:
bashCopy code
bin/flink run -m yarn-cluster -yn 2 -yjm 2048 -ytm 5120 ./examples/batch/WordCount.jar --input hdfs://nameservice1/user/root/test/LICENSE --output hdfs://nameservice1/user/root/test/result4.txt
bin/flink run: 启动 Flink 作业提交脚本。-m yarn-cluster: 指定 Flink 作业运行在 YARN 集群上的集群模式。这表示作业将由 YARN 管理。-yn 2: 指定作业需要的 TaskManager 数量。在这里,作业将使用 2 个 TaskManager 运行。-yjm 2048: 指定 JobManager 的内存大小为 2048 MB。这是 JobManager 运行时使用的内存。-ytm 5120: 指定每个 TaskManager 的内存大小为 5120 MB。这是每个 TaskManager 运行时使用的内存。./examples/batch/WordCount.jar: 指定要提交的 Flink 作业的 JAR 文件路径。在这里,使用 WordCount 示例作业。--input hdfs://nameservice1/user/root/test/LICENSE: 指定作业的输入参数,即 WordCount 示例中的输入文件路径。--output hdfs://nameservice1/user/root/test/result4.txt: 指定作业的输出参数,即 WordCount 示例中的输出文件路径。
总体而言,这个命令是在 YARN 集群上以集群模式提交一个 Flink 作业,使用 2 个 TaskManager,设置 JobManager 内存为 2048 MB,每个 TaskManager 内存为 5120 MB,执行 WordCount 示例作业,将输入文件从 HDFS 中读取,并将结果写入到指定的 HDFS 输出文件中。
命令2: ./bin/flink run ./examples/batch/WordCount.jar --input hdfs://nameservice1/user/root/test/LICENSE --output hdfs://nameservice1/user/root/test/result.txt 以下是给定命令的各参数含义:
bashCopy code
./bin/flink run ./examples/batch/WordCount.jar --input hdfs://nameservice1/user/root/test/LICENSE --output hdfs://nameservice1/user/root/test/result.txt
./bin/flink run: 启动 Flink 作业提交脚本。./examples/batch/WordCount.jar: 指定要提交的 Flink 作业的 JAR 文件路径。在这里,使用 WordCount 示例作业。--input hdfs://nameservice1/user/root/test/LICENSE: 指定作业的输入参数,即 WordCount 示例中的输入文件路径。--output hdfs://nameservice1/user/root/test/result.txt: 指定作业的输出参数,即 WordCount 示例中的输出文件路径。
总体而言,这个命令是在本地模式下提交一个 Flink 作业,执行 WordCount 示例作业,将输入文件从 HDFS 中读取,并将结果写入到指定的 HDFS 输出文件中。
对于 hadoop fs -cat /user/root/test/result.txt 命令:
hadoop fs: 是 Hadoop 的文件系统命令,用于执行文件系统操作。-cat: 是cat命令的 Hadoop 文件系统版本,用于查看文件的内容。/user/root/test/result.txt: 是要查看的文件路径,即 WordCount 示例中输出的结果文件。