Docker 安装Apache Superset 并实现汉化和快速入门

心已赠人 2024-04-23 16:00 154阅读 0赞

什么是Apache Superset

Apache Superset是一个现代化的企业级商业智能Web应用程序。Apache Superset 支持用户的各种数据类型可视化和数据分析,支持简单图饼图到复杂的地理空间图表。Apache Superset 是一个轻量级、简单化、直观化、可配置的BI 框架。

Docker 安装Apache Superset

Docker 检索 superse

  1. [root@localhost ~]# docker search superset
  2. NAME DESCRIPTION STARS OFFICIAL AUTOMATED
  3. amancevice/superset Superset on Debian+Python3 278 [OK]
  4. apache/superset Apache Superset 238
  5. ******

Docker 下载并查看superset镜像

  1. [root@localhost ~]# docker pull apache/superset
  2. Using default tag: latest
  3. latest: Pulling from apache/superset
  4. 0e29546d541c: Pull complete
  5. 9b829c73b52b: Pull complete
  6. cb5b7ae36172: Pull complete
  7. 6494e4811622: Pull complete
  8. ******
  9. [root@localhost ~]# docker images
  10. REPOSITORY TAG IMAGE ID CREATED SIZE
  11. nginx latest 0e901e68141f 18 months ago 142MB
  12. mysql 5.7 2a0961b7de03 18 months ago 462MB
  13. apache/superset latest 3e8fac582908 23 months ago 1.69GB
  14. ******

创建superset 挂载目录:/opt/superset

  1. [root@localhost opt]# mkdir /opt/superset

运行superset 容器

  1. [root@localhost opt]# docker run --name my_superset -d -p 8088:8088 -v /opt/superset:/home/superset apache/superset
  2. 8797809b77f275d4655d9bc80a1e7f227330a0973bf6ab7d1031be7a0e70b54d

查看正在运行容器

  1. [root@localhost opt]# docker ps
  2. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  3. 8797809b77f2 apache/superset "/bin/sh -c /usr/bin…" 43 seconds ago Up 42 seconds (healthy) 0.0.0.0:8088->8088/tcp my_superset
  4. ******

进入superset镜像

  1. [root@localhost opt]# docker exec -it my_superset /bin/bash

superset 数据库初始化

  1. superset@8797809b77f2:/app$ superset db upgrade
  2. logging was configured successfully
  3. 2023-12-07 15:25:41,240:INFO:superset.utils.logging_configurator:logging was configured successfully
  4. 2023-12-07 15:25:41,259:INFO:root:Configured event logger of type <class 'superset.utils.log.DBEventLogger'>
  5. /usr/local/lib/python3.8/site-packages/flask_caching/__init__.py:201: UserWarning: Flask-Caching: CACHE_TYPE is set to null, caching is effectively disabled.
  6. warnings.warn(
  7. WARNI [alembic.env] SQLite Database support for metadata databases will be removed in a future version of Superset.
  8. INFO [alembic.runtime.migration] Context impl SQLiteImpl.
  9. ******

superset 应用初始化

  1. superset@8797809b77f2:/app$ superset init
  2. logging was configured successfully
  3. 2023-12-07 15:26:15,395:INFO:superset.utils.logging_configurator:logging was configured successfully
  4. 2023-12-07 15:26:15,411:INFO:root:Configured event logger of type <class 'superset.utils.log.DBEventLogger'>
  5. /usr/local/lib/python3.8/site-packages/flask_caching/__init__.py:201: UserWarning: Flask-Caching: CACHE_TYPE is set to null, caching is effectively disabled.
  6. warnings.warn(
  7. Syncing role definition
  8. 2023-12-07 15:26:32,491:INFO:superset.security.manager:Syncing role definition
  9. Syncing Admin perms
  10. ******

superset 设置管理员账户

  1. superset@8797809b77f2:/app$ export FLASK_APP=superset
  2. superset@8797809b77f2:/app$ flask fab create-admin
  3. Username [admin]: admin
  4. User first name [admin]: first
  5. User last name [user]: last
  6. Email [admin@fab.org]: admin@test.com
  7. Password:
  8. Repeat for confirmation:
  9. logging was configured successfully
  10. 2023-12-07 15:28:24,832:INFO:superset.utils.logging_configurator:logging was configured successfully
  11. ******

温馨提示:设置superset 管理员账户为:admin 密码:123456
加载superset 示例Demo

  1. superset@8797809b77f2:/app$ superset load_examples
  2. logging was configured successfully
  3. 2023-12-07 15:29:03,488:INFO:superset.utils.logging_configurator:logging was configured successfully
  4. 2023-12-07 15:29:03,501:INFO:root:Configured event logger of type <class 'superset.utils.log.DBEventLogger'>
  5. /usr/local/lib/python3.8/site-packages/flask_caching/__init__.py:201: UserWarning: Flask-Caching: CACHE_TYPE is set to null, caching is effectively disabled.
  6. warnings.warn(
  7. Creating database reference for examples
  8. 2023-12-07 15:29:07,167:INFO:superset.utils.core:Creating database reference for examples
  9. Loading examples metadata and related data into examples
  10. Creating default CSS templates
  11. Loading [World Bank's Health Nutrition and Population Stats]
  12. Traceback (most recent call last):
  13. File "/usr/local/lib/python3.8/urllib/request.py", line 1354, in do_open
  14. h.request(req.get_method(), req.selector, req.data, headers,
  15. File "/usr/local/lib/python3.8/http/client.py", line 1256, in request
  16. self._send_request(method, url, body, headers, encode_chunked)
  17. ******

温馨提示:由于Paython 版本对语法支持差异,示例Demo会报错,但不会影响我们的使用。

superset 管理平台访问

339f8a5b661a4bb199d12e0db7bef31d.png

Apache Superset 汉化

核心命令:

  1. # 进入superset 镜像
  2. docker exec -it -u root my_superset /bin/bash
  3. # 替换/app/superset/config.py 配置文件
  4. sed -i "s/BABEL_DEFAULT_LOCALE = \"en/BABEL_DEFAULT_LOCALE = \"zh/g" superset/config.py
  5. # 替换/app/superset/config.py 配置文件
  6. sed -i "s/LANGUAGES = {}/# LANGUAGES = {}/g" superset/config.py
  7. #重新启动superset 镜像
  8. docker restart my_superset

superset 汉化界面

71ee56f18323419a89288d6b523e2f34.png

Apache Superset 快速入门

第一步:添加Databases(数据库)

9f237d288ae84ebcbe6a6c6c088d6dc3.png

提示:本次演示添加数据库为MySQL 8

9b3d63c864714c33bf2351bd3d97702e.png

填充 MYSQL 8 数据库连接信息

e7d1a8d9cc1a491e845a6edad7d5ae80.png

最后数据库查询列表展示我新增的MYSQL 8 数据库。

69c5daa2addc4ec89776f2423520ac93.png

第二步:添加Datasets(数据级)

3e33eb4aa35c425787ae838abf99b044.png

填充 Dataset/数据级信息

499d03c49d4f4412aed9c29578990993.png

最后数据级查询列表展示我新增的base_building数据级。

d9be0b249a6743cab927380601989138.png 第三步:点击Datasets(数据级) ,创建Chart(图表)

默认初始化Chart (图表)编辑页面

4f90dde2e0a844718eecbfb9319283b5.png

我基于base_building/数据集创建查询building_no\building_name\building_address的图表.

1f5746a53bc4465297323624f83d09ed.png

第四步:查询Chart(图表),并在DashBoard(仪表盘)中显示。

查询自己创建的Chart图表

4f840dd13b21450e8670ac95accf5dfd.png

新增看板 ,选择创建的图表

b783d3c39f364a35a60dc90f50fd55d4.png

最终效果展示:

90c362130d2c46d1af63e172d4578062.png

参考资料:

Apache Superset 官网:https://superset.apache.org/docs/intro

Apache Superset GitHub 地址 : https://github.com/apache/superset

SuperSet 最新 Docker 部署文档(含元数据库切换、汉化、镜像导出)

发表评论

表情:
评论列表 (有 0 条评论,154人围观)

还没有评论,来说两句吧...

相关阅读