Metabase

De MochilaWiki

Instalando em Ubuntu 20.04

dependências

apt update
apt install openjdk-11-jdk openjdk-11-jre
apt install mariadb-server
systemctl start mariadb
systemctl enable mariadb
mysql -u root -p

criando banco de dados

CREATE DATABASE metabase;
CREATE USER 'metabase_user'@'localhost' IDENTIFIED BY 'Strong_Password';
GRANT ALL ON metabase.* TO 'metabase_user'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

instalando

mkdir /home/metabase
cd /home/metabase
wget https://downloads.metabase.com/v0.39.3/metabase.jar
groupadd -r metabase
useradd -r -s /bin/false -g metabase metabase
chown -R metabase:metabase /home/metabase
touch /var/log/metabase.log
chown metabase:metabase /var/log/metabase.log
touch /etc/default/metabase
chmod 640 /etc/default/metabase

em /etc/systemd/system/metabase.service

[Unit]
Description=Metabase server
After=syslog.target
After=network.target

[Service]
MB_PASSWORD_COMPLEXITY=strong
MB_PASSWORD_LENGTH=12
MB_DB_TYPE=mysql
MB_DB_DBNAME=metabase
MB_DB_PORT=3306
MB_DB_USER=metabase_user
MB_DB_PASS=Strong_Password
MB_DB_HOST=localhost
MB_EMOJI_IN_LOGS=true
WorkingDirectory=/home/metabase/
ExecStart=/usr/bin/java -jar /home/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

em /etc/rsyslog.d/metabase.conf

if $programname == 'metabase' then /var/log/metabase.log
& stop
systemctl restart rsyslog.service

em /etc/default/metabase (alternativa, mas não funcionou no meu teste... deu certo inserindo no service)

MB_PASSWORD_COMPLEXITY=strong #weak|strong
MB_PASSWORD_LENGTH=10
MB_DB_TYPE=mysql #postgres|mysql|h2
MB_DB_DBNAME=metabase
MB_DB_PORT=3306
MB_DB_USER=metabase_user
MB_DB_PASS=Strong_Password
MB_DB_HOST=localhost
MB_EMOJI_IN_LOGS=true #true|false

iniciando metabase e habilitando para iniciar no boot

systemctl daemon-reload
systemctl start metabase
systemctl enable metabase

instalando e configurando o nginx

apt install nginx

em /etc/nginx/sites-available/metabase

server {
listen 80;
listen [::]:80;
server_name example.com;
location / {
proxy_pass http://127.0.0.1:3000;
}
}

reiniciando nginx e habilitando para iniciar no boot

ln -s /etc/nginx/sites-available/metabase /etc/nginx/sites-enabled/metabase
systemctl daemon-reload
systemctl restart nginx
systemctl enable nginx

Dicas

Para delimitar o uso de memória RAM

ExecStart=/usr/bin/java -Xms128m -Xmx256m -jar metabase.jar

Para verificar se o processo está rolando na porta 3000

ss -tunelp | grep 3000

Talvez seja necessário instalar o mariadb-client (apt install mariadb-client)


Referências