How to setup or install Apache Flink

Setup or install Apache Flink

Setup or Install Apache Flink – Flink could be setup on the following Operating Systems:

  • Linux
  • Mac OS X
  • Windows

Prerequisites to run Apache Flink

For Flink to run, the environment/machine should have following:

  1. Java 7 (or higher)

How to check if Java is available

To check if java is available, open the command prompt or terminal and enter the following command :

java -version

The output would look like:

Check Java version if available any - Apache Flink Tutorials - Tutorialkart.com

Checking Java availability in PC/Machine using “java -version”

In this case, the machine has Java with version of 1.8.

If the output for the command “java -version” is not as shown in the above image , Java is not installed or the Path to Java executable is not set properly. To setup Java in your machine, please refer How to setup java.

Download a binary of Apache Flink

Once your PC or machine is ready with Java, we have to download a binary of Apache Flink. Prior to download, we have to choose a binary of Apache Flink, based on the requirements. If you have data stored in hadoop, pick one based on the Hadoop version the data is available in. Binaries are available for download at the official download page.

If you don’t require hadoop, any of the binary at the download page should do the job.

For this tutorial, we chose the Hadoop version 2.7 and Scala 2.11 at link.

The download file is over 100MB, so we shall wait for the file to download. Once the binary is download in zip format, unzip and extract the contents.

The contents of the folder should look like the following

Apache Flink folder contents - Setup or Install Apache Flink - Apache Flink Tutorials - TutorialKart.com

Apache Flink folder contents

How to Start a Local Apache Flink Cluster

In Windows : Inside the bin folder, start-local.bat has all the necessary scripts to start the local cluster. To start the local cluster, navigate to /flink-folder>/bin/ folder and open command prompt from the bin folder. Run the command        start-local.bat  . Or just double clicking the start-local.bat file, should start the local cluster.

In Ubuntu : Inside the bin folder, start-local.sh has all the necessary scripts to start the local cluster.

Open the terminal from flink folder and run the command   ./bin/start-local.sh   as shown below:

Start local Flink cluster using command - Apache Flink Tutorials - TutorialKart.com

Start local Flink cluster using command

jobmanger daemon should be started on your PC/machine with a message “Starting jobmanager daemon on host <hostname>”. The jobmanager daemon which is running can be viewed through browser at http://localhost:8081/

Apache Flink jobmanager overview - Apache Flink Tutorials - TutorialKart.com

Apache Flink jobmanager overview

Apache Flink jobmanager overview could be seen in the browser as above.

How to stop Apache Flink local cluster

In Windows, running the command stop-local.bat in the command prompt from the <flink-folder>/bin/ folder should stop the jobmanager daemon and thus stopping the cluster.

In Ubuntu, running the command ./bin/stop-local.sh in the terminal from bin folder should stop the jobmanager daemon and thus stopping the cluster.

Stop Apache Flink Local cluster - Apache Flink Tutorials - TutorialKart.com

Stop Apache Flink Local cluster

So, now we are able to start or stop a stop a flink local cluster, and thus came to the end of the topic setup or install apache flink.

Conclusion

In this tutorial we have seen how to setup or install the apache flink to run as a local cluster. In our next tutorial, we shall observe how to submit a job to the apache flink local cluster.