将 AWS S3 数据迁移至 TiDB Cloud 集群
一、文档目的
在使用 TiDB Cloud 过程中,通常大家面临的第一个难题便是如何将现有集群的数据导入至 TiDB Cloud 集群中,”很幸运“地是 TiDB Cloud 上提供了多种方式可以帮助大家完成这一过程,大家可以自行到官网上查看。本文档提供了将 AWS S3 中数据导入至 TiDB Cloud 集群的操作步骤,供大家参考。
说明:目前在免费的 TiDB Cloud Dev Tier 集群中, Web 界面导入的数据源仅支持 AWS S3 ,支持的数据格式有 4 种:TiDB dumping、Aurora Backup Snapshot、CSV 和 Parquet,本次测试模拟将 AWS S3 中 dumpling 格式的数据导入至 TiDB Cloud 集群,其他的数据格式也是类似方式。
二、在 TiDB Cloud 上创建测试集群
1. 选择免费的 “Developer Tier”

2. 创建测试集群


3. 集群创建成功后,设置本地标准连接
(1)选择 Overview -》 选择 Connect -》 Standard Connection

(2)添加本地 IP 地址

(3)测试本地连接成功

三、在 AWS S3 上创建 bucket 并设置权限
1. 在 AWS 中创建 S3 bucket ,并上传 dumpling 导出的文件
(1)获取 s3 bucket 的 ARN (arn:aws:s3:::dumplingtest),后面在 AWS IAM 中创建策略会用到(创建 bucket 过程省略)

(2)在 s3 bucket 中上传 dumpling 工具导出的数据文件(过程省略),放到子目录 testdata 下
说明:测试数据来源为本地集群通过 dumpling 工具导出的 SQL 文件


2. 在 AWS IAM 中创建访问 S3 桶的 policy
(1)创建策略,编写策略规则
填写 S3 bucket 的 ARN 信息: arn:aws:s3:::dumplingtest
权限 s3.GetObject 、s3.GetObjectVersion 和 s3 bucket 中子目录对应
权限 s3.ListBucket 、 s3.GetBucketLocation 和 s3 bucket 对应


(2)策略创建成功

3. 获取 TiDB Cloud 集群的 Accound id 和 External id
在 TiDB Cloud 集群的 Overview -》 Import -》 Show AWS IAM policy settings 中获取

TiDB Cloud Account id: 380838443567
TiDB Cloud External id: 696e6672612d6170698cf65cc99da4bea3da7cd6717dd5bbbe
在 AWS IAM 中创建 role 时需要用到
4. 在 AWS IAM 中创建 role
(1)选择 “AWS 账户” -》选择 “另一个 AWS 账户” -》 填写 TiDB Cloud Account id -》选择 “需要外部 ID" -》填写 TiDB Cloud External ID


(2)选择之前创建的 Policy,执行下一步

(3)role 创建成功

(4)获取 role 的 ARN (arn:aws:iam::255548669385:role/Role_TiDBCloud)

四、将 AWS S3 数据导入 TiDB Cloud 集群
1. 将 AWS S3 数据 import 至 TiDB Cloud
(1)填写 S3 bucket 实际子目录的 URL
(2)填写 role 的 ARN
(3)选择 Data Format 为 ”TiDB Dumpling“

(4)输入 TiDB Cloud 集群的用户和密码,点击 “Import”

(5)数据导入过程
(6)数据导入成功

2. 验证数据
(1)方式一:通过本地客户端

(2)方式二:通过 Web SQL Shell
在 TiDB Cloud 集群的 Overview -》 Connect -》 Web SQL Shell 中登录

原作者:这道题我不会 发布时间:2022/3/27
原文链接:https://tidb.io/blog/c74cf5a1
评论