0条评论
还没有人评论过~
12节点分片集群安装搭建(3.2版)
主机 | MongoDB01 | MongoDB02 | MongoDB03 | MongoDB04 | MongoDB05 | MongoDB06 |
IP | 10.10.1.5 | 10.10.1.6 | 10.10.1.7 | 10.10.1.8 | 10.10.1.9 | 10.10.1.10 |
副本集(20081)数据 | SH1RS | SH1RS | SH1RS | SH2RS | SH2RS | SH2RS |
主机 | MongoDB07 | MongoDB08 | MongoDB09 | MongoDB10 | MongoDB11 | MongoDB12 |
IP | 10.10.1.11 | 10.10.1.12 | 10.10.1.13 | 10.10.1.14 | 10.10.1.15 | 10.10.1.16 |
副本集(20081)数据 | SH3RS | SH3RS | SH3RS | SH4RS | SH4RS | SH4RS |
副本集(20082)配置 | CFRS | CFRS | CFRS | |||
28003 路由 | Y | Y | Y |
SH1RS:SECONDARY> rs.status()
{
"set" : "SH1RS",
"date" : ISODate("2019-03-14T14:12:17.210Z"),
"myState" : 2,
"term" : NumberLong(1),
"syncingTo" : "MongoDB01:28001",
"heartbeatIntervalMillis" : NumberLong(2000),
"members" : [
{
"_id" : 0,
"name" : "MongoDB01:28001",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 655,
"optime" : {
"ts" : Timestamp(1552572310, 2),
"t" : NumberLong(1)
},
"optimeDate" : ISODate("2019-03-14T14:05:10Z"),
"lastHeartbeat" : ISODate("2019-03-14T14:12:15.436Z"),
"lastHeartbeatRecv" : ISODate("2019-03-14T14:12:16.769Z"),
"pingMs" : NumberLong(0),
"electionTime" : Timestamp(1552572066, 1),
"electionDate" : ISODate("2019-03-14T14:01:06Z"),
"configVersion" : 1
},
{
"_id" : 1,
"name" : "MongoDB02:28001",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 655,
"optime" : {
"ts" : Timestamp(1552572310, 2),
"t" : NumberLong(1)
},
"optimeDate" : ISODate("2019-03-14T14:05:10Z"),
"lastHeartbeat" : ISODate("2019-03-14T14:12:15.436Z"),
"lastHeartbeatRecv" : ISODate("2019-03-14T14:12:15.436Z"),
"pingMs" : NumberLong(0),
"syncingTo" : "MongoDB01:28001",
"configVersion" : 1
},
{
"_id" : 2,
"name" : "MongoDB03:28001",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 1002,
"optime" : {
"ts" : Timestamp(1552572310, 2),
"t" : NumberLong(1)
},
"optimeDate" : ISODate("2019-03-14T14:05:10Z"),
"syncingTo" : "MongoDB01:28001",
"configVersion" : 1,
"self" : true
}
],
"ok" : 1
}
use test
rs.slaveOk()
db.testc.find()
SH1RS:SECONDARY> db.testc.find()db.testc.find()
{ "_id" : ObjectId("5c8a5f960304e7b4a4ac66a4"), "id" : 1, "test" : "from Mongodb01,the primary" }
SH1RS:PRIMARY> admin = db.getSiblingDB("admin")admin = db.getSiblingDB("admin")
admin
SH1RS:PRIMARY> admin.createUser(admin.createUser(
... { {
... user: "mongoadmin", user: "mongoadmin",
... pwd: "Super**********", pwd: "Super**********",
... roles: [ { role: "root", db: "admin" } ] roles: [ { role: "root", db: "admin" } ]
... } }
... ))
Successfully added user: {
"user" : "mongoadmin",
"roles" : [
{
"role" : "root",
"db" : "admin"
}
]
}
mongos> admin = db.getSiblingDB("admin")admin = db.getSiblingDB("admin")
admin
mongos> admin.createUser(admin.createUser(
... { {
... user: "shadmin", user: "shadmin",
... pwd: "shSuper**********", pwd: "shSuper**********",
... roles: [ { role: "root", db: "admin" } ] roles: [ { role: "root", db: "admin" } ]
... } }
... ))
Successfully added user: {
"user" : "shadmin",
"roles" : [
{
"role" : "root",
"db" : "admin"
}
]
}