Superset问题汇总

superset概述

Superset 是一款由 Airbnb 开源的“现代化的企业级 BI(商业智能) Web 应用程序”,其通过创建和分享 dashboard,为数据分析提供了轻量级的数据查询和可视化方案。
 Superset 的前端主要用到了 ReactNVD3/D3,而后端则基于 Python 的 Flask 框架和 PandasSQLAlchemy 等依赖库,主要提供了这几方面的功能:

  • 集成数据查询功能,支持多种数据库,包括 MySQL、PostgresSQL、Oracle、SQL Server、SQLite、SparkSQL 等,并深度支持 Druid
  • 通过 NVD3/D3 预定义了多种可视化图表,满足大部分的数据展示功能。如果还有其他需求,也可以自开发更多的图表类型,或者嵌入其他的 JavaScript 图表库(如 HighCharts、ECharts)。
  • 提供细粒度安全模型,可以在功能层面和数据层面进行访问控制。支持多种鉴权方式(如数据库、OpenID、LDAP、OAuth、REMOTE_USER 等)。

superset安装部署

Superset官网地址:http://superset.apache.org/

1、安装Python环境

Superset是由Python语言编写的Web应用,要求Python3.6的环境

1
bash Miniconda3-latest-Linux-x86_64.sh
  • 配置环境变量
1
2
3
# conda env
export CONDA_HOME=/opt/moudle/miniconda3
export PATH=$PATH:$CONDA_HOME/bin
  • 取消激活base环境
1
conda config --set auto_activate_base false

2 、创建Python3.6环境

  • 配置conda国内镜像
1
2
3
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
  • *创建Python3.6 *环境
1
conda create --name superset python=3.6
  • 激活superset环境
1
conda activate superset

3、Superset部署

  • 安装依赖
1
2
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
1
2
3
4
5
6
7
8
9
10
11
# 安装(更新)setuptools和pip
pip install --upgrade setuptools pip -i https://pypi.douban.com/simple/
# 安装Supetset
pip install apache-superset -i https://pypi.douban.com/simple/
# 初始化Supetset数据库
superset db upgrade
# 创建管理员用户
export FLASK_APP=superset
flask fab create-admin
# Superset初始化
superset init

4、启动Supterset

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 安装gunicorn
pip install gunicorn -i https://pypi.douban.com/simple/

# 启动Superset

gunicorn \
-w 10 \
--timeout 120 \
-b 10.101.179.205:8787 \
--limit-request-line 0 \
--limit-request-field_size 0 \
--statsd-host localhost:8125 \
"superset.app:create_app()"
--daemon

5、停止Superset

1
ps -ef | awk '/gunicorn/ && !/awk/{print $2}' | xargs kill -9

6、登录Superset

访问http://hadoop102:8787

Question

1、配置Hive数据源错误

ERROR: {"error": "Connection failed!\n\nThe error message returned was:\nCan't load plugin: sqlalchemy.dialects:jdbc.hive"}

1.1、在Ambari下的HDP中

1
2
3
4
cd /usr/hdp/3.1.4.0-315/superset/bin/
./pip3.6 install sasl
./pip3.6 install thrift_sasl
./pip3.6 install pyhive

1.2、Test

1
2
3
4
5
6
[root@hadoop101 bin]# ./python3.6
Python 3.6.9 (default, Aug 23 2019, 05:08:01)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sqlalchemy import create_engine
>>> engine = create_engine('hive://hive@hadoop101:10000/default')