设为首页 加入收藏

TOP

mongodb高可用ReplicaSet(五)
2015-11-21 02:07:58 来源: 作者: 【 】 浏览:11
Tags:mongodb 可用 ReplicaSet
go 192.168.50.120:27017 mongo --host 127.0.0.1 --port 27017 #使用jinri数据库。 wind:SECONDARY> use jinri; switched to db jinri wind:SECONDARY> show tables; 2015-08-04T14:22:48.436+0800 E QUERY Error: listCollections failed: { "note" : "from execCommand", "ok" : 0, "errmsg" : "not master" } at Error ( ) at DB._getCollectionInfosCommand (src/mongo/shell/db.js:646:15) at DB.getCollectionInfos (src/mongo/shell/db.js:658:20) at DB.getCollectionNames (src/mongo/shell/db.js:669:17) at shellHelper.show (src/mongo/shell/utils.js:625:12) at shellHelper (src/mongo/shell/utils.js:524:36) at (shellhelp2):1:1 at src/mongo/shell/db.js:646 #mongodb默认是从主节点读写数据的,副本节点上不允许读,需要设置副本节点可以读。 wind:SECONDARY> db.getMongo().setSlaveOk(); wind:SECONDARY> show tables; system.indexes tblorders wind:SECONDARY> db.tblorders.find().forEach(printjson) { "_id" : ObjectId("55c05976985cda7c357bccd0"), "orderno" : "A2014089901", "pname" : "tblorders", "scity" : "beijing", "price" : 670 } { "_id" : ObjectId("55c05976985cda7c357bccd1"), "orderno" : "A2014089902", "pname" : "snow", "scity" : "成都", "price" : 1270 } { "_id" : ObjectId("55c05976985cda7c357bccd2"), "orderno" : "A2014089903", "pname" : "kiki", "scity" : "重庆", "price" : 9780 } --1.3 副本节点192.168.5.130 mongo 192.168.50.130:27017 mongo --host 127.0.0.1 --port 27017 wind:SECONDARY> use jinri; switched to db jinri wind:SECONDARY> show tables; 2015-08-04T14:37:56.222+0800 E QUERY Error: listCollections failed: { "note" : "from execCommand", "ok" : 0, "errmsg" : "not master" } at Error ( ) at DB._getCollectionInfosCommand (src/mongo/shell/db.js:646:15) at DB.getCollectionInfos (src/mongo/shell/db.js:658:20) at DB.getCollectionNames (src/mongo/shell/db.js:669:17) at shellHelper.show (src/mongo/shell/utils.js:625:12) at shellHelper (src/mongo/shell/utils.js:524:36) at (shellhelp2):1:1 at src/mongo/shell/db.js:646 wind:SECONDARY> db.getMongo().setSlaveOk(); wind:SECONDARY> show tables; system.indexes tblorders wind:SECONDARY> db.tblorders.find().forEach(printjson) { "_id" : ObjectId("55c05976985cda7c357bccd0"), "orderno" : "A2014089901", "pname" : "tblorders", "scity" : "beijing", "price" : 670 } { "_id" : ObjectId("55c05976985cda7c357bccd1"), "orderno" : "A2014089902", "pname" : "snow", "scity" : "成都", "price" : 1270 } { "_id" : ObjectId("55c05976985cda7c357bccd2"), "orderno" : "A2014089903", "pname" : "kiki", "scity" : "重庆", "price" : 9780 } --------2.测试副本集故障转移功能 2.1 关闭110节点 mongo 192.168.50.110:27017 use admin; db.shutdownServer(); 2.2自动选举一个节点为主节点130 2015-08-04T14:52:43.014+0800 I NETWORK [ReplExecNetThread-4] Socket recv() timeout 192.168.50.110:27017 2015-08-04T14:52:43.014+0800 I NETWORK [ReplExecNetThread-4] SocketException: remote: 192.168.50.110:27017 error: 9001 socket exception [RECV_TIMEOUT] server [192.168.50.110:27017] 2015-08-04T14:52:43.014+0800 I NETWORK [ReplExecNetThread-4] DBClientCursor::init call() failed 2015-08-04T14:52:43.062+0800 I REPL [ReplicationExecutor] Error in heartbeat request to 192.168.50.110:27017; Location10276 DBClientBase::findN: transport error: 192.168.50.110:27017 ns: admin.$cmd query: { replSetHeartbeat: "wind", pv: 1, v: 1, from: "192.168.50.130:27017", fromId: 2, chec
首页 上一页 2 3 4 5 6 7 下一页 尾页 5/7/7
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇(二)表的连接与外键约束 下一篇《Redis设计与实现》学习笔记-发..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: