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

https://www.jianshu.com/p/e1553b2185ae

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。