웹사이트 검색

Ubuntu 20.04 LTS에 Metabase Business Analytics를 설치하는 방법


이 튜토리얼은 다음 OS 버전에 대해 존재합니다.

  • Ubuntu 20.04(Focal Fossa)
  • Ubuntu 18.04(Bionic Beaver)

이 페이지에서

  1. 전제 조건
  2. 자바 설치
  3. MariaDB 설치 및 구성
  4. 메타베이스 다운로드
  5. 메타베이스용 Systemd 서비스 파일 만들기
  6. Nginx를 메타베이스용 역방향 프록시로 구성\n
  7. Lets Encrypt로 메타베이스 보호\n
  8. 메타베이스 웹 인터페이스 액세스
  9. 결론

Metabase는 데이터 세트를 검색하고 정보를 표시하는 데 사용할 수 있는 무료 오픈 소스 비즈니스 인텔리전스 도구입니다. 기술적 지식 없이도 회사의 데이터에서 배울 수 있도록 도와주는 간단하고 강력한 분석 도구입니다. 이를 통해 차트와 대시보드를 생성하고, SQL을 사용하지 않고 쿼리를 요청하고, 데이터베이스의 행에 대한 자세한 정보를 볼 수 있습니다.

비즈니스를 위한 고성능 데이터베이스 조회 플랫폼을 찾고 있다면 Metabase가 올바른 선택입니다.

이 튜토리얼에서는 Nginx 및 Lets Encrypt SSL을 사용하여 Ubuntu 20.04에 Metabase를 설치하는 방법을 설명합니다.

전제 조건

  • Ubuntu 20.04를 실행하는 서버.\n
  • 서버 IP를 가리키는 유효한 도메인 이름입니다.\n
  • 루트 암호는 서버에 구성됩니다.\n

자바 설치

Metabase는 Java 기반 응용 프로그램입니다. 따라서 서버에 Java가 설치되어 있어야 합니다. 다음 명령으로 설치할 수 있습니다.

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

성공적으로 설치한 후 다음 명령을 사용하여 Java 버전을 확인할 수 있습니다.

java -version

다음 출력이 표시되어야 합니다.

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)

완료되면 다음 단계로 진행할 수 있습니다.

MariaDB 설치 및 구성

다음으로 시스템에 MariaDB 데이터베이스 서버를 설치해야 합니다. 다음 명령을 실행하여 설치할 수 있습니다.

apt-get install mariadb-server -y

MariaDB 서버가 설치되면 다음 명령을 사용하여 MariaDB 셸에 로그인합니다.

mysql

로그인한 후 다음 명령을 사용하여 Metabase용 데이터베이스 및 사용자를 생성합니다.

MariaDB [(none)]> CREATE DATABASE metabase;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON metabase.* TO 'metabase'@'localhost' IDENTIFIED BY "password";

그런 다음 권한을 플러시하고 다음 명령을 사용하여 MariaDB 셸을 종료합니다.

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

완료되면 다음 단계로 진행할 수 있습니다.

메타베이스 다운로드

먼저 다음 명령을 사용하여 /opt 디렉토리 내에 메타베이스용 디렉토리를 만듭니다.

mkdir /opt/metabase

그런 다음 디렉터리를 /opt/metabase로 변경하고 다음 명령을 사용하여 최신 버전의 Metabase를 다운로드합니다.

cd /opt/metabase
wget https://downloads.metabase.com/v0.36.2/metabase.jar

다음으로 Metabase를 실행할 별도의 사용자와 그룹을 만들어야 합니다. 다음 명령으로 생성할 수 있습니다.

addgroup --quiet --system metabase
adduser --quiet --system --ingroup metabase --no-create-home --disabled-password metabase

다음으로 /opt/metabase의 소유권을 metabase로 변경하고 다음 명령을 사용하여 적절한 권한을 부여합니다.

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

완료되면 다음 단계로 진행할 수 있습니다.

메타베이스용 Systemd 서비스 파일 생성

다음으로 메타베이스 서비스를 관리하기 위한 systemd 서비스 파일을 생성해야 합니다. 다음 명령으로 만들 수 있습니다.

nano /etc/systemd/system/metabase.service

다음 줄을 추가합니다.

[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

파일을 저장하고 닫은 후 다음 명령을 사용하여 systemd 데몬을 다시 로드합니다.

systemctl daemon-reload

그런 다음 메타베이스 서비스를 시작하고 다음 명령을 사용하여 시스템 재부팅 시 시작되도록 활성화합니다.

systemctl start metabase
systemctl enable metabase

이제 다음 명령을 사용하여 Metabase의 상태를 확인할 수 있습니다.

systemctl status metabase

다음 출력이 표시되어야 합니다.

? 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 ubunt4 systemd[1]: Started Metabase server.
Aug 01 10:14:05 ubunt4 java[9650]: 08-01 10:14:05 INFO metabase.util :: Loading Metabase...
Aug 01 10:14:06 ubunt4 java[9650]: 08-01 10:14:06 INFO metabase.util :: Maximum memory available to JVM: 498.0 MB

이 시점에서 Metabase가 시작되고 포트 3000에서 수신 대기합니다. 다음 명령으로 확인할 수 있습니다.

netstat -tunelp | grep 3000

다음 출력이 표시되어야 합니다.

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

Nginx를 메타베이스의 역방향 프록시로 구성

다음으로 Nginx를 Metabase용 리버스 프록시로 구성해야 합니다. 먼저 다음 명령을 사용하여 Nginx 웹 서버를 설치합니다.

apt-get install nginx -y

Nginx를 설치한 후 다음 명령을 사용하여 새 Nginx 가상 호스트 구성 파일을 만듭니다.

nano /etc/nginx/sites-available/metabase.conf

다음 줄을 추가합니다.

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;
    }
}

완료되면 파일을 저장하고 닫습니다. 그런 다음 다음 명령을 사용하여 Nginx 가상 호스트를 활성화합니다.

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

다음으로 다음 명령을 사용하여 구성 오류에 대해 Nginx를 확인합니다.

nginx -t

다음 출력이 표시되어야 합니다.

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

마지막으로 Nginx 서비스를 다시 시작하여 변경 사항을 적용합니다.

systemctl restart nginx

이 시점에서 Nginx는 포트 80에서 메타베이스를 제공하도록 구성되었습니다. 이제 다음 단계를 진행할 수 있습니다.

Lets Encrypt로 안전한 메타베이스

먼저 도메인용 SSL을 설치하고 관리하려면 Certbot Lets Encrypt 클라이언트를 설치해야 합니다. 다음 명령을 사용하여 Certbot 클라이언트를 설치할 수 있습니다.

apt-get install python3-certbot-nginx -y

설치가 완료되면 다음 명령을 사용하여 Lets Encrypt SSL로 Metabase 웹 사이트를 보호하십시오.

certbot --nginx -d metabase.linuxbuz.com

아래와 같이 이메일을 제공하고 서비스 약관에 동의하라는 메시지가 표시됩니다.

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): 

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

다음으로 아래와 같이 HTTP 트래픽을 HTTPS로 리디렉션할지 여부를 선택합니다.

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

2를 입력하고 Enter 키를 눌러 도메인에 Lets Encrypt SSL을 설치합니다.

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.

이제 귀하의 Metabase 웹사이트는 Lets Encrypt SSL로 보호됩니다.

메타베이스 웹 인터페이스에 액세스

이제 웹 브라우저를 열고 URL https://metabase.linuxbuz.com을 입력하십시오. 아래와 같이 메타베이스 시작 화면으로 리디렉션됩니다.

이제 시작하겠습니다 버튼을 클릭합니다. 다음 화면이 표시됩니다.

원하는 언어를 선택하고 다음 버튼을 클릭합니다. 다음 화면이 표시됩니다.

이름, 이메일 주소, 비밀번호를 입력하고 다음 버튼을 클릭합니다. 메타베이스 데이터베이스 구성 화면이 표시되어야 합니다.

데이터베이스 정보를 제공하고 다음 버튼을 클릭합니다. 메타베이스 사용 데이터 기본 설정 화면이 표시되어야 합니다.

원하는 옵션을 활성화하고 다음 버튼을 클릭합니다. 다음 화면이 표시됩니다.

이메일 주소를 제공하고 Take me to Metabase를 클릭합니다. 다음 화면에 메타베이스 대시보드가 표시되어야 합니다.

결론

축하합니다! Nginx와 함께 Metabase를 성공적으로 설치했으며 Ubuntu 20.04 서버에 Lets Encrypt SSL을 사용했습니다. 이제 새 기능에 대한 메타베이스를 탐색할 수 있습니다. 궁금한 점이 있으면 언제든지 문의해 주세요.