How to run Mule on the Raspberry Pi. You’d be shock how easy it is!
If you follow me on LinkedIn, you’d have come across a few of my post of some simple hacks I’ve done using popular apps like Twitter and Telegram chatbot, all running of the Raspberry Pi. And since I work at MuleSoft, it’s only natural that I would use the Mule runtime as the core framework for the app development since it’s mostly a connectivity-based app. But before I digress further, I obviously need to first get Mule to be able to run on the Raspberry Pi. Here in this guide, you would see how easy it is to install the full enterprise edition of Mule. Not only that, you’d also see how you can manage and monitor the mule runtime on the Raspberry Pi it from the cloud using the Anypoint Runtime Manager!
A beginners guide to run Mule on the Raspberry Pi
Note that in this guide, the instructions would be based on using the MacOS as the primary host connecting to the Raspberry Pi via SSH on Terminal. If you’re using a Linux host or using Putty on a Windows machine, the general steps are the same but perhaps some different methods or commands that you’d need to use. Additionally, this guide is also based on the Enterprise Edition version of Mule Runtime which requires a license to run. You’re also allowed to run a 30-days trial of the EE runtime for R&D and testing purposes too. You can reach out to me or a local MuleSoft representative for more information on licensing of Mule.
1. Get the Raspberry Pi running with Raspbian
Firstly, assuming you have not already done so, you will need to install Raspbian on your Raspberry Pi. There are a lot of guides online including the official guide here to help you set it up. Once you’ve done so, boot up the Raspberry Pi with Raspbian and you’re pretty much ready to go. And guess what, there is nothing else you need to do or install on your Raspberry Pi or Raspbian to prepare it to run Mule, even with the enterprise edition version of Mule. Kinda awesome if you ask me.
Having said that, its always good to get Raspbian updated with the regular sudo apt-get update && sudo apt-get upgrade.
2. Copy the Mule EE installation file and the license file to your Raspberry Pi
Again, I assume that you’ve already downloaded the Mule EE installation file. I’m using the latest version of the Mule EE binary (typically named mule-ee-distribution-standalone-3.8.1.tar.gz). I also assume you have a valid license file to be copied over to the Raspberry Pi. I used SCP to copy the files to the Raspberry Pi.
scp /<path-to-file>/mule-ee-distribution-standalone-3.8.1.tar.gz pi@<ip-address-rpi>:mule-ee-distribution-standalone-3.8.1.tar.gz
You would then be prompted to key in the password for the pi user on the Raspberry Pi and the file would be copied over. Remember to replace the <path-to-file> and <ip-address-rpi> appropriately in the command. 😄
Do the same with the Mule Enterprise Edition license file.
scp /<path-to-file>/mule-ee-license.lic pi@<ip-address-rpi>:mule-ee-license.lic
3. Installing the Mule EE installation file
If you are already familiar with the installation process of Mule Enterprise Edition, it’s no different here on the Raspberry Pi. That’s really the beauty of the lightweight nature of Mule. For those new to the Mule platform, behold how simple the installation process is. Ready? Just extract the tar archive and that’s it. Yes. It’s really that simple! 😄
tar -xvf mule-ee-distribution-standalone-3.8.1.tar.gz
In the screenshot, you see that I’ve installed the Mule Runtime in a mule subdirectory, but that’s entirely up to your preference.
4. Lowering the default RAM allocation in the wrapper configuration
By default, the wrapper is configured to allocated 1GB of RAM for the JVM. This is obviously too much since the Raspberry Pi has limited RAM. Both the Raspberry Pi version 2 and 3 are equipped with 1GB of RAM, so I recommend configuring the wrapper to allocated a maximum of 512MB of RAM for Mule’s JVM.
To do so, edit the wrapper.conf file that is located in mule-enterprise-standalone-3.8.1/conf/
Scroll down the file and look for the Java Heap Size configuration.
Edit them both the configuration to 512 MB as shown below:-
# Initial Java Heap Size (in MB)
# Maximum Java Heap Size (in MB)
Once done, WriteOut (ctrl+O) and Exit (ctrl+X).
5. Install the license file and setup the Mule Agent to connect to ARM
If you have a valid license file, run the following command to install the license. Otherwise, you can skip this step and use the Mule runtime with a 30 days trial license that will be autogenerated upon the first run of the Mule Server.
Now, let’s also set up the runtime to be managed directly from the cloud using the Anypoint Platform’s Runtime Manager console. If don’t already have an Anypoint Platform ID, you can sign up for one here at https://anypoint.mulesoft.com/login/#/signup. Don’t worry. It’s free and comes with a 30-days trial for all the non-free components! Head over to the Runtime Manager console and click on the Servers tab, then click on the Add Server button.
Copy the generated “./amc_setup …..—12345 server-name” command. This will instruct the Mule Agent in the runtime to connect and register itself to your Anypoint Platform account. First, get into the /bin directory of Mule Server.
Here, paste the amc_setup command you copied and remember to change the server-name in the command to any name you prefer.
Once completed, you should see a new Server with the name you provided registered in the Runtime Manager.
6. Finally, start Mule!
Yes, that’s all there is to it. Now you can start up Mule and begin to manage it directly from the Runtime Manager in the cloud. This includes deploying and monitoring your Mule applications too.
Again, for those new to Mule, you can start Mule simply by using the following command: –
The “start” paramenter starts the Mule server in the terminal background. You can find out more about starting and stopping Mule here. If you want to know what’s happening in the server, you can simply tail the log files using the following command: –
tail -f ../logs/mule_ee.log
As soon as the server starts up, the Runtime Manager console will display the server’s status as Running. And now, you can start to monitor and manage the Mule runtime just as any other on-premise Mule Servers in an enterprise datacenter.
That’s it! I hope this guide has been useful to you and can’t wait to see the kind of interesting IoT projects you run using Mule at the edge.