Hey, Tea Lovers! In this post, we will be talking about how to install 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:

Windows: How to Install Apache Flink On Local Windows

Ubuntu: How to Install Apache Flink On Ubuntu

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 media via @coderstea on TwitterLinkedinFacebook, or Instagram. We also share high-quality videos about programming on our Youtube channel. You can also publish your post on CodersTea, just share your thought on Contact Us or let us know in the comments.


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 set up on 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 on your machine.

Now you can check if the Homebrew is installed successfully on the Mac OS by running the following command.

brew -v

alternatively, you can try help, update instead of -v.

Install Apache Flink on Mac OS with Homebrew

Now that we have set up the Homebrew on the Mac OS, we can install the Flink. To install the Apache Flink on Mac OS via 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.

flink --version

For me, it will be a version 1.12.1, but for you, it may differ. The Apache Flink will be installed on the following path.

/usr/local/Cellar/apache-flink/<your-version-of-flink>/libex

So for me, it is like this

/usr/local/Cellar/apache-flink/1.12.1/libex

I will show how to run the cluster in 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 Apache Flink 1.9.1 then you can simply run the following command.

brew install apache-flink@1.9.1

Keep in mind that, the given old version may or may not be available. So in such a case, you have to rely on the manual installation as described 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.

Select any one from these 2 to Install Flink Mac OS
Select any one from these 2
Flink Download Page to Install Flink Mac OS
Flink Download Page

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 -bin-scala_ the name.

Install Flink windows select binary
Select the binary link in front of the required version

I will be selecting Flink Version 1.7.1 for download. and then select the -bin-scala_ file (without Hadoop as I don’t need it)

For Flink Version 1.7.1
For Flink Version 1.7.1

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,

/Users/imran/Documents/programs/apache-flink/flink-1.12.1

Now let us see how to start and stop the Flink cluster on Mac OS, but before let’s create some shortcuts.

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 you earlier, the Homebrew installation path for me is,

/usr/local/Cellar/apache-flink/1.12.1/libex

export FLINK_PATH='/usr/local/Cellar/apache-flink/1.12.1/libex'

and the Manual Download path for me is,

/Users/imran/Documents/programs/apache-flink/flink-1.12.1

export flink_path='/Users/imran/Documents/programs/apache-flink/flink-1.12.1'

Start the Apache Flink Cluster on Mac OS

In the terminal, run the cluster with the following command.

$FLINK_PATH/bin/start-cluster.sh

If it is successful then you will see a cluster start to message and the cluster will run in the background.

Then simply go to the localhost:8081 to access the Flink UI Dashboard.

Flink Dashboard
Flink Dashboard

Stop the Apache Flink Cluster on Mac OS

To stop the cluster use the following command.

$FLINK_PATH/bin/stop-cluster.sh

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.

Submit and start a new job
Submit and start a new job

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.

Conclusion

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.

Check out 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.

HAKUNA MATATA!!!

You can follow me on social media via @coderstea on TwitterLinkedinFacebook, or Instagram. We also share high-quality videos about programming on our Youtube channel. You can also publish your post on CodersTea, just share your thought on Contact Us or let us know in the comments.

5 comments

Akash September 10, 2021 - 11:22 am

Followed your steps….
I found this error…
can you help me out
no such file or directory: /usr/local/Cellar/apache-flink/1.13.2/libex/bin/start-cluster.sh

Reply
Imran Shaikh
Imran Shaikh September 10, 2021 - 1:49 pm

Is it installed by Homebrew?
Are you sure the path is correct? Can you check if the file is present or not manually?

Reply
Vineet S April 22, 2022 - 10:20 am

change it to libexec

Reply
sripal jain July 1, 2022 - 7:25 am

Iam not able to start the cluster on m1 chip mac
λ streaming $FLINK_PATH/bin/start-cluster.sh
Starting cluster.
Starting standalonesession daemon on host Sripals-MBP.
Starting taskexecutor daemon on host Sripals-MBP.

when i open up localhost:8081 it doesnt show up.
i have tried manual installation without homebrew

Reply
Imran Shaikh
Imran Shaikh July 1, 2022 - 6:11 pm

Hi Sripal, unfortunately, I haven’t got any chance to work upon M1 chip, so I am unfamiliar with your issue.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

TWITTER FEED

INSTRAGRAM FEED

Newsletter

Subscribe my Newsletter for new blog posts, tips & new photos. Let's stay updated!

coderstea-logo-invert
@2022 All Right Reserved. Designed and Developed by CodersTea

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More