|
#设置第一个分片副本集
[root@DB ~]# mongo 192.168.221.160:21101
MongoDB shell version: 3.0.6
connecting to: 192.168.221.160:21101/test
> use admin
switched to db admin
#定义副本集配置信息
> config = {_id:"shard1",members:[{_id:0,host:"192.168.221.160:21101"},{_id:1,host:"192.168.221.160:21201"},{_id:2,host:"192.168.221.160:21301",arbiterOnly:true}]}
{
"_id" : "shard1",
"members" : [
{
"_id" : 0,
"host" : "192.168.221.160:21101"
},
{
"_id" : 1,
"host" : "192.168.221.160:21201"
},
{
"_id" : 2,
"host" : "192.168.221.160:21301",
"arbiterOnly" : true
}
]
}
#初始化副本集信息
> rs.initiate(config)
{ "ok" : 1 }
shard1:OTHER>
#设置第二个分片副本集
[root@DB ~]# mongo 192.168.221.160:21102
MongoDB shell version: 3.0.6
connecting to: 192.168.221.160:21102/test
> use admin
switched to db admin
> config = {_id:"shard2",members:[{_id:0,host:"192.168.221.160:21102"},{_id:1,host:"192.168.221.160:21202"},{_id:2,host:"192.168.221.160:21302",arbiterOnly:true}]}
{
"_id" : "shard2",
"members" : [
{
"_id" : 0,
"host" : "192.168.221.160:21102"
},
{
"_id" : 1,
"host" : "192.168.221.160:21202"
},
{
"_id" : 2,
"host" : "192.168.221.160:21302",
"arbiterOnly" : true
}
]
}
> rs.initiate(config)
{ "ok" : 1 }
shard2:OTHER>
#设置第三个分片副本集
[root@DB ~]# mongo 192.168.221.160:21103
MongoDB shell version: 3.0.6
connecting to: 192.168.221.160:21103/test
> use admin
switched to db admin
> config = {_id:"shard3",members:[{_id:0,host:"192.168.221.160:21103"},{_id:1,host:"192.168.221.160:21203"},{_id:2,host:"192.168.221.160:21303",arbiterOnly:true}]}
{
"_id" : "shard3",
"members" : [
{
"_id" : 0,
"host" : "192.168.221.160:21103"
},
{
"_id" : 1,
"host" : "192.168.221.160:21203"
},
{
"_id" : 2,
"host" : "192.168.221.160:21303",
"arbiterOnly" : true
}
]
}
> rs.initiate(config)
{ "ok" : 1 }
shard3:OTHER>
|
|
|