1、准备
Anaconda3环境
注意:建议使用python3.7, 兼容性更好
配置conda国内镜像
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda config --set show_channel_urls yes
2、创建环境
1、创建并激活一个环境使用”conda create”命令:
conda create --name superset python=3.7
2、激活这个新环境Linux,OS X:
conda activate superset
或者
source activate superset
Windows:
activate snowflake
说明:退出当前环境
conda deactivate
3、 安装依赖
安装Superset之前,需安装以下所需依赖
sudo yum install -y python-setuptools
sudo yum install -y gcc gcc-c++ libffi-devel python3-devel python-pip python-wheel openssl-devel cyrus-sasl-devel openldap-devel
3、安装Superset1.0
1、安装(更新)setuptools和pip
pip install --upgrade setuptools pip -i https://pypi.douban.com/simple/
说明:pip是python的包管理工具,可以和centos中的yum类比
2、安装Supetset 1.0
pip install apache-superset -i https://pypi.tuna.tsinghua.edu.cn/simple/
3、连接mysql配置
pip install mysqlclient -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install pymssql -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install pillow -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install mysqlclient 如果报错
错误如下:
OSError: mysql_config not found
解决:
安装依赖:
yum install mysql-devel gcc gcc-devel python-devel
重新安装 pip install mysqlclient
4、初始化Supetset数据库
superset db upgrade
5、创建管理员用户
export FLASK_APP=superset
flask fab create-admin
注意: 如果 flask fab create-admin 不可用使用如下命令创建用户:
superset fab create-admin
superset load_examples
连接失败需要重写源码
源码位置:
site-packages/superset/examples/helpers.py
可以下载以后改写源码进行本地导入
6、Superset初始化
superset init
7、启动Superset
superset run -p 8288 -h 10.15.1.54 --with-threads --reload --debugger
关闭superset以及其它操作查看:
https://blog.csdn.net/qq_42502354/article/details/107388059
4、对接数据源
1、对接MySQL数据源
安装依赖
conda install mysqlclient
连接方式:
mysql://user:password@ip:port/db_name
说明:对接不同的数据源,需安装不同的依赖,以下地址为官网说明
http://superset.apache.org/installation.html#database-dependencies
2、对接Hive数据源
pip install sasl
pip install thrift
pip install thrift-sasl
pip install pyhive
连接方式:
hive://ip:10000
官网:
hive://hive@{hostname}:{port}/{database}
3、连接impala
pip install impala
连接方式:
impala:///user:password@{hostname}:21050/{database}
官网:
impala://{hostname}:{port}/{database}
4、对接kylin
pip install kylinpy
官网:
kylin://<username>:<password>@<hostname>:<port>/<project>?<param1>=<value1>&<param2>=<value2>
5、对接Spark SQL
pip install pyhive
官网:
hive://hive@{hostname}:{port}/{database}
6、对接clickhouse
pip install sqlalchemy-clickhouse
superset连接clickhouse失败,需要对依赖进行版本下降
默认 infi.clickhouse_orm=2.0
pip uninstall infi.clickhouse_orm
pip install infi.clickhouse_orm==1.0.4
官网:
clickhouse://{username}:{password}@{hostname}:{port}/{database}
7、对接persto
pip install pyhive
presto://ip:port/**/db_name
官网
presto://
8、对接SQL Server
pip install pymssql
官网:
mssql://