Hey, Tea Lovers! In this post, we will be talking about how to install the Apache Flink on Mac OS. It will be a very quick guide We will be installing the latest version of Apache Flink 1.12.1, though it applies to all the versions and possibly any newer one too.
We have other posts on Flink Installation:
I will be showing two ways, one with the Homebrew, and the other one using the manual download, as we did for the Windows one.
You can follow me on social @coderstea on Twitter, Linkedin, Facebook, or Instagram. We will be sharing the high-quality videos about programming on our Youtube channel very soon. You can also publish your own post on CodersTea.com, just share your thought on Contact Us.
Requirements to Install Apache Flink on Mac OS
The must-have requirement to install the Flink on Mac OS is Java. Be it Java 8 or Java 11. And along with that, you need to make sure that you have the variable JAVA_HOME set.
How to Install Apache Flink On Mac OS via Homebrew
How to Install Homebrew on Mac OS
For the installation using Homebrew, you will need a Homebrew setup in your machine. If it’s not set up in your mac os machine, MacBook or iMac, you can go to Homebrew’s official site Homebrew, and follow the instruction on the page. It would only be to run the following command.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
And this will install the latest Homebrew in yuur machine.
Now you can check if the Homebrew is installed successsfully on the Mac OS by runnign the following command.
or alternatively you can try
update instead of
Install Apache Flink on Mac OS with Homwbrew
Now that we have setup the Homebrew on the Mac OS, we can install the Flink. To install the Apache Flink on Mac OS via the Homebrew, you need to run the following command.
brew install apache-flink
Then check if it is installed or not, you can type the version command as follows.
For me, it will be version
1.12.1, but for you, it may differ. The Apache Flink will be installed on the following path.
So for me it is like this
I will show how to run the cluster on this post’s last paragraph.
Install Old Stable Apache Flink on Mac OS via Homebrew
To install older releases of the Apache Flink, you can simply add the version number in the command. For example, if you want to install the Apache Flink 1.9.1 then you can simply run the following command.
brew install [email protected]
Keep in mind that, the given old version may or may not be available. So in such case you have to rely on the manual installation as describe in the following blocks.
Install Apache Flink on Mac OS Manually
If you don’t want to use Homebrew, no worries, you can always choose the long way. In this case, you can manually download and run the Apache Flink on Mac OS.
Download the Apache Flink for Mac OS
I will be installing Apache Flink version 1.2.1 for this post. To get the list of all Flink binaries available to download, head over to this link. Select the version you want to choose and download.
Download Old Stable Apache Flink Release for Mac OS
For the latest release, we can just look in the first paragraph for the link. But for the old release such as Flink Version 1.7.1, you need to select from the old stable release list present on the same page. From the list select the binaries in front of the desired version and then download a binary file that contains the
-bin-scala_ in the name.
I will be selecting the Flink Version 1.7.1 for download. and then select the
-bin-scala_ file (without Hadoop as I don’t need it)
Now that we have downloaded the Apache Flink binaries, let’s extract the tar file and copy it to a more appropriate location, any location would be fine. For me, it would be,
Start and Stop Apache Flink Cluster on Mac OS
Now let us see how to start and stop the Flink cluster on Mac OS, but before lets create some shortcut.
Set up Environment Variable for Apache Flink Path
Homebrew and Manual Apache installation use different paths on the machine. To simplify the procedure let’s make an environment variable with the path.
In the file .bash_profile for Bash or .zshrc file for ZSH, you can add the following line.
export FLINK_PATH='Full path of apache Flink'
As I told earlier, the Homebrew installation path for me is,
and for the Manual Download path for me is,
Start the Apache Flink Cluster on Mac OS
In the terminal, run the cluster with following command.
If it is successful then you will see a cluster started message and the cluster will run in the background.
Then simply go to the localhost:8081 to access the Flink UI Dashboard.
Stop the Apache Flink Cluster on Mac OS
To stop the cluster use the following command.
Run a Flink Job on Cluster
There are 2 ways you can run a Flink Job on the cluster. UI and via command.
Run Flink Job via Flink Dashboard
The simplest way is to use the UI. First, in the dashboard, go to the Submit New Job page and upload the Jar. Next, select the Jar from the list, and pass the Main class, the argument of the program. Then, submit the job and it will redirect you to the running job page, where you will see the pipelines and their status.
Run a Flink Job via Terminal
The second way is to run it via Terminal or Command-Line. You can use the following command to run the Flink Job.
$FLINK_PATH/bin/flink run \ --detached \ /path/to/jar/SampleFlinkJob.jar
This will run the Flink job in the background. You can then check the status in the Flink Dashboard, on localhost, if it runs successfully.
That’s it for this post. This post is focused on Flink Version 1.12.1 and running it on Mac OS. We looked at both the Homebrew shortcut installation and the Manual installation. Keep in mind to set up the JAVA_HOME properly and make sure the JAVA_HOME path doesn’t contain any space in it.
Checkout the post “How to Install Apache Flink On Local Windows“
You can also check out my other post “How to Select Specific Folders or Files As Input in Flink” and the code is on GitHub.
See you in the next post.