close

安裝完 ubuntu 18.04 後
根據 https://superset.apache.org/installation.html#getting-started
執行以下命令

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

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

pip install virtualenv
python3 -m venv venv
. venv/bin/activate
pip install --upgrade setuptools pip

# Install superset
pip install apache-superset

# Initialize the database
superset db upgrade

# Create an admin user (you will be prompted to set a username, first and last name before setting a password)
$ export FLASK_APP=superset
superset fab create-admin

# Load some data to play with
superset load_examples

# 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

如果在本地訪問的話,是可以正常使用。

在其他機器訪問的話會被拒絕,要加上  --host 0.0.0.0  ,服務器才可以被其他IP訪問,參考 https://github.com/apache/incubator-superset/issues/8682

一開始以為是防火墻問題,後來才知道,WEB BROSWER 顯示拒絕連線,應該不是防火墻擋了,Linux 防火墻擋了的話會TIMEOUT 沒有回應,拒絕連線是主機根本沒有在Listening這個 port,

看了wireshark , 主機回應了 RST ,如果是防火墻會直接DROP掉,不回應。


superset run --with-threads --reload --debugger --host 0.0.0.0

接下來安裝 production 環境

sudo apt update

sudo apt install nginx

pip install gunicorn

gunicorn \
      -w 10 \
      -k gevent \
      --timeout 120 \
      -b  0.0.0.0:6666 \
      --limit-request-line 0 \
      --limit-request-field_size 0 \
      --statsd-host localhost:8125 \
      "superset.app:create_app()"

建議不要用6666 port ,CHROME 會視為不安全

用vim編輯器打開:/etc/nginx/sites-available/default的設定檔

打開之後,找到server區塊,並把下面這一行加進去。

若location /的區塊裡有try_files $uri $uri/ =404;也請記得要刪除。

1
2
3
4
location / {
proxy_pass http://127.0.0.1:6666;
 
}

接著檢查設定語法是否正確並重新reload config

1
2
3
sudo nginx -t
 
sudo service nginx reload

參考https://peterli.website/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8nginx-gunicorn%E8%88%87supervisor-%E9%83%A8%E7%BD%B2%E4%B8%80%E5%80%8Bflask-app/

sudo apt install libpq-dev python3-dev
pip install psycopg2
arrow
arrow

    Felix 發表在 痞客邦 留言(0) 人氣()