1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| dba58:PRIMARY> db.inventory.insertMany( [ { "item": "journal", "qty": 25, "size": { "h": 14, "w": 21, "uom": "cm" }, "status": "A" }, { "item": "notebook", "qty": 50, "size": { "h": 8.5, "w": 11, "uom": "in" }, "status": "A" }, { "item": "paper", "qty": 100, "size": { "h": 8.5, "w": 11, "uom": "in" }, "status": "D" }, { "item": "planner", "qty": 75, "size": { "h": 22.85, "w": 30, "uom": "cm" }, "status": "D" }, { "item": "postcard", "qty": 45, "size": { "h": 10, "w": 15.25, "uom": "cm" }, "status": "A" } ]); dba58:PRIMARY> db.inventory.find()
//从节点查看 dba58:SECONDARY> db.inventory.find() ... "errmsg" : "not master and slaveOk=false", ...
默认从节点不可直接查询: 临时解决 dba58:SECONDARY> rs.slaveOk(); dba58:SECONDARY> db.inventory.find() { "_id" : ObjectId("5ec60b6a9df565bf8d6b6bcc"), "item" : "postcard", "qty" : 45, "size" : { "h" : 10, "w" : 15.25, "uom" : "cm" }, "status" : "A" }
永久解决 [root@db01 ~]
|