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 妈妈祝福语简短16字