简体   繁体   English

将 mongoDB 迁移到 AWS DocumentDB db on rails 无法创建索引

[英]Migrating mongoDB to AWS DocumentDB db on rails fails to create indexes

I'm trying to migrate from mongo DB to AWS documentDB on rails.我正在尝试从 mongo DB 迁移到 AWS documentDB on rails。 I changed the configuration of mongoid.yml to point to the documented instance (under hosts)我更改了 mongoid.yml 的配置以指向记录的实例(在主机下)

When running rake:db:mongoid:create_indexes I get the following error:运行 rake:db:mongoid:create_indexes 时出现以下错误:

rake aborted!
Mongo::Error::NoServerAvailable: No server is available matching preference: #<Mongo::ServerSelector::Primary:0x139580660 tag_sets=[] max_staleness=nil> using server_selection_timeout=60 and local_threshold=0.015
/usr/local/bundle/gems/mongo-2.6.2/lib/mongo/server_selector/selectable.rb:115:in `select_server'
/usr/local/bundle/gems/mongo-2.6.2/lib/mongo/cluster.rb:263:in `next_primary'
/usr/lib/ruby/2.3.0/forwardable.rb:202:in `next_primary'
/usr/local/bundle/gems/mongo-2.6.2/lib/mongo/index/view.rb:151:in `create_many'
/usr/local/bundle/gems/mongo-2.6.2/lib/mongo/index/view.rb:130:in `create_one'
/usr/local/bundle/gems/mongoid-5.4.0/lib/mongoid/indexable.rb:37:in `block in create_indexes'
/usr/local/bundle/gems/mongoid-5.4.0/lib/mongoid/indexable.rb:31:in `each'
/usr/local/bundle/gems/mongoid-5.4.0/lib/mongoid/indexable.rb:31:in `create_indexes'
/usr/local/bundle/gems/mongoid-5.4.0/lib/mongoid/tasks/database.rb:20:in `block in create_indexes'
/usr/local/bundle/gems/mongoid-5.4.0/lib/mongoid/tasks/database.rb:17:in `each'
/usr/local/bundle/gems/mongoid-5.4.0/lib/mongoid/tasks/database.rb:17:in `create_indexes'
/usr/local/bundle/gems/mongoid-5.4.0/lib/mongoid/tasks/database.rake:8:in `block (3 levels) in <top (required)>'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/task.rb:273:in `block in execute'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/task.rb:273:in `each'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/task.rb:273:in `execute'
/usr/local/bundle/gems/airbrake-9.5.0/lib/airbrake/rake.rb:17:in `execute'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/task.rb:214:in `block in invoke_with_call_chain'
/usr/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/task.rb:194:in `invoke_with_call_chain'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/task.rb:183:in `invoke'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:160:in `invoke_task'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:116:in `each'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:116:in `block in top_level'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:125:in `run_with_threads'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:110:in `top_level'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:83:in `block in run'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:186:in `standard_exception_handling'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:80:in `run'
/usr/local/bundle/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/usr/local/bundle/bin/rake:23:in `load'
/usr/local/bundle/bin/rake:23:in `<main>'
Tasks: TOP => db:mongoid:create_indexes

Installed ruby gems:安装 ruby 宝石:

mongo (2.6.2)
mongoid (5.4.0)

Am I missing some gem installation?我是否缺少一些 gem 安装? Is it not yet supported thus can't migrate ATM?是不是还不支持不能迁移ATM?

Your application cannot connect to the database.您的应用程序无法连接到数据库。

Am I missing some gem installation?我错过了一些 gem 安装吗?

No, but you are using a rather old driver (although MongoDB, who maintains the MongoDB Ruby driver that you are using, does not support using it with DocumentDB regardless of version).不,但是您使用的是相当旧的驱动程序(尽管您正在使用的 MongoDB 维护 MongoDB Ruby 驱动程序不支持将其与 DocumentDB 一起使用,无论版本如何)。

Is it not yet supported thus can't migrate ATM?它还不支持因此无法迁移 ATM 吗?

You haven't gotten to where the index creation was attempted.您还没有到达尝试创建索引的位置。

The MongoDB driver for Ruby should work with Amazon DocumentDB. Ruby 的 MongoDB 驱动程序应该可以与 Amazon DocumentDB 一起使用。 Have you checked the security group configuration and configured the certificate?您是否检查了安全组配置并配置了证书? DocumentDB is accessible only from the same VPC and has TLS enabled by default. DocumentDB 只能从同一 VPC 访问,并且默认启用 TLS。 There are code samples on how to connect programmatically in the documentation . 文档中有关于如何以编程方式连接的代码示例。

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

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