Metabase Logo
SHARE:

Metabase Installation on Digital Ocean – Ubuntu 20.04

Spread the love
Reading Time: 3 minutes

You may have seen recently that the metabase droplet is longer on the digital ocean marketplace. Given that Metabase is such a useful tool I will show how to do it on digital ocean. This will work on other hosts too, just make sure you have a ubuntu server.

Step 1) Database Setup

One of the easiest ways to start is by setting up a digital ocean database cluster. I’m using postgres flavour but you can use others. These are the settings used but you must choose the same datacenter you want your application to be in.

You can also host your prod data within this cluster, just make sure you choose the cluster plan that’s right for you.

For security purposes make sure that your database cluster is IP restricted.

Step 2) Metabase Droplet Setup

I’m going to be using a simple Ubuntu 20.04 droplet to set metabase up with as it’s the most recent. These are the settings I used but please be advised metabase will run slower on cheaper instances. But for smaller projects the cheaper plan should be enough. Again make sure that they’re in the same datacenter.

Metabase droplet setup screen

Step 3) Add Trusted Source

Now you’ve made your droplet you can simply go back to your database cluster overview, click edit sources in the trusted sources section and add your droplet.

Add metabase to trusted sources

Step 4) Install Metabase with Systemd

This section is a more brief version of this tutorial with a few additions for remote DB connections and what actually worked for me.

Install Java 11 onto the server:

sudo apt -y install openjdk-11-jdk openjdk-11-jre

Download Metabase onto the server:

wget https://downloads.metabase.com/v0.40.3.1/metabase.jar
sudo mkdir -p /apps/java
sudo mv metabase.jar /apps/java

Setup the permissions:

sudo groupadd -r appmgr
sudo useradd -r -s /bin/false -g appmgr appmgr
sudo chown -R appmgr:appmgr /apps/java

Make the service:

sudo nano /etc/systemd/system/metabase.service

Paste this then change your DB credentials and your memory limits ( -Xms128m -Xmx256m):

[Unit]
Description=Metabase application service
Documentation=https://www.metabase.com/docs/latest

[Service]
WorkingDirectory=/apps/java
Environment=MB_DB_TYPE=postgres
Environment=MB_DB_CONNECTION_URI=postgresql://{username}:{password}@{host}:{port}/{db_name}?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory&sslmode=require
ExecStart=/usr/bin/java -Xms128m -Xmx256m -jar metabase.jar
User=appmgr
Type=simple
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

Start the service and set it to run on boot:

sudo systemctl daemon-reload
sudo systemctl start metabase.service
sudo systemctl enable metabase.service

Expose the port for web access:

ss -tunelp | grep 3000

Step 5) That’s all folks!

Simply access your server IP on port 3000 and your metabase instance should be set up and ready to go!

If you would like to add a domain to it then I will be covering that in a future tutorial so keep an eye out for that one.

Thanks for reading and if something isn’t working or out of date then as always please let me know in the comments.

Written by

Dominic Cooper-Wootton

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.