Updated on 2022-06-01 GMT+08:00

Flink Client CLI

For details about how to use the Flink CLI, visit https://ci.apache.org/projects/flink/flink-docs-release-1.7/ops/cli.html.

Common CLIs

Common Flink CLIs are as follows:

  1. yarn-session.sh
    • You can run yarn-session.sh to start a resident Flink cluster to receive tasks submitted by clients. Run the following command to start a Flink cluster with three TaskManager instances:
      bin/yarn-session.sh -n 3
    • Run the following command to obtain other parameters of yarn-session.sh:
      bin/yarn-session.sh -help
  2. Flink
    • You can run the flink command to submit a Flink job to a resident Flink cluster or to run the job in single-node mode.
      • The following example command is used to submit a Flink job to a resident Flink cluster:
        bin/flink run examples/streaming/WindowJoin.jar

        Before running this command to submit a job, you need to use yarn-session to start the Flink cluster.

      • The following example command is used to run a job in single-node mode:
        bin/flink run -m yarn-cluster -yn 2 examples/streaming/WindowJoin.jar

        The -m yarn-cluster parameter is used for running the job in single-node mode. -yn indicates the number of TaskManagers.

    • Run the following command to obtain other parameters of the flink command:
      bin/flink --help

Precautions

  • If yarn-session.sh uses -z to configure the specified ZooKeeper namespace, you need to use -yid to specify applicationID and use -yz to specify the ZooKeeper namespace when using flink run. The namespaces must the same.

    Example:

    bin/yarn-session.sh -n 3 -z YARN101 
    bin/flink run -yid application_****_**** -yz YARN101 examples/streaming/WindowJoin.jar 
  • If yarn-session.sh does not use -z to configure the specified ZooKeeper namespace, do not use -yz to specify the ZooKeeper namespace when using flink run.

    Example:

    bin/yarn-session.sh -n 3
    bin/flink run examples/streaming/WindowJoin.jar
  • You can use -yz to specify a ZooKeeper namespace when running flink run -m yarn-cluster to start a cluster.
  • You cannot start two or more clusters at the same time to share one namespace.
  • If you use -z to specify a ZooKeeper namespace when starting a cluster or submitting a job, you need to use -z again to specify the namespace when deleting, stopping, or querying the job or triggering a savepoint.