Mongodb复制集切换时设置复制集成员优先级
2013-06-13 15:20
597 查看
设置复制集成员优先级
通常在切换时,我们需要将primary切换到指定db,此时需要指定不同db的优先级,根据优先级的不同在投票时会优先将级别高的切换为primary
登陆到primary
Replset中member的默认优先级为1,区间是1-100,0表示该db只能为secondary,不能变为主
> var c = rs.conf();
rs0:SECONDARY> c
{
"_id" : "rs0",
"version" : 1,
"members" : [
{
"_id" : 0,
"host" :"127.0.0.1:27017"
},
{
"_id" : 1,
"host": "127.0.0.1:27018"
},
{
"_id" : 2,
"host" :"127.0.0.1:27019"
}
]
}
rs0:SECONDARY> c.members[2].priority = 3
3
rs0:PRIMARY> c.members[1].priority = 2
2
rs0:PRIMARY> c.members[0].priority = 1
1
rs0:PRIMARY> c
{
"_id" : "rs0",
"version" : 1,
"members" : [
{
"_id" : 0,
"host" :"127.0.0.1:27017",
"priority" :1
},
{
"_id" : 1,
"host" :"127.0.0.1:27018",
"priority" :2
},
{
"_id" : 2,
"host" :"127.0.0.1:27019",
"priority" :3
}
]
}
rs0:PRIMARY> rs.reconfig(c);
Fri Sep 28 10:56:51 DBClientCursor::initcall() failed
Fri Sep 28 10:56:51 query failed :admin.$cmd { replSetReconfig: { _id: "rs0", version: 2, members: [ {_id: 0, host: "127.0.0.1:27017", priority: 1.0 }, { _id: 1, host:"127.0.0.1:27018", priority: 2.0 }, { _id: 2, host:"127.0.0.1:27019", priority: 3.0 } ]
} } to: localhost:27017
Fri Sep 28 10:56:51 trying reconnect tolocalhost:27017
Fri Sep 28 10:56:51 reconnectlocalhost:27017 ok
reconnected to server after rs command(which is normal)
通常在切换时,我们需要将primary切换到指定db,此时需要指定不同db的优先级,根据优先级的不同在投票时会优先将级别高的切换为primary
登陆到primary
Replset中member的默认优先级为1,区间是1-100,0表示该db只能为secondary,不能变为主
> var c = rs.conf();
rs0:SECONDARY> c
{
"_id" : "rs0",
"version" : 1,
"members" : [
{
"_id" : 0,
"host" :"127.0.0.1:27017"
},
{
"_id" : 1,
"host": "127.0.0.1:27018"
},
{
"_id" : 2,
"host" :"127.0.0.1:27019"
}
]
}
rs0:SECONDARY> c.members[2].priority = 3
3
rs0:PRIMARY> c.members[1].priority = 2
2
rs0:PRIMARY> c.members[0].priority = 1
1
rs0:PRIMARY> c
{
"_id" : "rs0",
"version" : 1,
"members" : [
{
"_id" : 0,
"host" :"127.0.0.1:27017",
"priority" :1
},
{
"_id" : 1,
"host" :"127.0.0.1:27018",
"priority" :2
},
{
"_id" : 2,
"host" :"127.0.0.1:27019",
"priority" :3
}
]
}
rs0:PRIMARY> rs.reconfig(c);
Fri Sep 28 10:56:51 DBClientCursor::initcall() failed
Fri Sep 28 10:56:51 query failed :admin.$cmd { replSetReconfig: { _id: "rs0", version: 2, members: [ {_id: 0, host: "127.0.0.1:27017", priority: 1.0 }, { _id: 1, host:"127.0.0.1:27018", priority: 2.0 }, { _id: 2, host:"127.0.0.1:27019", priority: 3.0 } ]
} } to: localhost:27017
Fri Sep 28 10:56:51 trying reconnect tolocalhost:27017
Fri Sep 28 10:56:51 reconnectlocalhost:27017 ok
reconnected to server after rs command(which is normal)
相关文章推荐
- MongoDB 复制集 (一) 成员介绍
- Replica Set设置一个延迟复制副本集成员
- MongoDB复制集成员的重新同步
- Replica Set设置一个延迟复制副本集成员
- MongoDB 复制集自动故障切换
- Replica Set设置一个延迟复制副本集成员
- MongoDB 复制集(二) 选举 自动故障切换
- Replica Set设置一个延迟复制副本集成员
- Replica Set设置一个延迟复制副本集成员
- Replica Set设置一个延迟复制副本集成员
- Replica Set设置一个延迟复制副本集成员
- MongoDB复制集成员及状态转换
- Replica Set设置一个延迟复制副本集成员
- MongoDB 驱动以及分布式集群读取优先级设置
- 关于mongodb复制集成员的votes和priority属性
- MongoDB 复制集(二) 选举 自动故障切换
- Replica Set设置一个延迟复制副本集成员
- MongoDB 复制集 (一) 成员介绍
- Replica Set设置一个延迟复制副本集成员
- Replica Set设置一个延迟复制副本集成员