Home / How To / How to install Metabase Business Analytics on Ubuntu 20.04 LTS

How to install Metabase Business Analytics on Ubuntu 20.04 LTS



Metabase is a free and open source for business intelligence that can be used to search data sets and view information. It is a simple and powerful analysis tool that helps you learn from your company’s data without technical knowledge. It allows you to create charts and dashboards, ask questions without using SQL, and view detailed information about rows in your database.

Metabase is the right choice for you if you are looking for a high-performance database retrieval 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.

conditions

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

Install Java

Metabase is a Java-based program. So Java needs to be installed on your server. You can install it with the following command:

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

After installation, you can verify the 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)

When you are done, you can move on to the next step.

Install and configure MariaDB

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

apt-get install mariadb-server -y

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

mysql

After logging in, create a database and a 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";

Then flush the privileges and leave the MariaDB shell with the following command:

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

When you are done, you can move on to the next step.

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

mkdir /opt/metabase

Then 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

Then you 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

Then change the ownership of / opt / metabase to metabase and give the correct permission with the following command:

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

When you are done, you can move on to the next step.

Next, you 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, and then reload the system daemon with the following command:

systemctl daemon-reload

Then start the Metabase service and enable it to start at system startup 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 starts and listens to port 3000. You can check it with the following command:

netstat -tunelp | grep 3000

You should see the following output:advertisement

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

Next, you need to configure Nginx as a reverse proxy for Metabase. First, install the Nginx Web Server using 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 done. Then enable the Nginx virtual host with the following command:

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

Then verify Nginx for configuration errors 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

Nginx is currently configured to operate Metabase on port 80. You can now proceed to the next step.

You must first 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 the installation is installed, secure the Metabase website with Let’s Encrypt SSL with the following command:advertisement

certbot --nginx -d metabase.linuxbuz.com

You will be asked to leave your email and accept the terms of use as 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

Then select whether 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

Type 2 and press Enter to install 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.

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

Get started with Metabase

Now click on Let’s start button. The following screen is displayed:

Select your language

Select the desired language and click Next button. The following screen is displayed:

Users and login

Enter your name, email address, password and click Next button. You should see the Metabase Database Configuration screen:

database information

JDBC connection

Enter your database information and click Next button. You should see the Metabase Usage Data Settings screen:

Settings for use

Activate the desired option and click Next button. The following screen is displayed:

The installation is complete

Enter your email address and click Take me to Metabase. You should see the Metabase Dashboard on the following screen:

Metabas dashboard

Conclusion

Congratulations! you have 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.


Source link