MongoDB Finishing notes New Shard Server

Source: Internet
Author: User

1. Start a new shard Server process

[Email protected] ~]# mkdir/data/shard/~]#/apps/mongo/bin/mongod--shardsvr--port 20002--dbpath/data/ shard/S2--fork--logpath/data/shard/log/s2.log--/data/shard/log/6772

2. Configuring the new Shard Server

[[email protected] ~]#/apps/mongo/bin/mongo admin--port 40000MongoDB Shell version:1.8.1Connecting to:127.0.0.1:40000/Admin> Db.runcommand ({addshard: "localhost:20002" }){ "shardadded": "shard0002", "OK": 1 }>printshardingstatus ()---sharding Status---sharding version: {"_id": 1, "Version": 3}shards:{"_id": "shard0000", "host": "localhost:20000" }{ "_id": "shard0001", "host": "Localhost:20001" }{ "_id": "shard0002", "host": "Localhost:20002"}--New Shard serverdatabases:{"_id": "admin", "partitioned":false, "PRIMARY": "config" }{ "_id": "Test", "partitioned":true, "PRIMARY": "shard0000"}test.users chunks:shard00022shard000021stshard000121sttoo many chunksn to print, use verboseifYou want to force printtest.users_2 chunks:shard000146shard00021shard000045too many chunksn to print, use verboseifYou want to force print
View Code

3. View the Shard table status to verify the new Shard Server

>Use testswitched to DB test>db.users_2.stats () {"Sharded":true,"NS": "Test.users_2",......"shard0002": {--the new Shard Server already has data"NS": "Test.users_2","Count": 21848,"Size": 2097408,"Avgobjsize": 96,"Storagesize": 2793472,"Numextents": 5,"Nindexes": 1,"Lastextentsize": 2097152,"Paddingfactor": 1,"Flags": 1,"Totalindexsize": 1277952,"Indexsizes" : {"_id_": 1277952},"OK": 1}},"OK": 1}>
View Code

We can see that when we add Shard Server, the data is automatically distributed to the new Shard, which is self-implemented by MongoDB internally.

MongoDB Finishing notes New Shard Server

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.