SUPERSET安裝步驟及問題排查

superset安裝過程是挺痛苦的,花了一天多的時間終于安裝好了,把過程記錄下來,供大家參考。希望能節約些大家寶貴的時間,如果碰到問題可以留言。

環境

系統:CentOS Linux release 7.2

python:python3.6.6

數據庫:MYSQL5.7

步驟

  1. 基礎包安裝

    配置yum和安裝編譯環境所需開發包

    #配置yum源
    rpm -ivh https://centos7.iuscommunity.org/ius-release.rpm
    #安裝epel源
    yum install -y epel-release
    yum install -y yum-utils && yum-config-manager --enable epel
    #安裝編譯環境
    yum install gcc gcc-c++ libffi-devel python-devel python-pip python-wheel openssl-devel libsasl2-devel openldap-devel
    
    
  2. 安裝python3.6.6版本

    由于系統自帶python2.7.5版本,安裝時遇到些問題,改用python3

    #下載python3.6.6版本
    wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz
    #編譯安裝
    ./configure --prefix=/usr/local/python3
    make && make install</pre>
    
    
  3. 配置python虛擬環境

    后面的所有安裝包基本都指定選擇阿里源,外國源實在太慢

    #用絕對路徑安裝
    /usr/local/python3/bin/pip3 install virtualenv -i https://mirrors.aliyun.com/pypi/simple
    #創建虛擬環境
    cd /data
    /usr/local/python3/bin/python3 -m venv superset-py3
    #激活虛擬機環境
    cd /data/superset-py3
    source ./bin/activate
    #激活后顯示如下
    (superset-py3) [root@superset bin]# 
    #升級pip和setup
    pip3 install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple
    pip3 install --upgrade setuptools pip -i https://mirrors.aliyun.com/pypi/simple</pre>
    
    
  4. 配置數據庫相關

    創建賬號和數據庫(MYSQL)

    --創建數據庫
    create database superset default charset utf8;
    --創建訪問賬號
    grant all on superset.* to superset@'%' identified by 'superset'</pre>
    

    創建數據庫配置文件:

    #-*- coding: utf-8 -*-
    #該文件到虛擬環境bin目錄:如/data/superset-py3/bin
    #===============superset_config.py開始================
    import sys
    #---------------------------------------------------------
    #Superset specific config
    #---------------------------------------------------------
    ROW_LIMIT = 5000
    SUPERSET_WORKERS = 4
    SUPERSET_WEBSERVER_PORT = 8888
    #---------------------------------------------------------
    #Flask App Builder configuration
    #---------------------------------------------------------
    #Your App secret key
    SECRET_KEY = '\2\1thisismyscretkey\1\2\e\y\y\h'
    #元數據存儲默認使用的是sqlite。
    #SQLALCHEMY_DATABASE_URI = 'sqlite:////path/to/superset.db'
    #mysql://用戶名:密碼@192.168.1.162/數據庫名?charset=utf8
    SQLALCHEMY_DATABASE_URI = 'mysql://superset:superset@localhost/superset?charset=utf8'
    #Flask-WTF flag for CSRF
    WTF_CSRF_ENABLED = True
    #Set this API key to enable Mapbox visualizations
    MAPBOX_API_KEY = ''
    #漢化
    BABEL_DEFAULT_LOCALE='zh'
    LANGUAGES = {
    'zh': {'flag': 'cn', 'name': 'Chinese'},
    'en': {'flag': 'us', 'name': 'English'}
    }
    #=============== superset_config.py結束===============</pre>
    
    
  5. 安裝配置superset

    安裝mysql客戶端和mysqlclient,支持對mysql數據庫的訪問

    #安裝mysql開發包
    yum install mysql-devel
    #安裝python通過導入MySQLdb訪問數據庫包
    pip install mysqlclient==1.3.6 -i https://mirrors.aliyun.com/pypi/simple/
    #安裝pymssql支持sqlserver訪問
    pip3 install pymssql -i https://mirrors.aliyun.com/pypi/simple
    ?</pre>
    #安裝superset選擇了0.26.3版本,中間遇到不少包版本不支持的問題
    pip install superset==0.26.3 -i https://mirrors.aliyun.com/pypi/simple/
    #創建管理員賬號,數據庫初始化,根據提示輸入賬號密碼郵箱等信息。(遇到了問很多題見問題排查)
    cd /data/superset-py3/bin
    ./fabmanager create-admin --app superset
    (superset-py3) [root@supperset bin]# ./fabmanager create-admin --app superset
    Username [admin]: admin
    User first name [admin]: admin
    User last name [user]: admin
    Email [admin@fab.org]: f
    Password: 
    Repeat for confirmation: 
    Loaded your LOCAL configuration at [/data/superset-py3/bin/superset_config.py]
    Recognized Database Authentications.
    Admin User admin created.
    #數據庫升級
    superset db upgrade
    #裝載一些案例,可選擇不裝載
    superset load_examples
    #superset初始化
    superset init
    #以debug方式啟動服務,去掉-d可以關掉debug
    superset runserver -d</pre>
    
    
  6. 登陸驗證

    瀏覽器輸入:

    http://localhost:8888/login

    頁面如下:

image-20200514164756599.png

登陸后就可以自己研究研究啦,安裝到這就基本結束了。

問題排查

./fabmanager create-admin --app superset
#執行這個報了很多錯誤,看看各位是否遇到么,解決如下:
Was unable to import superset Error: Install 'email_validator' for email validation support.
#安裝郵箱校驗組件就可以了
pip install email_validator
#配置文件開始加入了reload,這個在python2.7可以加入,python3之后可以去掉了。
Was unable to import superset Error: name 'reload' is not defined
配置文件中去掉reload
#需要安裝panda低版本,默認安裝的版本比較高,通過下面命令看下自己安裝的版本
pip list | grep pandas
pandas             0.23.4
Was unable to import superset Error: cannot import name '_maybe_box_datetimelike'
(superset-py3) [root@supperset bin]# pip install pandas==0.23.4 -i https://mirrors.aliyun.com/pypi/simple/ 
#報marketdown錯誤,選擇安裝低版本解決該問題
Was unable to import superset Error: markdown() takes 1 positional argument but 2 were given
(superset-py3) [root@supperset bin]# pip install markdown==2.6.11 -i https://mirrors.aliyun.com/pypi/simple/ 
?
------------------------------------------------------------------------------
#執行superset db upgrade報錯,需要修改289ce07647b_add_encrypted_password_field.py的代碼:
 File "/data/superset-py3/lib/python3.6/site-packages/sqlalchemy/dialects/mysql/base.py", line 2047, in visit_VARCHAR
 "VARCHAR requires a length on dialect %s" % self.dialect.name
sqlalchemy.exc.CompileError: VARCHAR requires a length on dialect mysql
vi /data/superset-py3/lib/python3.6/site-packages/superset/migrations/versions/289ce07647b_add_encrypted_password_field.py
#把加密類型去掉就可以了
原來:EncryptedType(sa.String(1024)), nullable=True))
修改后:sa.String(1024), nullable=True))

參考安裝文檔:

https://blog.51cto.com/14033037/2331657

http://www.lxweimin.com/p/e1553b2185ae

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。