MongoDB Add and remove Shard server instances _mongodb

Source: Internet
Author: User
Tags mkdir mongodb mongodb add

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.