Error creating index WriteConcern detected an error 'not master'

本文介绍了在尝试创建MongoDB索引时遇到的notmaster错误及其原因。该错误通常发生在非主节点上尝试创建索引操作时,因为索引创建只能在主节点上进行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值