客户AWS国内有两个DocumentDB数据库(4.0版本),由于成本原因,需要将两个数据库合并成一个数据库,将2个库合并成一个库。因此,需要使用DMS服务,将DocumentDB1--->DocumentDB2,合并成一个DocumentDB数据库。
echo -e "[mongodb-org-4.0] \nname=MongoDB Repository\nbaseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/4.0/x86_64/\ngpgcheck=1 \nenabled=1 \ngpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc" | sudo tee /etc/yum.repos.d/mongodb-org-4.0.repo sudo yum install -y mongodb-org-shell |

mongo --host admin1.cluster-c2lighgovwg5.docdb.cn-northwest-1.amazonaws.com.cn:27017 --username admin1 --password Test1234 |
需要修改的参数有host、username和password

db.adminCommand({modifyChangeStreams: 1,
database: "test",
collection: "",
enable: true}); |







创建的目标端点的内容与源端点类似,需要修改的地方,端点类型选择:目标端点



安装git yum install git 下载索引工具 git clone https://github.com/awslabs/amazon-documentdb-tools.git python3 安装依赖 cd amazon-documentdb-tools/index-tool pip3 install -r requirements.txt 下载索引数据,源端admin1数据库中必须要有数据库和表,否则下载为空,“.”为当前路径 python3 migrationtools/documentdb_index_tool.py --dump-indexes --host admin1.cluster-c2lighgovwg5.docdb.cn-northwest-1.amazonaws.com.cn --port 27017 --username admin1 --password Test1234 --dir . 导入索引数据 python3 migrationtools/documentdb_index_tool.py --restore-indexes --host admin2.cluster-c2lighgovwg5.docdb.cn-northwest-1.amazonaws.com.cn --port 27017 --username admin2 --password Test1234 --dir ./DB2 |
下载索引数据和导入索引数据截图如下:


登录到admin2数据库
查看数据库 show dbs |

创建迁移任务,并且启动/恢复




查看DMS的迁移状态和进度


数据库索引工具使用:https://github.com/awslabs/amazon-documentdb-tools/tree/master/index-tool
DocumentDB基础操作:https://blog.csdn.net/weixin_43408020/article/details/116009373
创建复制实例:https://docs.aws.amazon.com/zh_cn/dms/latest/userguide/CHAP_ReplicationInstance.Creating.html
创建源和目标终端节点:https://docs.aws.amazon.com/zh_cn/dms/latest/userguide/CHAP_Endpoints.Creating.html
创建数据库迁移任务:https://docs.aws.amazon.com/zh_cn/dms/latest/userguide/CHAP_Tasks.Creating.html
序号 | 判断描述 | 自我判定(是否) |
|---|---|---|
| 1 | 在各搜索引擎中是否能找到知识信息 | 是 |
| 2 | 是否需要代码集成开发 | 否 |