Mongodb增加、移除Shard Server实例
1.增加新的配置文件,并启动mongod实例
#14 mkdir-p/data/mongodb/shard311 ./mongod-f/opt/mongodb-linux-x86_64-2.2.0/conf/mongod_3.conf #16 mkdir-p/data/mongodb/shard32 ./mongod-f/opt/mongodb-linux-x86_64-2.2.0/conf/mongod_3.conf #23 mkdir-p/data/mongodb/shard33 ./mongod-f/opt/mongodb-linux-x86_64-2.2.0/conf/mongod_3.conf
2.步骤2初始化set集群
/opt/mongodb-linux-x86_64-2.2.0/bin/mongo-port10003
config={_id:'shard3',members:[
{_id:0,host:'192.168.1.14:10003',priority:1},
{_id:1,host:'192.168.1.16:10003'},
{_id:2,host:'192.168.1.23:10003'}]};
rs.initiate(config);
3.增加shard
/opt/mongodb-linux-x86_64-2.2.0/bin/mongo192.168.1.14:10000/admin
db.runCommand({
addshard:"shard3/192.168.1.14:10003,192.168.1.16:10003,192.168.1.23:10003",
name:"shard3",
maxsize:20480,
allowLocal:true});
4.移除shard
db.runCommand({"removeshard":"shard3/192.168.1.14:10003,192.168.1.16:10003,192.168.1.23:10003"});
注意:
三台服务器clock不同步导致不能分片的问题,今天又碰见一次,同步后就好了。这个问题是不是有点太频繁了,难道每天定时要同步三台服务器的clock?
移除shard的时候时间会比较久,这时候printShardingStatus()的时候会显示状态”draining”:true.
热门推荐
10 新婚简短的祝福语大全
11 小托班祝福语简短
12 艺术生联考祝福语简短
13 带马的祝福语简短
14 女孩生日祝福语简短的话
15 古风祝福语 唯美简短端午
16 买车新年祝福语简短创意
17 同学贺卡励志祝福语简短
18 简单生日祝福语简短大全