天天看點

Installing Superset最新版本安裝(筆記)

官方文檔:https://superset.apache.org/docs/installation/installing-superset-from-scratch

由于在centos上安裝有各種問題,個人沒有解決好。是以采用在ubuntu server上安裝,順利的多。

步驟如下,主要是按官方步驟就行,其中有一點就是必須更新pip至最新。

In Ubuntu 20.04 the following command will ensure that the required dependencies are installed:

sudo apt-get install build-essential libssl-dev libffi-dev python3-dev python3-pip libsasl2-dev libldap2-dev

pip install --upgrade pip【重要,一定要更新,不然後面報錯】

pip install virtualenv

# virtualenv is shipped in Python 3.6+ as venv instead of pyvenv.

# See https://docs.python.org/3.6/library/venv.html

python3 -m venv venv

. venv/bin/activate

You can exit the environment by running deactivate on the command line

Installing and Initializing Superset

First, start by installing apache-superset:

pip install apache-superset

Then, you need to initialize the database:

superset db upgrade

Finish installing by running through the following commands:

# Create an admin user in your metadata database (use `admin` as username to be able to load the examples)

$ export FLASK_APP=superset

superset fab create-admin

# Load some data to play with

superset load-examples【加載失敗見後面文檔,需要下載下傳資料,自建http伺服器】

# Create default roles and permissions

superset init

# To start a development web server on port 8088, use -p to bind to another port

superset run -p 8088 --with-threads --reload --debugger

superset run -p 8088 -h 192.168.1.149 --with-threads

連接配接資料庫:

mysql:用pip install mysqlclient會報錯,可以改用pip install mysql-connector-python。

mssql:pip install pymssql

mssql+pymssql://<Username>:<Password>@<Host>:<Port-default:1433>/<Database Name>/?Encrypt=yes

mysql+mysqlconnector://{username}:{password}@{host}/{database}

mssql+pymssql://sa:[email protected]/Test

其它:

UserWarning: Could not import the lzma module. Your installed Python is incomplete

For centos: sudo yum install -y xz-devel

Recompile python from source code

cd Python-3.8*/

./configure --enable-optimizations

sudo make altinstall

superset load-examples失敗解決方法

由于原因是example資料是存放在github的,但是無法直接下載下傳或者下載下傳逾時,可提前到官方下載下傳:網址如下https://github.com/apache-superset/examples-data/archive/refs/heads/master.zip

接着需要自己起一個http 服務,用的是python自帶的python -m http.server 【端口号】快速搭建一個,(端口号一般是自己設4位數字例如8088之類的)。搭建步驟如下

第一步:cmd進入自己要上傳到http的檔案目錄,例如我進入到下載下傳的案例壓縮包解壓到的一個檔案夾目錄中

第二步:指令行裡敲入python -m http.server 【端口号】,會出現以下結果,這時候已經搞定了

第三步,在網址欄輸入http://(自己電腦的IP):【端口号】

就可以看到你當時的目錄(webserver要允許目錄浏覽?)

http服務搭建完成

接着改examples/helpers.py裡的BASE_URL項

把原本的BASE_URL ="https://github.com/apache-superset/examples-data/blob/master/"

改成BASE_URL ="http://(自己電腦的IP):【端口号】/examples-data-master/"

【注意BASE_URL後面是直接各個資料的gz檔案,不能再有子目錄間隔】

儲存好

再回到最開始嘗試:superset load-examples【仍有一些db的錯誤,請網上搜查】

安裝為服務(未驗證)

Actually the superset runserver is used for development mode and it is highly recommended other tools like gunicorn for production. Anyway, the main problem is that superset path on the virutalenv is $VENV_PATH/bin/superset (in general the applications that treat like binary applications like superset or airflow, etc servers on this path: $VENV_PATH/bin and the easy way to find the path of any application on Linux systems is to use which command that in this case, you can use which superset to find the superset path ).

This is the superset service file that I use it on the production, hope to useful:

[Unit]

Description = Apache Superset Webserver Daemon

After = network.target

[Service]

PIDFile = /home/superset/superset-webserver.PIDFile

User = superset

Group = superset

Environment=SUPERSET_HOME=/home/superset

Environment=PYTHONPATH=/home/superset

WorkingDirectory = /home/superset

ExecStart =/home/superset/venv/bin/python3.7 /home/superset/venv/bin/gunicorn --workers 8 --worker-class gevent --bind 0.0.0.0:8888 --pid /home/superset/superset-webserver.PIDFile superset:app

ExecStop = /bin/kill -s TERM $MAINPID

[Install]

WantedBy=multi-user.target