当前位置: 首页 > news >正文

【OceanBase】使用 Superset 连接 OceanBase 数据库并进行数据可视化分析

文章目录

  • 前言
  • 一、前提条件
  • 二、操作步骤
    • 2.1 准备云主机实例
    • 2.2 安装docker-compose
    • 2.3 使用docker-compose安装Superset
      • 2.3.1 克隆 Superset 的 GitHub 存储库
      • 2.3.2 通过 Docker Compose 启动 Superset
    • 2.4 开通 OB Cloud 云数据库
    • 2.5 获取连接串
    • 2.6 使用 Superset 连接 OceanBase 数据库
    • 2.7 导入数据并创建表
    • 2.8 在 Superset 中创建数据集
    • 2.9 配置可视化图表
  • 三、参考链接

前言

在当今大数据与实时分析快速发展的时代,数据的高效存储、处理与可视化已成为推动业务决策的重要手段。OceanBase作为一款高性能分布式关系型数据库,凭借其卓越的事务处理能力与扩展性,广泛应用于金融、电信等领域。然而,如何将OceanBase的数据资产与强大的数据可视化工具结合,以直观、易懂的方式呈现数据价值,是一个备受关注的话题。


Apache Superset是一款开源数据可视化与数据探索工具,具有丰富的图表和仪表盘功能,支持多种数据库连接和实时交互分析。通过将Superset与OceanBase相结合,企业可以快速构建从数据存储到数据洞察的完整链路,实现更高效、更直观的数据分析与决策支持。


本文旨在详细介绍如何使用Superset连接OceanBase数据库,并通过可视化分析工具进行数据探索和展示。无论您是数据库开发者还是数据分析师,都可以通过本指南,快速掌握从OceanBase到Superset的数据可视化分析流程。

一、前提条件

  • 准备一台云主机实例;

  • 安装好Docker服务;

  • 完成配置并运行 Superset;

  • 准备好可用的数据集;

二、操作步骤

2.1 准备云主机实例

实例信息实例参数备注
主机名superset
操作系统Ubuntu 24.04.1 LTS
系统内核Linux 6.8.0-1016-aws
实例大小m5.2xlarge
vCPU/内存 (GiB)8C/32G

2.2 安装docker-compose

下载docker compose

## To download and install Compose standalone, run:
root@superset:~# curl -SL https://github.com/docker/compose/releases/download/v2.30.3/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose% Total    % Received % Xferd  Average Speed   Time    Time     Time  CurrentDload  Upload   Total   Spent    Left  Speed0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 61.0M  100 61.0M    0     0  19.5M      0  0:00:03  0:00:03 --:--:-- 35.9M## Apply executable permissions to the standalone binary in the target path for the installation.
root@superset:~# chmod +x /usr/local/bin/docker-compose## Test and execute Compose commands using docker-compose.
root@superset:~# ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

image-20241203223516441

查看docker-compose的版本号。

## root@superset:~# docker-compose version
root@superset:~# docker-compose version
Docker Compose version v2.30.3

2.3 使用docker-compose安装Superset

2.3.1 克隆 Superset 的 GitHub 存储库

git clone --depth=1  https://github.com/apache/superset.git
root@superset:~# git clone --depth=1  https://github.com/apache/superset.git
Cloning into 'superset'...
remote: Enumerating objects: 6775, done.
remote: Counting objects: 100% (6775/6775), done.
remote: Compressing objects: 100% (5505/5505), done.
remote: Total 6775 (delta 2198), reused 3319 (delta 1125), pack-reused 0 (from 0)
Receiving objects: 100% (6775/6775), 97.07 MiB | 16.79 MiB/s, done.
Resolving deltas: 100% (2198/2198), done.
root@superset:~#

2.3.2 通过 Docker Compose 启动 Superset

root@superset:~/superset# export TAG=3.1.1
root@superset:~/superset# docker compose -f docker-compose-image-tag.yml up -d

image-20241203224249154

image-20241203225121443

执行如下命令,初始化Superset。

image-20241203122716643

填入URL:IP地址:8088,输入用户名和密码。均为admin。

image-20241204145351369

2.4 开通 OB Cloud 云数据库

查看实例详细信息。

image-20241204115606101

点击连接,获取链接串。

image-20241204115657932

2.5 获取连接串

  1. 获取公共网络连接;如:xxxxxxxxxxxxxxxx.aliyun-cn-hangzhou-internet.oceanbase.cloud
  2. 安全设置,添加到租户白名单中的 IP 地址可以访问该租户的数据库;如,0.0.0.0/0
  3. 选择数据库和账号获取示例连接串;

image-20241204115752461

2.6 使用 Superset 连接 OceanBase 数据库

打开运行的 Superset 控制台页面,在右上角选择 + > Data > Connect database

image-20241203222417988

在弹出框中,完成如下配置:

  1. 在第一步 Select a database to connect 下,选择 MySQL 数据库类型。
  2. 在第二步 Enter the required MySQL credentials 下,根据在步骤一:获取数据库连接串中的连接串信息依次完成填写HOSTPORTDATABASE NAMEUSERNAMEPASSWORD。也可以自定义DISPLAY NAME的内容。

image-20241203172207255

单击 CONNECT,然后单击 FINISH

image-20241204140723683

此时,我们就可以看到该数据库已经使用Superset连接。

image-20241203230839322

2.7 导入数据并创建表

导航至OB Cloud数据库控制台,点击导入样本数据

image-20241204103350634

等待数据导入完成。

image-20241204103600765

数据导入完成。

image-20241204103725671

通过以下命令查看 flights_sample 表中的列名

mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -ADatabase changedmysql> DESCRIBE flights_sample;
+-------------------------+---------------+------+-----+---------+-------+
| Field                   | Type          | Null | Key | Default | Extra |
+-------------------------+---------------+------+-----+---------+-------+
| id                      | bigint(20)    | NO   | PRI | NULL    |       |
| fl_date                 | date          | YES  | MUL | NULL    |       |
| airline                 | varchar(100)  | YES  |     | NULL    |       |
| airline_dot             | varchar(100)  | YES  |     | NULL    |       |
| airline_code            | varchar(10)   | YES  |     | NULL    |       |
| dot_code                | varchar(10)   | YES  |     | NULL    |       |
| fl_number               | int(11)       | YES  |     | NULL    |       |
| origin                  | varchar(10)   | YES  |     | NULL    |       |
| origin_city             | varchar(100)  | YES  |     | NULL    |       |
| dest                    | varchar(10)   | YES  |     | NULL    |       |
| dest_city               | varchar(100)  | YES  |     | NULL    |       |
| crs_dep_time            | int(11)       | YES  |     | NULL    |       |
| dep_time                | decimal(6,2)  | YES  |     | NULL    |       |
| dep_delay               | decimal(6,2)  | YES  |     | NULL    |       |
| taxi_out                | decimal(6,2)  | YES  |     | NULL    |       |
| wheels_off              | decimal(6,2)  | YES  |     | NULL    |       |
| wheels_on               | decimal(6,2)  | YES  |     | NULL    |       |
| taxi_in                 | decimal(6,2)  | YES  |     | NULL    |       |
| crs_arr_time            | int(11)       | YES  |     | NULL    |       |
| arr_time                | decimal(6,2)  | YES  |     | NULL    |       |
| arr_delay               | decimal(6,2)  | YES  |     | NULL    |       |
| cancelled               | tinyint(1)    | YES  |     | NULL    |       |
| cancellation_code       | varchar(10)   | YES  |     | NULL    |       |
| diverted                | tinyint(1)    | YES  |     | NULL    |       |
| crs_elapsed_time        | decimal(6,2)  | YES  |     | NULL    |       |
| elapsed_time            | decimal(6,2)  | YES  |     | NULL    |       |
| air_time                | decimal(6,2)  | YES  |     | NULL    |       |
| distance                | decimal(10,2) | YES  |     | NULL    |       |
| delay_due_carrier       | decimal(6,2)  | YES  |     | NULL    |       |
| delay_due_weather       | decimal(6,2)  | YES  |     | NULL    |       |
| delay_due_nas           | decimal(6,2)  | YES  |     | NULL    |       |
| delay_due_security      | decimal(6,2)  | YES  |     | NULL    |       |
| delay_due_late_aircraft | decimal(6,2)  | YES  |     | NULL    |       |
+-------------------------+---------------+------+-----+---------+-------+
33 rows in set (0.13 sec)mysql> SELECT COUNT(*) FROM flights_sample;
+----------+
| COUNT(*) |
+----------+
|  3000000 |
+----------+
1 row in set (0.17 sec)

2.8 在 Superset 中创建数据集

导航至Superset 控制台,在右上角选择 + > Data > Create dataset

image-20241204103900667

New dataset 页面,完成如下配置:

配置项说明
DATABASE选择在步骤二的 DISPLAY NAME 中定义的数据库名。
SCHEMA选择在步骤一中创建的 OceanBase 数据库。
TABLE选择在步骤三种创建的表。

单击 CREATE DATASET AND CREATE CHART,完成创建数据集。

image-20241204104102593

在创建数据集后,可根据实际情况,选择一个图表类型,单击 CREATE NEW CHART,并根据需求进行图表配置。

image-20241204104300636

2.9 配置可视化图表

效果展示如下

image-20241204105941395

image-20241204110812489

image-20241204110835457

三、参考链接

使用 Superset 和 OceanBase 进行数据分析-V4.3.4-OceanBase 数据库文档-分布式数据库使用文档

Find Open Datasets and Machine Learning Projects | Kaggle

Install Compose standalone | Docker Docs

Docker Compose | Superset

http://www.lryc.cn/news/516145.html

相关文章:

  • 【通识安全】应急救护常识23则
  • C语言:cJSON将struct结构体与JSON互相转换
  • 在Linux中,如何查看和修改网络接口配置?
  • 使用深度学习来实现图像超分辨率 综述!
  • 基于深度学习的视觉检测小项目(六) 项目的信号和变量的规划
  • 【Android项目学习】3. MVVMHabit
  • 在Linux中,如何配置负载均衡器以分配网络流量?
  • 手机投屏到电视的3种选择:无线本地投屏,无线远程投屏,AirPlay投屏
  • MySQL关联关系理论与实践
  • 多模态论文笔记——U-ViT(国内版DiT)
  • 在 IntelliJ IDEA 中开发 GPT 自动补全插件
  • 7. C语言 运算符详解
  • Java四大常用JSON解析性能对比:Hutool、Fastjson2、Gson与Jackson测试
  • Qt 5.14.2 学习记录 —— 일 新项目
  • uni-app:实现普通选择器,时间选择器,日期选择器,多列选择器
  • Unity3D仿星露谷物语开发17之空库存栏UI
  • QT------模型/视图
  • Git - 记录一次由于少输入了一个命令导致的更改丢失
  • nodeJS下npm和yarn的关系和区别详解
  • 党员学习交流平台
  • HTML5 文件上传(File Upload)详解
  • 1.2.1-2部分数据结构的说明02_链表
  • vue elementUI Plus实现拖拽流程图,不引入插件,纯手写实现。
  • linux上使用cmake编译的方法
  • 如何实现el-select多选下拉框中嵌套复选框并加校验不为空功能呢?
  • 源码理解 UE4中的 FCookStatsManager::FAutoRegisterCallback RegisterCookStats
  • Android 根据内存大小显示MTP模式连接PC时的名称
  • 不只是mini-react第一节:实现最简单mini-react
  • 前端路由layout布局处理以及菜单交互(三)
  • 小结:DNS,HTTP,SMTP,IMAP,FTP,Telnet,TCP,ARP,ICMP