数据可视化的web工具 apache-superset

文章目录

  • 简介
  • 安装
    • window10
    • Ubuntu1804
    • CentOS8

简介

Superset是一款由Airbnb开源的、目前由Apache孵化的,基于Flask-appbuilder搭建的“现代化的企业级BI(商业智能)Web应用程序”,它通过创建和分享dashboard,为数据分析提供了轻量级的数据查询和可视化方案。

安装

官网仅仅提供了linux、macos、docker的安装
apache-superset

window10

  1. 创建一个目录superset_,内部创建python虚拟环境(python3.9)
# superset_目录
python -m venv superset_venv

# 激活虚拟环境
cd superset_venv/Scripts/
activate # 激活
  1. 下载源码
    在superset_目录下(虚拟环境的同级目录),下载superset的源码。
# git 克隆
git clone https://github.com/apache/superset.git

# 若无法拉取,则直接打开网址,直接复制

然后解压,并进入superset项目目录。

  1. 打开一个终端,并安装superset
# 安装依赖
pip install -e .
# 安装superset
pip install apache-superset
  1. 设置配置文件
    在superset项目根目录下,创建superset_config.py配置文件,内部编辑如下。
  • 重点修改 SECRET_KEY,使用openssl rand -base64 42 生成随机秘钥。
  • 重点修改SQLALCHEMY_DATABASE_URI
# 
# Superset specific config
ROW_LIMIT = 5000
# 服务端口
SUPERSET_WEBSERVER_PORT = 8088

# Flask App Builder configuration
# Your App secret key will be used for securely signing the session cookie
# and encrypting sensitive information on the database
# Make sure you are changing this key for your deployment with a strong key.
# You can generate a strong key using `openssl rand -base64 42`.
# Alternatively you can set it with `SUPERSET_SECRET_KEY` environment variable.
SECRET_KEY = 'xQyq5JVwd7q6cw1yXjE/P+YyirBzP7hEWTn+S0ux6GuUkPzDyPoVLhp7'

# The SQLAlchemy connection string to your database backend
# This connection defines the path to the database that stores your
# superset metadata (slices, connections, tables, dashboards, ...).
# Note that the connection information to connect to the datasources
# you want to explore are managed directly in the web UI
SQLALCHEMY_DATABASE_URI = 'sqlite:///C:\\Users\\lenovo\\Desktop\\superset_/superset.db'

# Flask-WTF flag for CSRF
WTF_CSRF_ENABLED = True
# Add endpoints that need to be exempt from CSRF protection
WTF_CSRF_EXEMPT_LIST = []
# A CSRF token that expires in 1 year
WTF_CSRF_TIME_LIMIT = 60 * 60 * 24 * 365

# Set this API key to enable Mapbox visualizations
MAPBOX_API_KEY = ''
  1. 设置环境变量,并初始化数据库
# 终端下
set FLASK_APP=superset  # 本身就是一个flask应用
# 初始化数据库
superset db upgrade

如下表示半成功,数据库配置不正确;修改数据库配置后,再次执行superset db upgrade会输出大量的日志,表示成功。
数据可视化的web工具 apache-superset_第1张图片
 
初始化失败的情况:
数据可视化的web工具 apache-superset_第2张图片
因为默认的秘钥不安全,必须自己在superset项目下使用superset_config.py进行配置。

可以查看superset命令的帮助信息:superset --help
数据可视化的web工具 apache-superset_第3张图片

  1. 创建用户,并初始化
# 终端下,创建管理用户
superset fab create-admin

# 下载 superset 案例
superset load-examples  # 下载失败

# 创建默认的角色、权限
superset init
  1. 启动superset这个flask应用程序
    启动应用程序,并在浏览器中访问。
# 运行后端flask项目
superset run -p 5000 --with-threads --reload --debugger

浏览器访问,http://localhost:5000/
数据可视化的web工具 apache-superset_第4张图片
 
使用创建的管理员账户登录。
数据可视化的web工具 apache-superset_第5张图片
此时发现没有页面数据。

  1. 处理前端项目
# 进入前端项目
cd superset-frontend
# 安装依赖
npm install

# 报错可以尝试升级,然后再次安装
npm install -g npm
npm install 

# 安装完成,启动前端项目
npm run dev

数据可视化的web工具 apache-superset_第6张图片
数据可视化的web工具 apache-superset_第7张图片
前端项目启动时,有几个报错,好像不影响使用。

 
在前后端服务都启动时,刷新浏览器。
数据可视化的web工具 apache-superset_第8张图片

 
数据可视化的web工具 apache-superset_第9张图片

 

Ubuntu1804

pass

CentOS8

pass

你可能感兴趣的:(可视化工具,apache,superset,数据可视化,BI)