学习数据库的最好方法,是从官方文档开始看起。mongodb的官方文档在这里,但是也有中文翻译的版本,可见这里(中文翻译貌似还没完全翻译完,还有不少段落是英文的。)。 mongodb目前最新的版本是3.4版本。注:3.4版本不在支持x86 32位的系统。 (1)安装: (1.1) 准备3台机器,分别是 […]
mongodb添加arbiter节点
创建mongodb的replica set的时候,只是做成了1主2从,没有做成1主1从1仲裁。这我们将一个几点从replica set中删除,再以仲裁节点的身份加入到replica set中: 1.初始状态:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
shard1ReplSet:PRIMARY> rs.status();rs.status(); { "set" : "shard1ReplSet", "date" : ISODate("2017-02-21T07:48:03.058Z"), "myState" : 1, "term" : NumberLong(1), "heartbeatIntervalMillis" : NumberLong(2000), "optimes" : { "lastCommittedOpTime" : { "ts" : Timestamp(0, 0), "t" : NumberLong(-1) }, "appliedOpTime" : { "ts" : Timestamp(1487663274, 1), "t" : NumberLong(1) }, "durableOpTime" : { "ts" : Timestamp(1487587982, 1), "t" : NumberLong(-1) } }, "members" : [ { "_id" : 0, "name" : "10.13.0.130:22001", "health" : 1, "state" : 1, "stateStr" : "PRIMARY", "uptime" : 76672, "optime" : { "ts" : Timestamp(1487663274, 1), "t" : NumberLong(1) }, "optimeDate" : ISODate("2017-02-21T07:47:54Z"), "electionTime" : Timestamp(1487587993, 1), "electionDate" : ISODate("2017-02-20T10:53:13Z"), "configVersion" : 1, "self" : true }, { "_id" : 1, "name" : "10.13.0.131:22001", "health" : 1, "state" : 2, "stateStr" : "SECONDARY", "uptime" : 75300, "optime" : { "ts" : Timestamp(1487663274, 1), "t" : NumberLong(1) }, "optimeDurable" : { "ts" : Timestamp(1487587982, 1), "t" : NumberLong(-1) }, "optimeDate" : ISODate("2017-02-21T07:47:54Z"), "optimeDurableDate" : ISODate("2017-02-20T10:53:02Z"), "lastHeartbeat" : ISODate("2017-02-21T07:48:02.150Z"), "lastHeartbeatRecv" : ISODate("2017-02-21T07:48:02.215Z"), "pingMs" : NumberLong(0), "syncingTo" : "10.13.0.132:22001", "configVersion" : 1 }, { "_id" : 2, "name" : "10.13.0.132:22001", "health" : 1, "state" : 2, "stateStr" : "SECONDARY", "uptime" : 75300, "optime" : { "ts" : Timestamp(1487663274, 1), "t" : NumberLong(1) }, "optimeDurable" : { "ts" : Timestamp(1487587982, 1), "t" : NumberLong(-1) }, "optimeDate" : ISODate("2017-02-21T07:47:54Z"), "optimeDurableDate" : ISODate("2017-02-20T10:53:02Z"), "lastHeartbeat" : ISODate("2017-02-21T07:48:02.889Z"), "lastHeartbeatRecv" : ISODate("2017-02-21T07:48:01.503Z"), "pingMs" : NumberLong(0), "syncingTo" : "10.13.0.130:22001", "configVersion" : 1 } ], "ok" : 1 } shard1ReplSet:PRIMARY> shard1ReplSet:PRIMARY> shard1ReplSet:PRIMARY> shard1ReplSet:PRIMARY> |
2.删除节点: [cra […]