MongoDB Shard cluster Environment construction record

Source: Internet
Author: User

--Create a configuration server
Mongod.exe--logpath "G:\USERDATA\MONGODB\Test2\Log\mongodb.log"--logappend--dbpath "G:\USERDATA\MONGODB\Test2\DB "--port 27031--servicename" MongoTest2 "--servicedisplayname" MongoTest2 "--install--configsvr

--Create a shard controller
MONGOs--configdb 172.23.88.116:27031--port 27041--chunksize 1--servicename "MongoTest2"--logpath "G:\USERDATA\ Mongodb\test2\log\mongodb.log "--servicedisplayname" MongoTest2 "--install

--Create two specific shard servers
Mongod.exe--logpath "G:\USERDATA\MONGODB\Test\Log\mongodb.log"--logappend--dbpath "G:\USERDATA\MONGODB\Test\DB"- -port 27030--servicename "mongotest"--servicedisplayname "Mongotest"--install

--Uninstall MongoDB service
Mongod.exe--remove--servicename "Mongotest"
Mongod.exe--remove--servicename "MongoTest2"


--Adding shards
Db.runcommand ({addshard: "172.23.88.116:27030"})
Db.runcommand ({addshard: "172.23.88.116:27040"})
--View shard status
Db.printshardingstatus ();
--Set up a library of shards
Db.runcommand ({enablesharding: "Relationlist"})
--Set the collection of shards, note that the name must be the library name + table name
Db.runcommand ({shardcollection: "relationlist.mactable", key: {_id:1}})

MongoDB Shard cluster Environment construction record

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.