Skip to content

Instantly share code, notes, and snippets.

@molsches
Forked from jgautsch/mirth_setup.md
Last active January 13, 2024 19:21
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save molsches/322bce27f21b65768f12 to your computer and use it in GitHub Desktop.
Save molsches/322bce27f21b65768f12 to your computer and use it in GitHub Desktop.

NextGen Connect (formerly known as Mirth Connect) Server Setup

Create a VM running Ubuntu. Use a modern version.

Great thanks for the original guide: https://gist.github.com/jgautsch/9157402

# Update Ubuntu
sudo apt-get update

# Upgrade Ubuntu
sudo aptitude upgrade

# Make the ~/downloads folder
mkdir ~/downloads

# Change into ~/downloads/ folder
cd ~/downloads/

# Download the most up to date NextGen  Connect .sh file. You can find this here: [NextGen  Connect Downloads](https://www.nextgen.com/products-and-services/NextGen-Connect-Integration-Engine-Downloads)

curl -O https://s3.amazonaws.com/downloads.mirthcorp.com/connect/4.4.2.b326/mirthconnect-4.4.2.b326-unix.sh

# (Optional) You may want to install nginx to manage SSL, basic auth or to provide multiple DNS endpoints for your NextGen  instance 

sudo apt-get install nginx

# Install the OpenJDK (older versions of NextGen  required the Oracle Java JDK but that is not a requirement on newer versions of NextGen Connect)

sudo apt install openjdk-11-jre-headless

# Set the permissions to be able to run the installer script
sudo chmod a+x ~/downloads/mirthconnect-4.4.2.b326-unix.sh

# Now run the Mirth Connect installer
sudo ~/downloads/mirthconnect-4.4.2.b326-unix.sh

You can hit enter through most of the installer, the defaults are good. There are two hard prompts that you'll need to insert data into -> 

Application data should go in : /opt/mirthconnect/application
Logs should go : /opt/mirthconnect/logs

###Accessing NG Connect Itself

Once Mirth is up and running, you can access it by going to http://yourIPAddress:8080 and following the steps to download the Java Applet. The default username/password is admin/admin and you'll be prompted to change this after your first log in.

###If Mirth stops

Mirth runs as a daemon by default when you start the software. If Mirth stops for whatever reason you can start/stop mirth using mcservice located in the default mirth directory /usr/local/mirthconnect. The format for this is service mcservice start|stop|restart

Moving from Derby to Postgres

You don't need to do this at first, but is necessary for any project at scale. Datica's Mirth runs on HA Postgres boxes.

The default database that Mirth Connect will use is Derby. However, this is not really supposed to be used in production, so we will switch over to good ol' Postgres. Remember that your channels will not transfer between the two databases, so if you did any work on the derby database, make sure to export any channels/message history before performing the cutover.

I've found that Derby usually doesn't scale to more than a few thousand messages or a stream with any amount of real traffic, so installing PG is a must sooner rather than later. Here is a nice intro to installing and using PostgreSQL on Ubuntu

Let's start with a nice update of the apt-get repository:

apt-get update

Next we'll go ahead and download Postgres and its helpful accompanying dependencies:

sudo apt-get install postgresql postgresql-contrib postgresql-client-common

Now postgres is installed.

Prep PostgreSQL for Mirth

By default postgres uses ident authentication, tying each server user to a Postgres account. So to get going we will first switch into the default user, and then create our user and database mirth ("mirth").

$ sudo su - postgres
$ createuser -d -R -P mirth
Enter name of role to add: mirth
Enter password for new role:
Enter it again:
$ sudo -u postgres createdb -O mirth mirth

According to this mirthcorp.com thread, once PostgreSQL is installed and the user/role that we're going to use is created, we just have to update the mirth.properties file with the URL and credentials to the new database and start the server, and that will automatically create the schema for us. The default port for postgres is 5432, so our URL is 0.0.0.0:5432. Our user/pw is whatever we made in the createuser step.

Open up sudo nano /usr/local/mirthconnect/conf/mirth.properties and replace:

database = derby
...
database.url = jdbc:derby${dir.appdata}/mirthdb;create=true

with

database = postgres
...
database.url = jdbc:postgresql://localhost:5432/mirthdb
database.username = mirth
database.password = <YOUR PASSWORD>

If you had used your mirth installation at all thus far, all the stuff you saved is gone with the old database. So when you log in to Mirth Connect, it will be with the default username/pw again (admin:admin), and you will be prompted to change it, and you'll have to re-create any of your channels again.

@Biruk-Abebe-Y
Copy link

Biruk-Abebe-Y commented Aug 20, 2020

I believe, in this example
database.url = jdbc:postgresql://localhost:5432/mirthdb
should be
database.url = jdbc:postgresql://localhost:5432/mirth

because the database created is named "mirth" in the previous step

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment