首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Mongorestore 4.2可以使用AWS DocumentDB 4.0吗?

Mongorestore 4.2可以使用AWS DocumentDB 4.0吗?
EN

Stack Overflow用户
提问于 2020-11-19 07:51:37
回答 3查看 1.2K关注 0票数 1

我正在尝试将mongodb(4.2)迁移到AWS DocumentDB(4.0)。当我试图通过mongo还原恢复备份数据时,我遇到了以下问题

代码语言:javascript
运行
复制
$ time sudo mongorestore \
> --host="x.x.x.x:27017" \
> --ssl --sslCAFile ~/rds-combined-ca-bundle.pem \
> --username=user --password=passwd \
> --db db \
> --dir /mongodump \
> -vvvvv \
> --numInsertionWorkersPerCollection 128 \
>
2020-11-19T07:46:39.507+0000    using --dir flag instead of arguments
2020-11-19T07:46:39.507+0000    using write concern: &{majority false 0}


2020-11-19T07:47:09.508+0000    error connecting to host: could not connect to server: server selection error: server selection timeout
current topology: Type: Single
Servers:
Addr: shw-docdb-test-migration.cluster-caxwucwjitxo.ap-southeast-2.docdb.amazonaws.com:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: connection(shw-docdb-test-migration.cluster-caxwucwjitxo.ap-southeast-2.docdb.amazonaws.com:27017[-121]) connection is closed 

对这个错误有什么想法吗?

谢谢你,肖恩

EN

回答 3

Stack Overflow用户

发布于 2020-11-20 02:32:42

考虑到我找到了解决这个问题的方法,我使用了docker来运行这个mongo还原4.0,然后可以将转储数据还原到docdb:

代码语言:javascript
运行
复制
docker run --detach  \
--volume /home/ec2-user:/ec2-user \
--volume /mongodump:/dumpdir \
mongo:4.0.18-xenial


dockerid=`docker ps|grep -v IMAGE|awk '{print $1}'`

time sudo docker exec -it $dockerid \
mongorestore --host xxxx \
--ssl --sslCAFile /ec2-user/rds-combined-ca-bundle.pem \
--port 27017 \
--verbose \
-u xxx -p xxxx \
--db dbtest \
--dir /dumpdir/dbtest \
-vvvvv \
--numInsertionWorkersPerCollection 128 \

因此,基本上,可以将MongoDB v4.2中的数据还原到DocumentDB v4.0中,唯一需要做的就是选择mongo还原v4.0。

希望这个答案能帮到你。

谢谢你,肖恩

票数 3
EN

Stack Overflow用户

发布于 2020-11-19 19:02:13

看起来,用于mongorestore的客户端无法连接到DocumentDB集群。常见的原因是: 1/client与DocumentDB集群不在同一个VPC中,2/ DocumentDB群集的安全组不启用默认端口27017上的入站连接。

有关更多疑难解答选项,请参见连接问题:https://docs.aws.amazon.com/documentdb/latest/developerguide/troubleshooting.connecting.html

票数 0
EN

Stack Overflow用户

发布于 2022-10-21 19:33:02

使用mongorestore 4.2版本将Mongo转储还原到DocumentDB失败

代码语言:javascript
运行
复制
sudo docker run --rm -it -v /tmp:/app mongo:4.2 bash
mongorestore --tls --host documentdb.cluster-clodkmgd3rhk.ap-southeast-1.docdb.amazonaws.com:27017 --tlsCAFile rds-combined-ca-bundle.pem --username dbadmin --password <PASSWORD>
...
2022-10-21T14:37:58.510+0000    error connecting to host: could not connect to server: server selection error: server selection timeout, current topology: { Type: Single, Servers: [{ Addr: documentdb.cluster-clodkmgd3rhk.ap-southeast-1.docdb.amazonaws.com:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: connection() : x509: certificate signed by unknown authority }, ] }

使用mongo还原4.0版本将Mongo转储还原到DocumentDB失败

代码语言:javascript
运行
复制
sudo docker run --rm -it -v /tmp:/app mongo:4.0 bash
mongorestore --tls --host documentdb.cluster-clodkmgd3rhk.ap-southeast-1.docdb.amazonaws.com:27017 --tlsCAFile rds-combined-ca-bundle.pem --username dbadmin --password <PASSWORD>
...
restoring indexes for collection database.collection from metadata
Failed: database.collection: error creating indexes for database.collection: createIndex error: Field '' is currently not supported

使用最新的蒙戈还原版本将Mongo转储还原到DocumentDB失败

代码语言:javascript
运行
复制
mongorestore --ssl --host documentdb.cluster-clodkmgd3rhk.ap-southeast-1.docdb.amazonaws.com:27017 --sslCAFile rds-combined-ca-bundle.pem --username dbadmin --password <PASSWORD>
finished restoring database.collection (63673 documents, 0 failures)
Failed: database.collection: error creating indexes for database.collection: createIndex error: Index type not supported : text
63673 document(s) restored successfully. 0 document(s) failed to restore.

无法将MongoDB Atlas Cloud4.2转储还原为AWSCloud4.0。

我试着用不同的方式恢复,但没有运气。

尝试将MongoDB Atlas Cloud4.2恢复为EC2上的MongoDB 4.4.6-8,并使用Amazon配置同步。

在MongoDB成功上将Mongo转储还原到当前生产的EC2副本集

代码语言:javascript
运行
复制
mongorestore -u admin -p <PASSWORD> -d test --authenticationDatabase=admin ./dump/database
...
2022-10-21T15:34:45.650+0000    1318333 document(s) restored successfully. 0 document(s) failed to restore.

之后,我成功地创建了数据库迁移任务,从EC2上的当前产品EC2副本集到AWS DocumentDB

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64907436

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档