docker安装superset及使用

1、获取docker镜像

[root]# docker search superset
NAME                           DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
amancevice/superset            Superset on Debian+Python3                      239                                     [OK]
tylerfowler/superset           An extendable Docker image for Airbnb's Supe…   15                                      
preset/superset                Apache Superset (incubating) is a modern, en…   7                                       
crobox/superset                Superset + Clickhouse docker image              3                                       [OK]
maedamikio/superset                                                            3                                       
tyyzqmf/superset               根据amancevice/superset修改的镜像 主要解决su…              2                                       [OK]
ganshanshan/superset_tddv      tddv superset                                   2                                       [OK]
huksley/superset               AirBnB Superset 0.28 with MySQL driver          2                                       [OK]
dailyhotel/superset            Dockerized Superset                             2                                       [OK]
starburstdata/superset         Apache Superset docker container                1                                       [OK]
pietrocannalire/superset       Superset Image                                  1                                       [OK]
muicoder/superset              Superset is a data exploration platform desi…   1                                       [OK]
noenv/superset                 Superset Docker Image                           1                                       [OK]
burtdatacloud/superset-mysql   Superset MySQL                                  0                                       
mmontagna/superset-docker      superset-docker                                 0                                       
nis365/superset                This docker image is built from amancevice/s…   0                                       
ganshanshan/superset1          superset1                                       0                                       [OK]
gavrikov/superset                                                              0                                       
dockerdegbert/superset                                                         0                                       
chethanuk/superset                                                             0                                       
wenchma/superset               Own superset build                              0                                       [OK]
lrosenman/superset             superset                                        0                                       
harisekhon/superset            Superset open source analytics UI by AirBNB     0                                       [OK]
tddv/superset                  Superset is come from airbub superset open s…   0                                       [OK]
peertopark/superset            Peer to Park Superset                           0                                       
[root]# docker pull amancevice/superset
Using default tag: latest
latest: Pulling from amancevice/superset
Digest: sha256:1f7e88850066141a60feac844834deeee25fe0d8ca8e612144e4c83ca0648e84
Status: Image is up to date for amancevice/superset:latest
docker.io/amancevice/superset:latest

查看镜像

[root]# docker images
REPOSITORY                                                      TAG                 IMAGE ID            CREATED             SIZE
redis                                                           latest              36304d3b4540        4 days ago          104MB
amancevice/superset                                             latest              2b49a84a0360        4 weeks ago         2.01GB

2、安装

#创建挂载目录
>  mkdir -p /opt/docker/superset/conf & mkdir -p /opt/docker/superset/data
#启动
>  docker run --name superset -u 0 -d -p 8088:8088 -v /opt/docker/superset/conf:/etc/superset -v /opt/docker/superset/data:/var/lib/superset amancevice/superset
#查看启动容器
> docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS                 PORTS                    NAMES
84c729a89cd1        amancevice/superset:latest   "gunicorn superset.a…"   4 days ago          Up 4 hours (healthy)   0.0.0.0:8088->8088/tcp   superset
#用户初始化
>docker exec -it superset superset-init

修改配置文件

>vim /opt/docker/superset/conf/superset_config.py
#---------------------------------------------------------
# Superset specific config
#---------------------------------------------------------
ROW_LIMIT = 5000

SUPERSET_WEBSERVER_PORT = 8088
#---------------------------------------------------------

#---------------------------------------------------------
# Flask App Builder configuration
#---------------------------------------------------------
# Your App secret key
SECRET_KEY = '\2\1thisismyscretkey\1\2\e\y\y\h'

# 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:////var/lib/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 = ''

重启

>docker restart superset 
>docker exec -it superset superset-init

3、初始化设置

# 创建用户名和密码
> docker exec -it -u root 84c729a89cd1 fabmanager create-admin --app superset

# 初始化数据库
> docker exec -it 84c729a89cd1 superset db upgrade

# 导入示例数据
> docker exec -it 84c729a89cd1 superset load_examples

# 创建默认角色和权限
> docker exec -it 84c729a89cd1 superset init

# 启动服务
> docker exec -it 84c729a89cd1 superset runserver

4、登录

访问地址:http://ip:8088/

docker安装superset及使用_第1张图片

汉化

docker安装superset及使用_第2张图片

5、配置数据库

docker安装superset及使用_第3张图片

 

docker安装superset及使用_第4张图片

6、表配置

docker安装superset及使用_第5张图片

 

docker安装superset及使用_第6张图片

 

保存之后回到 table 页,编辑刚才添加的 table,切换到列列表视图,可以看到 table 中包含的所有的列:

docker安装superset及使用_第7张图片

6.1 探索数据

在 table 页直接点击 user,进入 table explore 页:

docker安装superset及使用_第8张图片

选择需要的图表类型

docker安装superset及使用_第9张图片

查询表类型展示

docker安装superset及使用_第10张图片

 

查看sql

docker安装superset及使用_第11张图片

保存图表

docker安装superset及使用_第12张图片

6.2 联表查询

Superset不能直接使用联合查询,只能从单个表查找数据。但是它提供的视图的概念,可以编写视图SQL,最终在视图上执行单表查询操作。视图的配置见下图:

docker安装superset及使用_第13张图片

sql示例

SELECT
	u.id,
	u.NAME,
	u.age,
	u.points,
	u.STATUS,
	u.create_time,
	u.update_time,
	uc.NO 
FROM
	user u,
	user_class uc 
WHERE
	u.id = uc.user_id

 

 

 

 

你可能感兴趣的:(工具,superset,bi,可视化图表,数据库)