Install Metabase with Systemd on Ubuntu 22.04|20.04|18.04

Posted on 117 views

In this guide, I’ll show you how to Install Metabase with Systemd on Ubuntu 22.04/20.04/18.04/16.04. Metabase is a simple and powerful analytics tool which lets you learn and make decisions from your company’s data without any technical knowledge required.

To run the Metabase jar file you need to have Java installed on your system. Currently, Metabase requires Java 8 or higher and will work on either the OpenJDK or Oracle JDK.

For Debian: Install Metabase with Systemd on Debian

Step 1: Install Java on Ubuntu 22.04|20.04|18.04|16.04

As of this writing, Metabase will run on Java version 8 and 11. Install Java on Ubuntu by running the commands provides in the sections below.

Update your APT package index:

sudo apt -y update

Then install Java JDK on Ubuntu system:

sudo apt install -y default-jdk

You can query for the version of Java installed using the following command:

$ java -version
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)

Step 2: Install and Configure the Database server ( MariaDB)

You can skip this step if you have a datastore for Metabase already configured.

I had written a guide on how to install the MariaDB database server on Ubuntu

Follow the steps in the link to get a running database server in minutes. When done, create a database for your Metabase like below

Login to MySQL shell as root user

sudo mysql -u root -p

Create a database and user with access privileges

CREATE DATABASE metabase;
GRANT ALL PRIVILEGES ON metabase.* TO 'metabase'@'localhost' IDENTIFIED BY "StrongPassword";
FLUSH PRIVILEGES;
QUIT

If the database server is remote, assign privilege to a user at specific IP address, e.g

'metabase'@'192.168.0.20'

Or allow access from any IP – Not recommended for a server with public access.

'metabase'@'%'

Step 3: Install Metabase on Ubuntu 22.04/20.04/18.04/16.04

Download Metabase and save it on the path where you want the application to run from.

export VER=0.43.2
wget http://downloads.metabase.com/v$VER/metabase.jar
sudo mkdir -p /apps/java
sudo cp metabase.jar /apps/java

The most basic way of running Metabase to use the javacommand to launch the application.

$ java -jar metabase.jar
01-14 21:24:56 DEBUG plugins.classloader :: Using NEWLY CREATED classloader as shared context classloader: [email protected]
01-14 21:24:57 INFO metabase.util :: Loading Metabase...
01-14 21:24:57 INFO metabase.util :: Maximum memory available to JVM: 483.4 MB
01-14 21:25:01 INFO util.encryption :: Saved credentials encryption is DISABLED for this Metabase instance. 🔓 
 For more information, see https://metabase.com/docs/latest/operations-guide/encrypting-database-details-at-rest.html
.....

This will start the Metabase application using all of the default settings.

Step 4: Configure Metabase Systemd service

The best way to run Metabase is using Systemd init system available on both Ubuntu Linux system.

For the sake of simplicity, I’ll do a specific systemd service file for metabase

Start by creating a system group for the user.

sudo groupadd -r appmgr

Next, we create a system user appmgr with the default group

sudo useradd -r -s /bin/false -g appmgr appmgr

Give this user ownership permission to the applications directory:

sudo chown -R appmgr:appmgr /apps/java

Create a systemd service unit file:

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

Add the contents below to the file.

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

[Service]
WorkingDirectory=/apps/java
ExecStart=/usr/bin/java -Xms128m -Xmx256m -jar metabase.jar
User=appmgr
Type=simple
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

Set your values for maximum and minimum memory allowed for the Java application ( -Xms128m and -Xmx256m ) in my case

The next thing to do is start the application service, but first, reload systemd so that it loads the new application added.

sudo systemctl daemon-reload

Once reloaded, start the service and set it to start on boot:

sudo systemctl start metabase.service
sudo systemctl enable metabase.service

To check the status, use:

sudo systemctl status metabase
metabase status ubuntu 18.04 min

Step 5: Access Metabase Web User Interface

After the service is started, Metabase server will listen on port 3000 by default.

$ sudo ss -tunelp | grep 3000
tcp LISTEN 0 50 *:3000 *:* users:(("java",pid=14386,fd=18)) uid:998 ino:85041 sk:a v6only:0 <->

Access the web page to finish setup using http://:3000

metabase-ubuntu-18.04-welcome-page-min

Click “Let’s get started” button to start the setup. On the next page, create a user to manage Metabase

metabase-set-username-password-min-1024x475

Provide info about your MySQL database – username and password. If you don’t have that right now, Metabase also comes with a sample dataset you can get started with.

metabase-set-database-min-934x1024

You need to feed your data to the database configured above. Metabase will check for data there. Once you finish the setup, you’ll get access to Metabase Administration panel

metabase-dashboard-min-1024x427

See the Metabase getting Started page to start adding Dataset and playing with your data. Also, visit Official metabase documentation for detailed setup and administration.

coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.