Cara Install Superset Data Visualization di Ubuntu 20.04

Apache Superset adalah aplikasi data visualization berbasis web. Superset digunakan untuk eksplorasi dan visualisasi data dalam berbagai format grafik. Superset dikembangkan di atas bahasa pemrograman Python dan framework Flask. Superset mendukung berbagai engine database seperti MySQL, MariaDB, PostgreSQL, Oracle, SQL Server, Amazon Redshift, Azure MS SQL, dan Big Query.

*Tutorial Environment*

Server dan software yang digunakan pada tutorial ini:

· OS: Ubuntu Server 20.04 · Python: 3.8 · Web Server: Nginx · SSL: Let’s Encrypt · Subdomain: superset.musaamin.my.id · Superset: v1.3.2

*Install Dependensi*

Install paket dependensi yang dibutuhkan.

[INPUT]

1 apt install build-essential libssl-dev libffi-dev python3-dev python3-pip libsasl2-dev libldap2-dev libmysqlclient-dev

*Install virtualenv*

Install Python virtual environment (virtualenv) dengan menggunakan pip.

[INPUT]

1 pip install virtualenv

*Membuat virtualenv*

Membuat user untuk Superset.

[INPUT]

1 adduser superset

Login sebagai user superset.

[INPUT]

1 su – superset

Membuat virtualenv dengan nama venv.

[INPUT]

1 virtualenv venv

Mengaktifkan virtualenv.

[INPUT]

1 source venv/bin/activate

*Install superset*

Install superset dan library yang dibutuhkan.

[INPUT]

1 2 3 pip install pillow pip install apache-superset pip install mysqlclient

Insialisasi database.

[INPUT]

1 superset db upgrade

Export environment variable untuk superset.

[INPUT]

1 echo “export FLASK_APP=superset” >> ~/.bashrc

Membuat user admin.

[INPUT]

1 superset fab create-admin

Load data contoh.

[INPUT]

1 superset load_examples

Membuat default roles dan permissions.

[INPUT]

1 superset init

Menguji hasil instalasi Superset dengan menjalankan development server. Untuk menghentikan development server tekan CTRL+C.

[INPUT]

1 superset run -h 0.0.0.0 -p 8088 –with-threads –reload –debugger

Mengakses Superset yang berjalan di development server pada port 8088.

Akses Superset dengan IP address

Keluar dari virtual environment dan user superset.

[INPUT]

1 2 deactivate exit

*Membuat systemd service*

Membuat folder untuk log Gunicorn.

[INPUT]

1 mkdir gunicorn-log

Membuat systemd service file untuk mengatur Superset service.

[INPUT]

1 nano /etc/systemd/system/superset.service

Masukkan konfigurasi berikut ini:

[INPUT]

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 [Unit] Description=”Apache Superset” After=network.target   [Service] User=superset Group=superset WorkingDirectory=/home/superset Environment=”PATH=/home/superset/venv/bin” ExecStart=/home/superset/venv/bin/gunicorn -w 4 \         –timeout 120 \         -b unix:/home/superset/gunicorn.sock \         –limit-request-line \         –limit-request-field_size \         –error-logfile /home/superset/gunicorn-log/error.log \         –access-logfile /home/superset/gunicorn-log/access.log \         superset.app:create_app() Restart=on-failure RestartSec=5s   [Install] WantedBy=multi-user.target

Reload systemd daemon.

[INPUT]

1 systemctl daemon-reload

Menjalankan dan mengaktifkan service saat system boot.

[INPUT]

1 2 systemctl start superset systemctl enable superset

Mengecek status service Superset.

[INPUT]

1 systemctl status superset

Hasilnya.

[INPUT]

1 2 3 4 5 6 “— superset.service – “Apache Superset”      Loaded: loaded (/etc/systemd/system/superset.service; enabled; vendor preset: enabled)      Active: active (running) since Tue 2022-01-11 14:47:19 UTC; 7min ago    Main PID: 1949 (gunicorn)       Tasks: 13 (limit: 4612)      Memory: 510.8M

*Install Nginx*

Install Nginx sebagai reverse proxy untuk Superset.

[INPUT]

1 apt install nginx

Membuat file konfigurasi Nginx server block.

[INPUT]

1 nano /etc/nginx/conf.d/superset.conf

Masukkan konfigurasi berikut:

[INPUT]

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 upstream superset {   server unix:/home/superset/gunicorn.sock; }   server {     listen 80;     server_name superset.musaamin.my.id;       location / {         proxy_pass http://superset/;         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;     }       access_log /var/log/nginx/superset.musaamin.my.id-access.log;     error_log /var/log/nginx/superset.musaamin.my.id-error.log;     }

Verifikasi konfigurasi Nginx.

[INPUT]

1 nginx -t

Hasilnya.

[INPUT]

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

Restart dan cek status service Nginx.

[INPUT]

1 2 systemctl restart nginx systemctl status nginx

Hasilnya.

[INPUT]

1 2 3 4 5 6 7 8 9 “— nginx.service – A high performance web server and a reverse proxy server      Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)      Active: active (running) since Tue 2022-01-11 15:05:55 UTC; 3s ago        Docs: man:nginx(8)     Process: 2096 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=/SUCCESS)     Process: 2109 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=/SUCCESS)    Main PID: 2111 (nginx)       Tasks: 3 (limit: 4612)      Memory: 3.6M

Mengakses Superset dengan menggunakan domain.

Akses Superset dengan domain

*Install Let”€™s Encrypt*

Install Let”€™s Encrypt untuk SSL.

[INPUT]

1 apt install python3-certbot-nginx

Request SSL untuk superset.

[INPUT]

1 certbot –non-interactive -m email@example.com –agree-tos –no-eff-email –nginx -d superset.musaamin.my.id –redirect

Mengakses Superset dengan protokol HTTPS.

Akses Superset dengan protokol HTTPS

Superset siap untuk digunakan.

Superset dashboard

Selamat mencoba 🙂

Leave a Reply

Your email address will not be published.