YUCEL MORAN

YUCEL MORAN


Salesforce and Mulesoft experience

Yucel
Author

Share


Subscribe to YUCEL MORAN


Subscribe to our email newsletter to receive article notifications and regular updates. We don't spam and your email won't be shared with third-parties.

Tags


YUCEL MORAN

How to install Mulesoft runtime 3.9.1 on Ubuntu 16.04

YucelYucel

I've been using Anypoint Platform for 3 + years now, at the beginning I was only familiar on how to deploy my applications directly to CloudHub which was enough at that time for the work I did.

Eventually,  I needed tot make use of own servers where I needed to install Mulesoft runtime in order to take advantage of custom memory and disk size. So basically on  this tutorial, I will try to explain what steps I took in order to complete a full installation of the  runtime.

So first, I got an AWS Server with Ubuntu 16.04, 120 GB on disk and 16GB memory, these settings based on performance requirements  for applications what consumes a lot of memory transforming data in general.

Once we have the machine,  we can follow the next steps:

Install JAVA, personally I always like how Digital Ocean makes their tutorials, they explain step by step how to achieve installations of any kind, so in my flow I check this tutorial from them: https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04

Installing the Default JRE/JDK

The easiest option for installing Java is using the version packaged with Ubuntu. Specifically, this will install OpenJDK 8, the latest and recommended version.

First, update the package index.

sudo apt-get update

Next, install Java. Specifically, this command will install the Java Runtime Environment (JRE).

sudo apt-get install default-jre

There is another default Java installation called the JDK (Java Development Kit). The JDK is usually only needed if you are going to compile Java programs or if the software that will use Java specifically requires it.

The JDK does contain the JRE, so there are no disadvantages if you install the JDK instead of the JRE, except for the larger file size.

You can install the JDK with the following command:

sudo apt-get install default-jdk

Installing the Oracle JDK

If you want to install the Oracle JDK, which is the official version distributed by Oracle, you will need to follow a few more steps.

First, add Oracle's PPA, then update your package repository.

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

Then, depending on the version you want to install, execute one of the following commands:

Oracle JDK 8

This is the latest stable version of Java at time of writing, and the recommended version to install. You can do so using the following command:

sudo apt-get install oracle-java8-installer

Oracle JDK 9

This is a developer preview and the general release is scheduled for March 2017. It's not recommended that you use this version because there may still be security issues and bugs. There is more information about Java 9 on the official JDK 9 website.

To install JDK 9, use the following command:

sudo apt-get install oracle-java9-installer

Managing Java

There can be multiple Java installations on one server. You can configure which version is the default for use in the command line by using update-alternatives, which manages which symbolic links are used for different commands.

sudo update-alternatives --config java

The output will look something like the following. In this case, this is what the output will look like with all Java versions mentioned above installed.

Output

There are 5 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      auto mode
  1            /usr/lib/jvm/java-6-oracle/jre/bin/java          1         manual mode
  2            /usr/lib/jvm/java-7-oracle/jre/bin/java          2         manual mode
  3            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode
  4            /usr/lib/jvm/java-8-oracle/jre/bin/java          3         manual mode
  5            /usr/lib/jvm/java-9-oracle/bin/java              4         manual mode

Press <enter> to keep the current choice[*], or type selection number:

You can now choose the number to use as a default. This can also be done for other Java commands, such as the compiler (javac), the documentation generator (javadoc), the JAR signing tool (jarsigner), and more. You can use the following command, filling in the command you want to customize.

sudo update-alternatives --config command

Setting the JAVA_HOME Environment Variable

Many programs, such as Java servers, use the JAVA_HOME environment variable to determine the Java installation location. To set this environment variable, we will first need to find out where Java is installed. You can do this by executing the same command as in the previous section:

sudo update-alternatives --config java

Copy the path from your preferred installation and then open /etc/environment using nano or your favorite text editor.

sudo nano /etc/environment

At the end of this file, add the following line, making sure to replace the highlighted path with your own copied path.

/etc/environment

JAVA_HOME="/usr/lib/jvm/java-8-oracle"

Save and exit the file, and reload it.

source /etc/environment

You can now test whether the environment variable has been set by executing the following command:

echo $JAVA_HOME

This will return the path you just set.

PREPARING MULE RUNTITME IN THE VM MACHINE

After java is installed then we can proceed with Download Mulesoft runtime, you can get a copy of Mule 3.9.1 from here, upload  the file into the VM machine   using any SSH application for file transfer.

Now, from terminal access to  your vm via SSH, and locate the mule391  that  we just uploaded in  my  case is under /mule/391

Here's how I think about the folder content:

/mule/mule391/bin - This keeps all important binary files, the  ones that  make mulesoft runtime to work properly.  also this folder is the one that has the src/main/resources  folder,  meaning that if you are downloading files or generating file, will be  stored here.


/mule/mule391/conf - This folder has all configuration  files we need, this allow tot customize how mule work in your server,  depending of the hardware you can set multiple options. Mainly the file we use to set those options is the wrapper.config file.


/mule/mule391/logs - Store  all  logs separated by application  name, for example (my-mule-app.log)  you cans stream the content of  this file from terminal using this command

$. sudo tail -f my-mule-application.log

From this point the runtime is ready, uploading  and running the runtime just like this will  allow you  to use it for a month, so if you get a mulesoft subscription  you  need to make sure su have a core for this server because then mulesoft will provide a .lic file that  you need to install (https://docs.mulesoft.com/mule-runtime/4.2/installing-an-enterprise-license)

CONNECT MY SERVER TO RUNTIME MANAGER.

Runtime Manager, allows you basically to monitor and see metrics from your applications, even CloudHub or custom (Hybrid) ones.  In order to see our server we need to follow this steps:

  1. Login into AnyPoint Platform (https://anypoint.mulesoft.com) you can create a trial account if you want to test all functionality.
  2. Select Runtime Manager from the Menu  on  the left and  then clic on "Servers" this will load the servers already created in case you have some already

On  the top right  we should see  a button  "Add Server",  clic on it   and then you should get  a command that  you need to copy in  order to  use it in your server

Go back in  your terminal, and locate the mule391 folder, and get into the /bin  folder, the path should be  something like this /mule/mule391/bin.

In there you jus need to past the  command you copied from runtime Manager

$.sudo ./amc_setup -H 321de965-c640-40e6-a1f2-2d66fb2e3006---36771 mulesoft-prod-001

this will install the communication  between your server and  Runtime Manager.  You can  see the server created in  your environment

From the terminal now go into the bin folder  (/mule/mule391/bin/). So now we  can  start mule, use  this command

sudo ./mule start -M-Denv=production

the -M-Denv option lets me to specify the environment variable I want to use,  basically we are telling the server what environment is. you can add more variables like the marterkey to decrypt properties files etc.

After the commnad is executed you should  see your server running in Runtime Manager

So now you have your server ready  to deploy applications, in another post we should explain how to deploy manually selecting a compressed project file and later how to do the same using maven.

Hopefully this gives you an idea on how easy is to set the full environment, overal after a few times to do it, it will take around 30 mins to 1 hour to get working.

Yucel
Author

Yucel

View Comments