Skip to content

Instantly share code, notes, and snippets.

@djoudi
Forked from r0lodex/metabase-setup.md
Created July 23, 2024 08:41
Show Gist options
  • Save djoudi/61f446493434085497ec0db83c5d451c to your computer and use it in GitHub Desktop.
Save djoudi/61f446493434085497ec0db83c5d451c 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;
     }
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment