How to Install Metabase Business Analytics on Ubuntu 20.04 LTS

Metabase is a free and open-source business intelligence tool that can be used to search data sets and display information. It is a simple and powerful analytics tool that helps you to learn from your company’s data without any technical knowledge. It allows you to generate charts and dashboards, ask queries without using SQL, and see detailed information about rows in your Database.

Metabase is the right choice for you if you are looking for a high performance database lookup platform for your business.

In this tutorial, we will explain how to install Metabase on Ubuntu 20.04 with Nginx and Let's Encrypt SSL.

Prerequisites

  • A server running Ubuntu 20.04.
  • A valid domain name pointed with your server IP.
  • A root password is configured the server.

Install Java

Metabase is a Java-based application. So Java must be installed in your server. You can install it with the following command:

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

After successful installation, you can verify Java version with the following command:

java -version

You should see the following output:

openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)

Once you are finished, you can proceed to the next step.

Install and Configure MariaDB

Next, you will need to install the MariaDB database server in your system. You can install it by running the following command:

apt-get install mariadb-server -y

Once the MariaDB server has been installed, log in to the MariaDB shell with the following command:

mysql

Once login, create a database and user for Metabase with the following command:

MariaDB [(none)]> CREATE DATABASE metabase;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON metabase.* TO 'metabase'@'localhost' IDENTIFIED BY "password";

Next, flush the privileges and exit from the MariaDB shell with the following command:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Once you are finished, you can proceed to the next step.

Download Metabase

First, create a directory for Metabase inside /opt directory with the following command:

mkdir /opt/metabase

Next, change the directory to /opt/metabase and download the latest version of Metabase with the following command:

cd /opt/metabase
wget https://downloads.metabase.com/v0.36.2/metabase.jar

Next, you will need to create a separate user and group to run Metabase. You can create them with the following command:

addgroup --quiet --system metabase
adduser --quiet --system --ingroup metabase --no-create-home --disabled-password metabase

Next, change the ownership of the /opt/metabase to metabase and give proper permission with the following command:

chown -R metabase:metabase /opt/metabase
chmod -R 755 /opt/metabase

Once you are finished, you can proceed to the next step.

Create a Systemd Service File for Metabase

Next, you will need to create a systemd service file to manage the Metabase service. You can create it with the following command:

nano /etc/systemd/system/metabase.service

Add the following lines:

[Unit]
Description=Metabase server

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

[Install]
WantedBy=multi-user.target

Save and close the file then reload the systemd daemon with the following command:

systemctl daemon-reload

Next, start the Metabase service and enable it to start at system reboot with the following command:

systemctl start metabase
systemctl enable metabase

You can now verify the status of Metabase with the following command:

systemctl status metabase

You should see the following output:

? metabase.service - Metabase server
     Loaded: loaded (/etc/systemd/system/metabase.service; disabled; vendor preset: enabled)
     Active: active (running) since Sat 2020-08-01 10:14:02 UTC; 12s ago
   Main PID: 9650 (java)
      Tasks: 18 (limit: 2353)
     Memory: 150.2M
     CGroup: /system.slice/metabase.service
             ??9650 /usr/bin/java -jar /opt/metabase/metabase.jar

Aug 01 10:14:02 ubuntu2004 systemd[1]: Started Metabase server.
Aug 01 10:14:05 ubuntu2004 java[9650]: 08-01 10:14:05 INFO metabase.util :: Loading Metabase...
Aug 01 10:14:06 ubuntu2004 java[9650]: 08-01 10:14:06 INFO metabase.util :: Maximum memory available to JVM: 498.0 MB

At this point, Metabase is started and listening on port 3000. You can check it with the following command:

netstat -tunelp | grep 3000

You should see the following output:

tcp6       0      0 :::3000                 :::*                    LISTEN      109        35366      9650/java

Configure Nginx as a Reverse Proxy for Metabase

Next, you will need to configure Nginx as a reverse proxy for Metabase. First, install the Nginx web server with the following command:

apt-get install nginx -y

After installing Nginx, create a new Nginx virtual host configuration file with the following command:

nano /etc/nginx/sites-available/metabase.conf

Add the following lines:

upstream metabase {
  server 127.0.0.1:3000;
}

server {
    listen 80;
    server_name metabase.linuxbuz.com;
    access_log /var/log/nginx/metabase.linuxbuz.com-access.log;
    error_log /var/log/nginx/metabase.linuxbuz.com-error.log;

    location / {
        proxy_pass http://metabase/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $http_host;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forward-Proto http;
        proxy_set_header X-Nginx-Proxy true;

        proxy_redirect off;
    }
}

Save and close the file when you are finished. Then, activate the Nginx virtual host with the following command:

ln -s /etc/nginx/sites-available/metabase.conf /etc/nginx/sites-enabled/

Next, verify the Nginx for any configuration error with the following command:

nginx -t

You should see the following output:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Finally, restart the Nginx service to apply the changes:

systemctl restart nginx

At this point, Nginx is configured to serve Metabase on port 80. You can now proceed to the next step.

Secure Metabase with Let's Encrypt

First, you will need to install the Certbot Lets Encrypt client to install and manage SSL for your domain. You can install the Certbot client with the following command:

apt-get install python3-certbot-nginx -y

Once installed, secure the Metabase website with Let's Encrypt SSL with the following command:

certbot --nginx -d metabase.linuxbuz.com

You will be asked to provide your email and accept the terms of service as shown below:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for metabase.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/metabase.conf

Next, choose whether or not to redirect HTTP traffic to HTTPS as shown below:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Tyep 2 and hit Enter to install the Let's Encrypt SSL for your domain.

Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/metabase.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://metabase.linuxbuz.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=metabase.linuxbuz.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/metabase.linuxbuz.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/metabase.linuxbuz.com/privkey.pem
   Your cert will expire on 2020-10-30. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

 - We were unable to subscribe you the EFF mailing list because your
   e-mail address appears to be invalid. You can try again later by
   visiting https://act.eff.org.

Now, your Metabase website is secured with Let's Encrypt SSL.

Access Metabase Web Interface

Now, open your web browser and type the URL https://metabase.linuxbuz.com. You will be redirected to the Metabase welcome screen as shown below:

Lets get started with Metabase

Now, click on the Let's get started button. You should see the following screen:

Select Language

Select your desired language and click on the Next button. You should see the following screen:

User and Login

Provide your name, email address, password and click on the Next button. You should see the Metabase database configuration screen:

Database details

JDBC Connection

Provide your database information and click on the Next button. You should see the Metabase usage data preferences screen:

Usage Preferences

Enable your desired option and click on the Next button. You should see the following screen:

Setup finished

Provide your email address and click on the Take me to Metabase. You should see the Metabase dashboard in the following screen:

Metabase dashboard

Conclusion

Congratulations! you have successfully installed Metabase with Nginx and Let's Encrypt SSL on Ubuntu 20.04 server. You can now explore the Metabase for new features. Feel free to ask me if you have any questions.

Share this page:

0 Comment(s)