Over a million developers have joined DZone.

Running Mule 4 on Raspberry Pi

DZone's Guide to

Running Mule 4 on Raspberry Pi

While a real mule running on a raspberry pi(e) would just be sad, running MuleSoft on this great IoT platform is a lot of fun!

· IoT Zone ·
Free Resource

What an amazing time it is! MuleSoft recently announced a major milestone: the GA release of Mule 4! The new release of Mule is all about ease of use and accelerating the speed of development. With up to 50% fewer steps and concepts to learn, Mule introduces a lower learning curve to jumpstart integration projects with better access to data and a completely new reactive, non-blocking (and self-tuning) runtime engine!

Mule runtime can be installed on a wide range of hardware, ranging from IoT devices to high-end mainframes. In this post, we will look at the very bottom of this spectrum: the low-cost Raspberry Pi single-board computer.

While there are plenty of blog posts and technical articles on running Mule on the Pi, the timing of this post could not be better for a new post because, in addition to the recent launch of Mule 4, the Raspberry Pi Foundation also released a new model. The new Raspberry Pi 3 B+ features better performance and has onboard WiFi, among other exciting improvements.

Since Raspberry Pi is a low-cost computer, it can easily be used for building IoT or embedded solutions. The Pi was designed for expansion and can be equipped with various sensors, such as a motion sensor, temperature sensor, light sensor, a camera, a barcode scanner (just to name a few). This is why it only makes sense to pair it with a power integration solution to collect sensor data from hundreds of Pi’s in a large warehouse or to use it to light a LED bulb. So let’s have a look at what it takes to get Mule 4 running.

Getting Started

In order to install and run Mule 4 on the Raspberry Pi, you need the following items:

Note that an active internet access is required for downloading packages and installation files.

To learn more, the Raspberry Pi Foundation provides excellent documentation on setting up your Pi device, we will not cover this topic in this blog post.

Preparing the Raspberry Pi

Before we can actually run Mule runtime, it is recommended we properly prepare the Pi to make sure Mule can run smoothly.

Step 1: Enabling Remote Access

First, we need to enable SSH (secure shell) for remote access and file transport to the Raspberry Pi via the raspi-config utility. Remote access is needed for deploying applications to the runtime or adding Mule runtime to Anypoint Runtime Manager.

pi@raspberrypi:~ $ sudo raspi-config 

  • Select "5 Interfacing Options"
  • Select "P2 SSH"
  • Select “<Yes>”, then “<OK>”, and finally “<Finish>”.

Step 2: Installing a Java SDK

Mule runtime requires a certified Java installation, but the Raspbian operating system does not come with Java out-of-the-box. The next step is to install Java:

pi@raspberrypi:~ $ sudo apt-get update 

pi@raspberrypi:~ $ sudo apt-get install oracle-java8-jdk 

Step 3: Creating a User (Optional)

The next step is optional but highly recommended: creating a new user (simply named mule) for installing and running Mule runtime. A password must be set before the new user can log in. We will also create a home directory (/home/mule) for the new user and a directory for installing Mule (/opt/mule).

pi@raspberrypi:~ $ sudo su -

root@raspberrypi:~ $ useradd -s /bin/bash -d /home/mule -U -G sudo mule

root@raspberrypi:~ $ passwd mule

Enter new UNIX password:

Retype new UNIX password:

passwd: password updated successfully

root@raspberrypi:~ $ mkdir /home/mule /opt/mule

root@raspberrypi:~ $ chown mule:mule /opt/mule

At this point we should switch to the user 'mule.' Enter the password you set earlier when prompted to do so.

root@raspberrypi:~ $ exit

pi@raspberrypi:~ $ su - mule


Step 4: Installing Mule Runtime

Now we can download and unzip Mule runtime using the ‘wget’ command.

mule@raspberrypi:~ $ cd /opt/mule 

mule@raspberrypi:/opt/mule $ wget https://repository-master.mulesoft.org/nexus/content/repositories/releases/org/mule/distributions/mule-standalone/4.1.1/mule-standalone-4.1.1.tar.gz

Depending on your Internet connection speed, this may take some time. Once the download is complete, extract the downloaded file using the ‘tar’ command.

mule@raspberrypi:/opt/mule $ tar zxf mule-standalone-4.1.1.tar.gz 

Mule runtime uses the Tanuki Service Wrapper, which allows a Java-based application (that’s right, such as Mule runtime) to be started as a Windows Service or UNIX daemon. However, out-of-the-box, the bundled Service Wrapper is not optimized for Raspberry Pi’s ARM architecture. Therefore, the next step is to download the Armhf port of the Java Service Wrapper and patch the bundled Service Wrapper by copying a few required files to the Mule runtime directory.

mule@raspberrypi:/opt/mule $ wget https://download.tanukisoftware.com/wrapper/3.5.34/wrapper-linux-armhf-32-3.5.34.tar.gz

tar zxf wrapper-linux-armhf-32-3.5.34.tar.gz

mule@raspberrypi:/opt/mule $ cp ./wrapper-linux-armhf-32-3.5.34/lib/libwrapper.so ./mule-standalone-4.1.1/lib/boot/libwrapper-linux-armhf-32.so

mule@raspberrypi:/opt/mule $ cp ./wrapper-linux-armhf-32-3.5.34/lib/wrapper.jar ./mule-standalone-4.1.1/lib/boot/wrapper-3.2.3.jar

mule@raspberrypi:/opt/mule $ cp ./wrapper-linux-armhf-32-3.5.34/bin/wrapper ./mule-standalone-4.1.1/lib/boot/exec/wrapper-linux-armhf-32

The next step is to modify Mule’s startup script to support the Armhf architecture. To do this, open $MULE_HOME/bin/mule in a text editor, for example Vi.

mule@raspberrypi:/opt/mule $ cd ./mule-standalone-4.1.1/bin

mule@raspberrypi:/opt/mule/mule-standalone-4.1.1/bin $ vi mule

Search for the section with the line ‘case "$PROC_ARCH" in’. Hint: it is around line 238.

Add the following lines of code:


echo "Armhf architecture detected"




The final step is to modify Mule’s configuration file, wrapper.conf, to deal with the limited memory size of the Raspberry Pi. By default, Mule is configured to use 1 GB of memory, but the new model 3B+ only has 1 Gb of RAM in total that it needs to share with the OS and other processes, and SWAP is limited and slow on most MicroSD’s.

mule@raspberrypi:/opt/mule/mule-standalone-4.1.1/bin $ cd ../conf

mule@raspberrypi:/opt/mule/mule-standalone-4.1.1/conf $ vi wrapper.conf

Search for the configuration items wrapper.java.initmemory and wrapper.java.maxmemory. Change the original values of 1024 into lower values, such as (maxing out to 512Mb):

# Initial Java Heap Size (in MB)


# Maximum Java Heap Size (in MB)


Save the changes and start the Mule runtime.

mule@raspberrypi:/opt/mule/mule-standalone-4.1.1/conf $ cd ../bin

mule@raspberrypi:/opt/mule/mule-standalone-4.1.1/bin $ ./mule

Mule 4 will now start without any issues.


With a bit of configuration, Mule 4 runs just fine on the low-cost Raspberry Pi device. The powerful combination of those two provides us with a great platform for building IoT solutions.

To simplify the installation of Mule ever further, we can automate the installation steps. I created a shell script that contains all the required steps. The script can be downloaded and run in a single step. So go out, get a Raspberry Pi and Raspbian, and run this command as the default user (pi):

pi@raspberrypi:~ $ wget -O - https://raw.githubusercontent.com/rajprins/mule-rpi/master/install-mule4CE.sh | bash

Happy hacking!

mule 4 ,raspberry pi 3 ,iot

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}