……
},
{
"_id" : 2,
"name" : "mha3:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 15,
……
}
],
……
}
五、验证
主节点上写入数据:
rs0:PRIMARY> db.test.insert({ a:1 })
WriteResult({ "nInserted" : 1 })
从节点上查看:
rs0:SECONDARY> rs.slaveOk()
rs0:SECONDARY> db.test.find()
{ "_id" : ObjectId("5f3cdf0a0f14ffc0caecaf3d"), "a" : 1 }
主节点写入:
rs0:PRIMARY> db.test.insert({ a:2 });
WriteResult({ "nInserted" : 1 })
从节点进行读:
rs0:SECONDARY> db.test.find()
{ "_id" : ObjectId("5f3cdf0a0f14ffc0caecaf3d"), "a" : 1 }
{ "_id" : ObjectId("5f3ce3e30f14ffc0caecaf3e"), "a" : 2 }
文档被以下合辑收录
评论