python - 如何在停机时间最短的情况下将 DynamoDB 表迁移到全局 DynamoDB 表?

标签 python amazon-web-services amazon-dynamodb

AWS 不允许将现有的 DynamoDB 表转换为全局 DynamoDB 表。所以我需要编写一些代码或找到现有的工具来完成它。 现有表数据量大,导出导入过程耗时长,宕机不可取。

我有一个大概的行动计划,要进行迁移:

  1. 创建全局表
  2. 更改应用程序逻辑以开始写入全局表。当请求读取数据时,首先尝试全局表,如果没有数据 - 当读取普通表时。
  3. 将数据从普通表复制到全局表。
  4. 再次更改应用程序逻辑以仅写入和读取全局表。
  5. 删除普通表。

我想知道是否有人做过类似的迁移?你如何简化从两个表(全局和普通)的读取?是否存在任何用于 boto、pynamodb 或其他 lib 的插件/lib/wrapper 来执行此操作? 或者您使用其他方法进行了迁移,请分享。

最佳答案

自 2019 年 11 月起,可以将现有 DynamoDB 表转换为全局表而不会丢失数据。

"Starting today, you can convert your existing DynamoDB tables to global tables with a few clicks in the AWS Management Console, or using the AWS Command Line Interface (CLI), or the Amazon DynamoDB API. Previously, only empty tables could be converted to global tables. You had to guess your regional usage of a table at the time you created it. Now you can go global, or you can extend existing global tables to additional regions at any time."

https://aws.amazon.com/blogs/aws/new-convert-your-single-region-amazon-dynamodb-tables-to-global-tables/

在 AWS 控制台中将 DynamoDB 表转换为全局表:

  1. 在 AWS 控制台中导航到您的 DynamoDB 表。
  2. 选择“全局表”选项卡。
  3. 如果提示启用 Streams,请启用 Streams。全局表需要流。
  4. 单击“添加区域”以添加一个全局表并选择一个区域。

根据我的经验,创建全局表需要 10-20 分钟。

关于python - 如何在停机时间最短的情况下将 DynamoDB 表迁移到全局 DynamoDB 表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50618236/

相关文章:

node.js - Lambda 函数失败,未生成日志

amazon-web-services - 无法从 docker 容器内部连接到 RDS,我可以从主机连接到 RDS,也可以从本地 docker 容器连接到 RDS

amazon-web-services - 如何在 Docker 容器中创建 DynamoDB(本地)表

java - Amazon EC2 - Quartz 和作业未在正确的时间运行

python - scipy.misc.imread 展平参数——转换为灰度

python - 无法从pycharm导入numpy

Python smtplib 和每个连接的多条消息

python - 如何模拟 AWS DynamoDB 服务?

amazon-web-services - AWS APIgateway 响应映射

python - pkg_resources.resource_stream 在 python3 上失败