我有一个包含大量数据的mongodb实例,现在我需要启动一个没有数据的相同结构的新实例.
如何完成它?
MongoDB建议update()对分片集合进行所有操作,这些操作指定'multi:false'选项必须在查询条件中包括分片键,这样查询将仅命中特定的分片集群。如果没有找到shard键'multi:false',则会返回此错误(请参见http://docs.mongodb.org/manual/core/sharded-cluster-query-router/):
update does not contain _id or shard key for pattern
Run Code Online (Sandbox Code Playgroud)
我正在切换代码以使用分片集合。我的代码默认情况下使用update()with 'multi:true',并且我不想更改该默认选项以避免上面的任何潜在错误。我的问题是,如果我在update()with中包含分片键'multi:true',mongos是否足够聪明,可以使用分片键将查询路由到特定集群并忽略'multi: true'?
编辑:签出这些代码,确认@wdberkeley说了什么。
版本2.4:
https://github.com/mongodb/mongo/blob/v2.4/src/mongo/s/strategy_shard.cpp#L941
2.6版:
https://github.com/mongodb/mongo/blob/v2.6/src/mongo/s/chunk_manager_targeter.cpp#L250
我在 MongoDB 中有以下文档。
{
"_id" : ObjectId("521aff65e4b06121b688fabc"),
"user" : "abc",
"servers" : [
{
"name" : "server1",
"cpu" : 4,
"memory" : 4
},
{
"name" : "server2",
"cpu" : 6,
"memory" : 6
},
{
"name" : "server3",
"cpu" : 8,
"memory" : 8
}
]
}
Run Code Online (Sandbox Code Playgroud)
根据某些事件,我必须更新现有服务器的 cpu 和内存字段,或者如果阵列中不存在新服务器,则将其添加到阵列中。目前,我分两步执行此操作。首先检查服务器是否已经存在于数组中。如果是,则更新 cpu 和内存字段。否则,将新的子文档推送到数组中。由于应用程序的多线程性质,有时同一服务器会多次添加到数组中。是否有原子操作符可以执行以下两个操作(类似于$setOnInsert操作符):
注意:$addToSet在上述情况下,运算符不起作用,因为 cpu 或内存的值可能不同。
我尝试启动 Rails 服务器,但收到以下错误消息,请问如何修复它
C:\Sites\sample_app>rails s
=> Booting Puma
=> Rails 5.1.4 application starting in development
=> Run `rails server -h` for more startup options
Please add the following to your Gemfile to avoid polling for changes:
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
Please add the following to your Gemfile to avoid polling for changes:
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
ERROR: worker mode not supported on JRuby or Windows
Exiting
Run Code Online (Sandbox Code Playgroud)