Mongodb sharding trial (2)

Source: Internet
Author: User
Tags mongodb sharding

1. You can change the partition mode for the existing data storage mode of a single instance.

1.1 start and configure the service instance and route service instance respectively.

1.2 add an existing single instance to the partition mode.

1.3 Finally, decide which set in the database adopts the sharding mode and specify the shard key.

2. Add a new data storage node for the partition mode.

Use admin; db. runCommand ({addshard: "IP. Port "});

After the new node is added successfully, the Set Data Specified to adopt the sharding mode is automatically allocated to the new node.

3. In the fragment mode, change the fragment mode for a set that already exists and does not adopt the fragment mode.

3.1 If the library where the set is located already adopts the sharding mode, but it does not, you only need to run the command to specify the sharding mode of the set.

Use admin; db. runCommand ({shardcollection: "database name. Set"}, key: {xx: 1 });

3.2 If the database where the set is located does not adopt the sharding mode, you must change the database to sharable before specifying the sharding mode of the set.

Use admin; db. runCommand ({enablesharding: "Database Name"}); db. runCommand ({shardcollection: "database name. Set"}, key: {xx: 1 });

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.