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上建。