Error creating index
WriteConcern detected an error 'not master'. (Response was { "lastOp" : { "$timestamp" : NumberLong(0) }, "connectionId" : 2152576, "err" : "not master", "code" : 8, "n" : 0, "ok" : 1.0 }).
Type: MongoDB.Driver.WriteConcernException
Stack: 在 MongoDB.Driver.Operations.InsertOperation.Execute(MongoConnection connection)
在 MongoDB.Driver.MongoCollection.InsertBatch(Type nominalType, IEnumerable documents, MongoInsertOptions options)
在 MongoDB.Driver.MongoCollection.Insert(Type nominalType, Object document, MongoInsertOptions options)
在 MongoDB.Driver.MongoCollection.Insert[TNominalType](TNominalType document, MongoInsertOptions options)
在 MongoDB.Driver.MongoCollection`1.Insert(TDefaultDocument document, MongoInsertOptions options)
在 MongoDB.Driver.MongoCollection.CreateIndex(IMongoIndexKeys keys, IMongoIndexOptions options)
在 MangoUI.MIndexes.Create(String db, String col, String name, BsonDocument fields, Boolean unique, Boolean dropDups, Boolean background)
在 MangoUI.WinIndexNew.btnCreate_Click(Object sender, EventArgs e)
Inputs::
results: System.Collections.Generic.List`1[MongoDB.Driver.WriteConcernResult]
Command: getlasterror
Ok: True
ErrorMsg:
Request: { "getlasterror" : 1, "w" : 1 }
Response: { "lastOp" : { "$timestamp" : NumberLong(0) }, "connectionId" : 2152576, "err" : "not master", "code" : 8, "n" : 0, "ok" : 1.0 }解释
当前mongodb不是master,索引只能在master上建。
本文介绍了在尝试创建MongoDB索引时遇到的notmaster错误及其原因。该错误通常发生在非主节点上尝试创建索引操作时,因为索引创建只能在主节点上进行。

被折叠的 条评论
为什么被折叠?



