Superset 安裝配置


 

Superset是由Python語言編寫的Web應用,要求Python3.6的環境

conda是一個開源的包、環境管理器,可以用於在同一個機器上安裝不同Python版本的軟件包及其依賴,並能夠在不同的Python環境之間切換,Anaconda包括Conda、Python以及一大堆安裝好的工具包,比如:numpy、pandas等,Miniconda包括Conda、Python

安裝Miniconda

1 .wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

2. bash Miniconda3-latest-Linux-x86_64.sh

.................

Do you accept the license terms? [yes|no]
[no] >>>
Please answer 'yes' or 'no':'
>>> yes

Miniconda3 will now be installed into this location:
/home/datalink/miniconda3

- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below

[/home/datalink/miniconda3] >>> /opt/module/miniconda3   ----安裝目錄
PREFIX=/opt/module/miniconda3
Unpacking payload ...

 3.配置環境變量

vim /etc/profile

export CONDA_HOME=/opt/module/miniconda3
export PATH=$PATH:$CONDA_HOME/bin

source /etc/profile

4.取消激活base環境

Miniconda安裝完成后,每次打開終端都會激活其默認的base環境

(base) [datalink@slave1 ~]$ conda config --set auto_activate_base false

 

創建Python3.6環境

配置conda國內鏡像

[datalink@slave1 ~]$ conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/
[datalink@slave1 ~]$ conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
[datalink@slave1 ~]$ conda config --set show_channel_urls yes

[datalink@slave1 ~]$ cat ~/.condarc
auto_activate_base: false
channels:
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/
- defaults
show_channel_urls: true

創建Python3.6環境

[datalink@slave1 ~]$ conda create -n superset python=3.6
Collecting package metadata (current_repodata.json): |

conda環境管理常用命令如下:

創建環境:conda create -n env_name

查看所有環境:conda info --envs

刪除一個環境:conda remove -n env_name --all

 

[datalink@slave1 ~]$ conda create -n superset python=3.6  
Collecting package metadata (current_repodata.json): failed

UnavailableInvalidChannel: The channel is not accessible or is invalid.
channel name: anaconda/pkgs
channel url: http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs
error code: 404

You will need to adjust your conda configuration to proceed.
Use `conda config --show channels` to view your configuration's current state,
and use `conda config --show-sources` to view config file locations.

解決辦法:使用以下命令恢復默認源
[datalink@slave1 ~]$ conda config --remove-key channels
[datalink@slave1 ~]$ cat ~/.condarc
auto_activate_base: false
show_channel_urls: true

重新安裝

[datalink@slave1 ~]$ conda create -n superset python=3.6
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

environment location: /opt/module/miniconda3/envs/superset

added / updated specs:
- python=3.6

 

..........................

 

激活superset環境

[datalink@slave1 ~]$ conda activate superset
(superset) [datalink@slave1 ~]$

退出當前環境:

conda deactivate

查看python版本

[datalink@slave1 ~]$ python
Python 3.8.5 (default, Sep 4 2020, 07:30:14)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.

Superset部署

安裝依賴

[datalink@slave1 ~]$ sudo yum install -y python-setuptools

sudo yum install -y gcc gcc-c++ libffi-devel python-devel python-pip python-wheel openssl-devel cyrus-sasl-devel openldap-devel

安裝Superset

安裝(更新)setuptools和pip

[datalink@slave1 ~]$ pip install --upgrade setuptools pip -i https://pypi.douban.com/simple/

pip是python的包管理工具,可以和centos中的yum類比

安裝Superset

[datalink@slave1 ~]$ pip install apache-superset -i https://pypi.douban.com/simple/

說明:-i的作用是指定鏡像,這里選擇國內鏡像

初始化Superset數據庫

superset db upgrade

采用的數據庫是sqllite數據庫,是一個輕量級的數據量

 創建管理員用戶

給superset創建管理員用戶

export FLASK_APP=superset

[datalink@slave1 ~]$ export FLASK_APP=superset
[datalink@slave1 ~]$ flask fab create-admin
Username [admin]: datalink
User first name [admin]:
User last name [user]:
Email [admin@fab.org]:
Password:
Repeat for confirmation:
logging was configured successfully
INFO:superset.utils.logging_configurator:logging was configured successfully
/opt/module/miniconda3/lib/python3.8/site-packages/flask_caching/__init__.py:201: UserWarning: Flask-Caching: CACHE_TYPE is set to null, caching is effectively disabled.
warnings.warn(
No PIL installation found
INFO:superset.utils.screenshots:No PIL installation found
Recognized Database Authentications.
Admin User datalink created.

密碼同mysql密碼

 

初始化

superset init

 

啟動Superset

安裝gunicorn

[datalink@slave1 ~]$ pip install gunicorn -i https://pypi.douban.com/simple/
Looking in indexes: https://pypi.douban.com/simple/
Requirement already satisfied: gunicorn in /opt/module/miniconda3/lib/python3.8/site-packages (20.0.4)
Requirement already satisfied: setuptools>=3.0 in /opt/module/miniconda3/lib/python3.8/site-packages (from gunicorn) (54.1.2)

說明:gunicorn是一個Python Web Server,可以和java中的Tomcat類比

1.確保當前conda環境為superset

(superset) [datalink@slave1 ~]$ 

如果沒有,需要執行:conda activate superset

2.啟動

(superset) [datalink@slave1 ~]$ gunicorn --workers 5 --timeout 120 --bind slave1:8787 superset:app --daemon

 

 

(superset) [datalink@slave1 ~]$ curl http://192.168.130.62:8787
<html>
<head>
<title>Internal Server Error</title>
</head>
<body>
<h1><p>Internal Server Error</p></h1>

</body>
</html>

解決:

(superset) [datalink@slave1 ~]$ pip install gevent  -i https://pypi.douban.com/simple 

 

 

(superset) [datalink@slave1 ~]$ gunicorn --workers 5 --timeout 120 --bind slave1:8787 "superset.app:create_app()"
[2021-03-16 15:15:13 +0800] [16119] [INFO] Starting gunicorn 20.0.4
[2021-03-16 15:15:13 +0800] [16119] [INFO] Listening at: http://192.168.130.62:8787 (16119)
[2021-03-16 15:15:13 +0800] [16119] [INFO] Using worker: sync
[2021-03-16 15:15:13 +0800] [16122] [INFO] Booting worker with pid: 16122
[2021-03-16 15:15:13 +0800] [16123] [INFO] Booting worker with pid: 16123
[2021-03-16 15:15:13 +0800] [16124] [INFO] Booting worker with pid: 16124
[2021-03-16 15:15:13 +0800] [16125] [INFO] Booting worker with pid: 16125
[2021-03-16 15:15:13 +0800] [16126] [INFO] Booting worker with pid: 16126
logging was configured successfully

 

 

(superset) [datalink@slave1 ~]$ gunicorn --workers 5 --timeout 120 --bind slave1:8787 "superset.app:create_app()" --daemon
(superset) [datalink@slave1 ~]$

說明:

–workers:指定進程個數

–timeout:worker進程超時時間,超時會自動重啟

–bind:綁定本機地址,即為Superset訪問地址

–daemon:后台運行

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM