Skip to content

Instantly share code, notes, and snippets.

@r0lodex
Last active January 26, 2026 19:55
Show Gist options
  • Select an option

  • Save r0lodex/f57340b47091031e7af198cbedd29870 to your computer and use it in GitHub Desktop.

Select an option

Save r0lodex/f57340b47091031e7af198cbedd29870 to your computer and use it in GitHub Desktop.
Metabase Setup

Installing and Setting Up Metabase with Postgres

This guide is written for installation of Metabase on Ubuntu 18.04. Instead of using H2 as the application database, we will be using Postgres. You can opt to use MySQL as well. Please follow the steps below:

  • Update and install Java with proper configuration
sudo apt-get update
sudo apt install openjdk-8-jdk
  • Get the installation path via
sudo update-alternatives --config java
  • Set JAVA_HOME to installation path and along with metabase application database variables
sudo nano /etc/environment
  • Add this to the file
JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java"
MB_DB_TYPE=postgres
MB_DB_DBNAME=metabase
MB_DB_PORT=5432
MB_DB_USER=<username>
MB_DB_PASS=<password>
MB_DB_HOST=localhost
  • Don't forget to reactivate your terminal session via source /etc/environment
  • Download metabase
wget http://downloads.metabase.com/v0.34.2/metabase.jar
  • Move the downloaded file to /opt/metabase (or anywhere, make sure the path follows for next steps)
  • Configure user group
sudo addgroup --quiet --system metabase
sudo adduser --quiet --system --ingroup metabase --no-create-home --disabled-password metabase
  • Configure permission
sudo chown -R metabase:metabase /opt/metabase
sudo touch /var/log/metabase.log
sudo chown metabase:metabase /var/log/metabase.log
sudo touch /etc/default/metabase
sudo chmod 640 /etc/default/metabase
  • Add metabase as an OS service
sudo nano /etc/systemd/system/metabase.service
  • Configuration for the service as below:
[Unit]
Description=Metabase server
After=syslog.target
After=network.target

[Service]
WorkingDirectory=/opt/metabase/
ExecStart=/usr/bin/java -jar /opt/metabase/metabase.jar
EnvironmentFile=/etc/default/metabase
User=metabase
Type=simple
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=metabase
SuccessExitStatus=143
TimeoutStopSec=120
Restart=always
 
[Install]
WantedBy=multi-user.target
  • Enable metabase to start on boot
sudo systemctl daemon-reload
sudo systemctl enable metabase
  • Configure metabase to properly log with the system
sudo nano /etc/rsyslog.d/metabase.conf
  • Add this piece of condition into that
if $programname == 'metabase' then /var/log/metabase.log
& stop
  • Then you can start with sudo systemctl start metabase
  • And also check status with sudo systemctl status metabase

Then can configure nginx as usual, with this config:

server {
     listen [::]:80;
     listen 80;

     server_name metabase.domain.com;

     location / {
         proxy_set_header X-Forwarded-Host $host;
         proxy_set_header X-Forwarded-Server $host;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_pass http://localhost:3000;
         client_max_body_size 100M;
     }
 }
@bradintheusa
Copy link

This line is missing quote

JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

I also don't get the last part "Then can configure nginx as usual, with this config"

@r0lodex
Copy link
Author

r0lodex commented Jan 26, 2026

This line is missing quote

JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

I also don't get the last part "Then can configure nginx as usual, with this config"

Good eye. I've corrected that. On the last part, what I meant was you can go on with the common nginx configuration, nothing more.

Anyway, this guide was written years ago (and it was for my sanity check later). Now I'm using Redash, which has more flexible configuration options.

@bradintheusa
Copy link

The latest metabase requires a more recent JDK. Just an FYI to future explorers. The rest is great and very helpful.

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