1. Add new configuration file and start Mongod instance
Copy Code code as follows:
#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. Step 2 Initialize Set cluster
Copy Code code as follows:
/opt/mongodb-linux-x86_64-2.2.0/bin/mongo-port 10003
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. Increase Shard
Copy Code code as follows:
/opt/mongodb-linux-x86_64-2.2.0/bin/mongo 192.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. Removal of Shard
Copy Code code as follows:
Db.runcommand ({"Removeshard": "shard3/192.168.1.14:10003,192.168.1.16:10003,192.168.1.23:10003"});
Note:
Three servers clock different steps leading to the problem can not be fragmented, and met again today, synchronized after the good. This question is not a bit too frequent, do you have to sync three servers clock?
The time to remove Shard is longer, when Printshardingstatus () shows the state "draining": true.