MongoDB Cluster Fragmentation Deployment practice

Source: Internet
Author: User
Tags mongodb

First step. Start the appropriate Mongod process

Mongod--fork--slave  --port 27017--replset myset--rest--dbpath/data/dbmongo/shard11--logpath/data/dbmongo/ Shard11.log
mongod--fork--slave--port 27018--replset myset--rest--dbpath/data/dbmongo/shard12--logpath  / Data/dbmongo/shard12.log
mongod--fork--slave  --port 27019--replset myset--rest--dbpath/data/dbmongo/ Shard13--logpath/data/dbmongo/shard13.log mongod--fork--slave--port 27020--replset myset--rest--dbpath  / Data/dbmongo/shard14--logpath/data/dbmongo/shard14.log

Step two. Initialize replica set

>config = {_id: ' MySet ', members:[{_id:0, Host: ' 192.168.1.111:27017 '},{_id:1, Host: ' 192.168.1.112:27018 '},{_id:1, Host: ' 192.168.1.113:27019 '},{_id:2, Host: ' 192.168.1.114:27020 '}}]}
>rs.initiate (config);
>rs.status ();

Step three. Configure a config Servers:

192.168.1.100
mongod--fork--configsvr--port 20000--rest--dbpath/data/dbmongo/config--logpath/data/dbmongo/ Config/config.log 

Fourth step. Configure a route Servers
Mongos-fork--port 30000--chunksize 1--configdb "192.168.1.100:20000"--logpath/data/dbmongo/mongos.log

Fifth step. Configuring the Shard Cluster connect to the MONGOs process and switch to the Admin database for the following configuration

192.168.1.100
>mongo 192.168.1.100:30000
>use admin
>db.runcommand ({addshard: ' myset/ 192.168.1.115:27021,192.168.1.116:27022 '});
>db.runcommand ({enablesharding: ' Test '});
>db.runcommand ({listshards:1});
>printshardingstatus ();
>db.runcommand ({shardcollection: ' Test.test ', key:{_id:1},unique:true});

Step sixth. Test

>for (Var i=1;i<=2011;i++) B.test.save ({id:i,value1: "1234567890", value2: "1234567890", Value3: "1234567890", Value4: "1234567890"});



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.