UbuntuUbuntu Based

How To Install Metabase on Ubuntu 24.04 LTS

Install Metabase on Ubuntu 24.04

Metabase stands as one of the most powerful open-source business intelligence platforms available today. This comprehensive analytics tool transforms raw data into actionable insights through intuitive dashboards and visualizations. Ubuntu 24.04 LTS provides the perfect foundation for hosting Metabase, offering stability, security, and long-term support that enterprise environments demand. Whether you’re a system administrator, data analyst, or business owner, this guide will walk you through every step of installing and configuring Metabase on your Ubuntu server.

Prerequisites and System Requirements

Hardware Requirements

Before beginning the Metabase installation process, ensure your Ubuntu 24.04 LTS server meets the minimum hardware specifications. A successful deployment requires at least 2GB of RAM, though 4GB is strongly recommended for optimal performance. The system should have a minimum of one CPU core, but multiple cores will significantly improve query processing and dashboard loading times. Storage requirements include at least 2GB of free disk space for the application files, with additional space needed for data storage and logs. Network connectivity is essential, as Metabase will need to communicate with databases and serve web traffic to users.

Software Prerequisites

Your Ubuntu 24.04 LTS system should be freshly updated with the latest security patches and system updates. You’ll need a user account with sudo privileges to execute administrative commands throughout the installation process. Before proceeding, update your system package repository and install essential utilities. The firewall should be properly configured to allow necessary traffic while maintaining security. Additionally, ensure your system has adequate swap space configured, as Java applications like Metabase can be memory-intensive during peak usage periods.

Method 1: Installing Metabase Using JAR File

Installing Java Development Kit

The first step in installing Metabase via JAR file involves setting up the Java runtime environment. OpenJDK 17 is the recommended version for optimal compatibility and performance. Execute the following commands to install Java:

sudo apt update
sudo apt install openjdk-17-jdk -y

Verify the installation by checking the Java version:

java -version
javac -version

Configure the JAVA_HOME environment variable by adding it to your system profile:

echo 'export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64' | sudo tee -a /etc/environment
source /etc/environment

If you encounter Java installation issues, ensure your package repository is up to date and consider installing the default-jdk package as an alternative. Some users may need to manually set the Java alternatives if multiple versions are present on the system.

Downloading and Setting Up Metabase

Create a dedicated directory structure for Metabase installation and management:

sudo mkdir -p /opt/metabase
cd /opt/metabase

Download the latest Metabase JAR file directly from the official repository:

sudo wget https://downloads.metabase.com/latest/metabase.jar

Establish proper file permissions and ownership for security:

sudo chmod +x metabase.jar
sudo chown -R metabase:metabase /opt/metabase

Create a dedicated user account for running Metabase services:

sudo useradd --system --no-create-home --shell /bin/false metabase
sudo usermod -aG metabase metabase

This approach follows security best practices by running the application under a non-privileged user account, reducing potential security risks.

Creating Systemd Service

Configure Metabase to run as a system service for automatic startup and management. Create the systemd service file:

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

Add the following service configuration:

[Unit]
Description=Metabase Business Analytics
After=network.target
Requires=network.target

[Service]
Type=simple
User=metabase
Group=metabase
ExecStart=/usr/bin/java -jar /opt/metabase/metabase.jar
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
Environment=MB_DB_TYPE=h2
Environment=MB_DB_FILE=/opt/metabase/metabase.db
Environment=MB_JETTY_PORT=3000

[Install]
WantedBy=multi-user.target

Create an environment file for additional configuration options:

sudo nano /etc/metabase/metabase.conf

Enable and start the Metabase service:

sudo systemctl daemon-reload
sudo systemctl enable metabase
sudo systemctl start metabase

Monitor the service status to ensure proper startup:

sudo systemctl status metabase
sudo journalctl -u metabase -f

The systemd configuration ensures Metabase automatically restarts after system reboots and handles service failures gracefully.

Testing and Verification

Verify that Metabase is running correctly by checking the service status and accessing the web interface. The application should be accessible at http://your-server-ip:3000 within a few minutes of startup. Initial loading may take several minutes as Metabase initializes its database and performs first-time setup procedures.

Check that the service is bound to the correct port:

sudo netstat -tlnp | grep :3000
ss -tulnp | grep :3000

If the service fails to start, examine the system logs for error messages and troubleshooting information. Common issues include Java version conflicts, file permission problems, or port binding conflicts with other services.

Configuration and Optimization

Optimize Metabase performance by adjusting JVM memory allocation settings in the service file. Add memory parameters to the ExecStart command:

ExecStart=/usr/bin/java -Xmx2g -Xms1g -jar /opt/metabase/metabase.jar

Configure the system timezone to ensure accurate data reporting:

sudo timedatectl set-timezone America/New_York

Set up log rotation to prevent disk space issues:

sudo nano /etc/logrotate.d/metabase

Add log rotation configuration:

/var/log/metabase/*.log {
    daily
    rotate 30
    compress
    missingok
    notifempty
    create 644 metabase metabase
}

These optimizations ensure Metabase runs efficiently and maintains system stability over time.

Method 2: Installing Metabase with Docker

Docker Installation and Setup

Docker provides an alternative installation method that simplifies deployment and management. Install Docker and Docker Compose on Ubuntu 24.04:

sudo apt update
sudo apt install docker.io docker-compose -y
sudo systemctl start docker
sudo systemctl enable docker

Add your user to the docker group to run commands without sudo:

sudo usermod -aG docker $USER
newgrp docker

Verify Docker installation:

docker --version
docker-compose --version

Configure Docker daemon settings for optimal performance and security. Edit the Docker daemon configuration file and restart the service after making changes. Consider implementing Docker security best practices, including user namespace remapping and resource limitations.

Docker Compose Configuration

Create a project directory and Docker Compose configuration file:

mkdir ~/metabase-docker
cd ~/metabase-docker
nano docker-compose.yml

Configure the complete Docker Compose setup with PostgreSQL database:

version: '3.8'
services:
  postgres:
    image: postgres:13
    container_name: metabase-postgres
    environment:
      POSTGRES_DB: metabaseappdb
      POSTGRES_USER: metabase
      POSTGRES_PASSWORD: strong_password_here
    volumes:
      - postgres_data:/var/lib/postgresql/data
    restart: always
    networks:
      - metabase-network

  metabase:
    image: metabase/metabase:latest
    container_name: metabase-app
    environment:
      MB_DB_TYPE: postgres
      MB_DB_DBNAME: metabaseappdb
      MB_DB_PORT: 5432
      MB_DB_USER: metabase
      MB_DB_PASS: strong_password_here
      MB_DB_HOST: postgres
    ports:
      - "3000:3000"
    depends_on:
      - postgres
    restart: always
    networks:
      - metabase-network

volumes:
  postgres_data:

networks:
  metabase-network:
    driver: bridge

This configuration creates a complete Metabase environment with persistent data storage and proper network isolation. The PostgreSQL database ensures better performance and reliability compared to the default H2 database.

Launching and Managing Containers

Start the Metabase environment using Docker Compose:

docker-compose up -d

Monitor container logs for startup progress and troubleshooting:

docker-compose logs -f metabase
docker-compose logs -f postgres

Manage the containerized services with standard Docker Compose commands:

docker-compose stop
docker-compose start
docker-compose restart
docker-compose down

Access the Metabase web interface at http://localhost:3000 once the containers are running successfully. The Docker approach provides easier maintenance, updates, and backup procedures compared to traditional installation methods.

Docker-Specific Optimizations

Configure resource limitations to prevent container resource exhaustion:

  metabase:
    # ... other configuration
    deploy:
      resources:
        limits:
          memory: 2G
          cpus: '1.0'
        reservations:
          memory: 1G
          cpus: '0.5'

Implement Docker security practices including non-root user execution and read-only root filesystems where possible. Set up proper backup procedures for Docker volumes to ensure data persistence and disaster recovery capabilities. Consider using Docker secrets for sensitive configuration data instead of environment variables.

Database Configuration

Application Database Setup

While Metabase ships with an H2 database for quick setup, production environments require more robust database solutions. PostgreSQL offers the best performance and reliability for Metabase deployments.

Install and configure PostgreSQL:

sudo apt install postgresql postgresql-contrib -y
sudo systemctl start postgresql
sudo systemctl enable postgresql

Create the Metabase application database:

sudo -u postgres createuser -d -r -s metabase
sudo -u postgres createdb -O metabase metabaseappdb
sudo -u postgres psql -c "ALTER USER metabase WITH PASSWORD 'secure_password';"

Configure PostgreSQL for optimal Metabase performance by adjusting memory settings, connection limits, and query optimization parameters. Regular database maintenance, including vacuum operations and index optimization, ensures continued high performance.

Environment Variables Configuration

Configure Metabase database connection through environment variables. Create a comprehensive environment file:

sudo nano /etc/metabase/metabase.env

Add database configuration parameters:

MB_DB_TYPE=postgres
MB_DB_DBNAME=metabaseappdb
MB_DB_PORT=5432
MB_DB_USER=metabase
MB_DB_PASS=secure_password
MB_DB_HOST=localhost
MB_JETTY_PORT=3000
MB_JETTY_HOST=localhost
JAVA_OPTS=-Xmx2g -Xms1g

Security considerations include storing sensitive information in protected files with restricted permissions. Environment variables provide flexibility for different deployment scenarios while maintaining security best practices. Update the systemd service file to source the environment configuration during startup.

Reverse Proxy Setup with Nginx

Nginx Installation and Configuration

Install Nginx web server to provide reverse proxy functionality:

sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx

Create a virtual host configuration for Metabase:

sudo nano /etc/nginx/sites-available/metabase

Configure the Nginx virtual host:

server {
    listen 80;
    server_name your-domain.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_connect_timeout 60s;
        proxy_send_timeout 60s;
        proxy_read_timeout 60s;
    }
}

Enable the site configuration:

sudo ln -s /etc/nginx/sites-available/metabase /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

The reverse proxy configuration provides additional security, SSL termination capabilities, and improved performance through caching and compression features.

SSL Certificate with Let’s Encrypt

Secure your Metabase installation with SSL/TLS encryption using Let’s Encrypt:

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d your-domain.com

Configure automatic certificate renewal:

sudo systemctl enable certbot.timer
sudo systemctl start certbot.timer

Add security headers to the Nginx configuration:

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options DENY;
add_header X-XSS-Protection "1; mode=block";

SSL encryption protects sensitive business data during transmission and builds user trust in your analytics platform. Regular certificate monitoring ensures continued security without service interruptions.

Security Hardening

User and Permission Management

Implement the principle of least privilege by configuring appropriate user permissions and access controls. Ensure the Metabase service runs under a dedicated user account with minimal system privileges:

sudo chmod 750 /opt/metabase
sudo chown -R metabase:metabase /opt/metabase
sudo chmod 640 /etc/metabase/metabase.env

Configure SSH key-based authentication and disable password authentication for enhanced server security:

sudo nano /etc/ssh/sshd_config

Set PasswordAuthentication no and restart the SSH service. Regular security audits and access reviews ensure continued protection against unauthorized access attempts.

Network Security

Configure the Ubuntu Firewall (UFW) to restrict network access to essential services only:

sudo ufw enable
sudo ufw allow ssh
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw deny 3000/tcp

Install and configure Fail2ban for automated intrusion prevention:

sudo apt install fail2ban -y
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo systemctl enable fail2ban
sudo systemctl start fail2ban

Regular security updates and system monitoring ensure your Metabase installation remains protected against emerging threats. Consider implementing intrusion detection systems and log monitoring for comprehensive security coverage.

Initial Setup and Configuration

Web Interface Setup

Access the Metabase web interface through your configured domain or server IP address. The initial setup wizard guides you through essential configuration steps including administrator account creation, language selection, and basic system settings.

Install Metabase on Ubuntu 24.04

Create a strong administrator password using a combination of uppercase letters, lowercase letters, numbers, and special characters. Configure the system timezone to match your organization’s location for accurate data reporting and scheduling.

The setup process includes database connection testing and sample data configuration options. Take time to properly configure these initial settings, as they establish the foundation for your entire analytics platform.

Database Connections

Add your first data source by navigating to the Admin Settings and selecting “Databases.” Metabase supports numerous database types including PostgreSQL, MySQL, MongoDB, and cloud-based solutions like Amazon Redshift and Google BigQuery.

Test database connections thoroughly before proceeding with dashboard creation. Configure appropriate user permissions and access controls for different team members based on their roles and responsibilities within your organization.

Sample data setup helps users understand Metabase capabilities and provides a testing environment for learning advanced features. Consider creating dedicated test databases for training and experimentation purposes.

Troubleshooting Common Issues

Installation Problems

Common Java version conflicts can prevent Metabase from starting correctly. Verify that OpenJDK 17 is properly installed and configured as the default Java version:

sudo update-alternatives --config java
sudo update-alternatives --config javac

Permission denied errors often result from incorrect file ownership or restrictive permissions on the Metabase directory. Ensure proper ownership and execute permissions:

sudo chown -R metabase:metabase /opt/metabase
sudo chmod +x /opt/metabase/metabase.jar

Service startup failures may indicate port conflicts or configuration errors. Check system logs for detailed error messages and verify that port 3000 is available for Metabase use.

Performance and Access Issues

Memory allocation problems can cause slow performance or application crashes. Monitor system resource usage and adjust JVM memory settings accordingly:

sudo systemctl edit metabase

Add memory configuration to the service override:

[Service]
Environment=JAVA_OPTS=-Xmx4g -Xms2g

Network connectivity issues may prevent users from accessing the Metabase interface. Verify firewall rules, DNS configuration, and reverse proxy settings. Browser compatibility problems can usually be resolved by clearing cache and cookies or using an alternative web browser.

Database connection timeouts might indicate network issues or database performance problems. Monitor database performance metrics and consider connection pooling optimization for high-traffic environments.

Maintenance and Best Practices

Regular Maintenance Tasks

Establish a routine maintenance schedule including system updates, security patches, and performance monitoring. Ubuntu 24.04 LTS provides security updates for five years, but regular patching remains essential for continued protection:

sudo apt update && sudo apt upgrade -y
sudo systemctl restart metabase

Implement automated backup procedures for both the Metabase application database and system configuration files. Regular backups ensure quick recovery from hardware failures or data corruption incidents:

sudo -u postgres pg_dump metabaseappdb > metabase_backup_$(date +%Y%m%d).sql

Log rotation and cleanup prevent disk space exhaustion and maintain system performance. Configure appropriate retention policies based on your organization’s compliance and auditing requirements.

Production Deployment Considerations

Scaling recommendations for production environments include horizontal scaling through load balancers and vertical scaling through increased system resources. High availability setups require redundant systems and automatic failover capabilities to ensure continuous service availability.

Implement comprehensive monitoring and alerting systems to detect performance issues before they impact users. Consider using tools like Prometheus, Grafana, or Nagios for system monitoring and alerting.

Disaster recovery planning should include regular backup testing, documented recovery procedures, and defined recovery time objectives. Test recovery procedures regularly to ensure they work correctly when needed most.

Congratulations! You have successfully installed Metabase. Thanks for using this tutorial for installing Metabase with Docker Compose on the Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the official Metabase website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button