简体   繁体   English

无法在 AWS EC2 实例上运行 mongoexport

[英]Unable to run mongoexport on AWS EC2 instance

I have data in a DocumentDB database that I would like to export to an S3 bucket.我在 DocumentDB 数据库中有想要导出到 S3 存储桶的数据。 However, when I try to run the mongoexport command:但是,当我尝试运行 mongoexport 命令时:

mongoexport --uri="my_cluster_address/database_to_use" --collection=my_collection --out=some_file.json

I get this error:我收到此错误:

could not connect to server: server selection error: server selection timeout, current topology: 
{ Type: Single, Servers: [{ Addr: docdb_cluster_address, Type: Unknown, State: Connected, Average RTT: 0, Last error: 
connection() : connection(docdb_cluster_address[-13]) incomplete read of message header: read tcp port_numbers-
>port_numbers: i/o timeout }, ] }

I am able to ssh into the cluster and do all sorts of transformations and really anything else related to database work but when I exit the mongoshell and try to run the mongoexport command it does not work.我能够将 ssh 放入集群并进行各种转换以及与数据库工作相关的任何其他事情,但是当我退出 mongoshell 并尝试运行 mongoexport 命令时它不起作用。 I already downloaded the mongoexport tools to the EC2 instance and added them to the.bash_profile path.我已经将 mongoexport 工具下载到 EC2 实例并将它们添加到 .bash_profile 路径。 I do not think it is a networking issue because if that were the case I wouldn't be able to ssh into the cluster so I think I am good on that part, I am not sure what I could be missing here.我认为这不是网络问题,因为如果是这种情况,我将无法将 ssh 插入集群,所以我认为我在这方面做得很好,我不确定我可能会在这里遗漏什么。 Any ideas?有任何想法吗?

When working with DocumentDB the mongoexport does not take the same parameters as it normally would when exporting/importing/restoring/dumping from/to MongoDB使用 DocumentDB 时,mongoexport 不会采用与从/到 MongoDB 导出/导入/恢复/转储时通常使用的参数相同的参数

Below is the command that worked for me and a link to the documentation: https://docs.aws.amazon.com/documentdb/latest/developerguide/backup_restore-dump_restore_import_export_data.html以下是对我有用的命令和文档链接: https://docs.aws.amazon.com/documentdb/latest/developerguide/backup_restore-dump_restore_import_export_data.html

mongoexport --ssl \
    --host="tutorialCluster.node.us-east-1.docdb.amazonaws.com:27017" \
    --collection=restaurants \
    --db=business \
    --out=restaurant2.json \
    --username=<yourUsername> \
    --password=<yourPassword> \
    --sslCAFile rds-combined-ca-bundle.pem

And below is the documentation for how it would normally work if you were working with MongoDB: https://docs.mongodb.com/database-tools/mongoexport/以下是使用 MongoDB 时它如何正常工作的文档: https://docs.mongodb.com/database-tools/mongoexport/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM