ShawnTT
ShawnTT

Reputation: 61

Mongorestore 4.2 can work with AWS DocumentDB 4.0?

I'm trying to migrate my mongodb(4.2) to AWS DocumentDB(4.0). I meet the below problem when I try to restore the backup data by mongorestore:

$ 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 

Any ideas about this error?

Thank you, Shawn

Upvotes: 3

Views: 2599

Answers (3)

Pavel Klyuev
Pavel Klyuev

Reputation: 11

Restore Mongo dump to a DocumentDB using mongorestore 4.2 version fails

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 }, ] }

Restore Mongo dump to a DocumentDB using mongorestore 4.0 version fails

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

Restore Mongo dump to a DocumentDB using latest mongorestore version fails

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.

Can’t restore dump from MongoDB Atlas Cloud 4.2 to AWS DocumentDB 4.0.

I tried to restore in a different ways but no luck.

Tried to restore MongoDB Atlas Cloud 4.2 to a MongoDB 4.4.6-8 on EC2 and configure sync using Amazon DMS.

Restore Mongo dump to a current production MongoDB Replica Set on EC2 success

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.

After that I successfully created Database migration task from current production MongoDB Replica Set on EC2 to a AWS DocumentDB

Upvotes: 0

ShawnTT
ShawnTT

Reputation: 61

Thinking I found a way to resolve this issue, I used docker to run this mongorestore 4.0, then the dump data can be restored to the docdb:

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 \

So basically, the data from MongoDB v4.2 can be restored into the DocumentDB v 4.0, the only thing that needs to do is to choose the mongorestore v4.0.

Hope this answer can help you.

Thank you, Shawn

Upvotes: 3

Joseph Idziorek
Joseph Idziorek

Reputation: 5071

it looks like the client that you are using for mongorestore is not able to connect to the DocumentDB cluster. The common reasons for that are 1/client is not in the same VPC as the DocumentDB cluster, 2/security group for the DocumentDB cluster does not enable inbound connections on the default port of 27017.

Please see connection issues for more troubleshooting options: https://docs.aws.amazon.com/documentdb/latest/developerguide/troubleshooting.connecting.html

Upvotes: 0

Related Questions