简体   繁体   中英

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. I changed the configuration of mongoid.yml to point to the documented instance (under hosts)

When running rake:db:mongoid:create_indexes I get the following error:

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:

mongo (2.6.2)
mongoid (5.4.0)

Am I missing some gem installation? Is it not yet supported thus can't migrate ATM?

Your application cannot connect to the database.

Am I missing some gem installation?

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).

Is it not yet supported thus can't migrate ATM?

You haven't gotten to where the index creation was attempted.

The MongoDB driver for Ruby should work with 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. There are code samples on how to connect programmatically in the documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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