"MongoDB" to build MongoDB Shard cluster under Windows platform (ii)

Source: Internet
Author: User

In the previous blog, we talked about the main principle of the Shard cluster in Mongodb database. In this blog, we mainly describe the construction process of the Shard cluster. There are two main steps to configuring a shard cluster, the first to start all required Mongod and mongos processes. The second step is to start a mongos communication with the cluster. Let 's take a step-by-step description of the cluster build process.


Figure 1-1 components in a MongoDB shard cluster


Figure 1-2 A complete picture of a process composed of instance shard clusters


Note: Both images are quoted from Kyle Banker the translation of the Jonathan Allen MongoDB actual Combat "

2.1Create a shard directory

Note: This is similar to creating a replica set, see blog for more details: http://blog.csdn.net/sxb0841901116/article/details/40596361


2.2Start replica set

We start two replica sets with the following command:

--shardsvr--replset shard-a--dbpath "D:\Program files\mongodb\data\slide\data\rs-a-1"--port mongod--logpath "D : \program Files\mongodb\data\slide\log\rs-a-1.log "--nojournalmongod--shardsvr--replset shard-a--dbpath" D:\ Program Files\mongodb\data\slide\data\rs-a-2 "--port 3001--logpath" D:\Program files\mongodb\data\slide\log\ Rs-a-2.log "--nojournalmongod--shardsvr--replset shard-a--dbpath" D:\Program files\mongodb\data\slide\data\rs-a-3 " --port 3002--logpath "D:\Program files\mongodb\data\slide\log\rs-a-3.log"--nojournalmongod--shardsvr--replSet Shard-b--dbpath "D:\Program files\mongodb\data\slide\data\rs-b-1"--port 30100--logpath "D:\Program files\mongodb\ Data\slide\log\rs-b-1.log "--nojournalmongod--shardsvr--replset shard-b--dbpath" D:\Program Files\mongodb\data\ Slide\data\rs-b-2 "--port 30101--logpath" D:\Program files\mongodb\data\slide\log\rs-b-2.log "--nojournalmongod-- Shardsvr--replset shard-b--dbpath "D:\Program files\mongodb\data\slide\data\rs-b-3"--port 30102--logpath" D:\Program files\mongodb\data\slide\log\rs-b-3.log "--nojournal 

When successfully running, a 6 Black window appears similar to the following:


2.3Start replica set

Start the first replica set shard-a:

You can use the rs.status () command to view the status of the first replica set.

Start second replica set shard-b:

2.4 Creating a Configuration server directory




2.5 Start the configuration server with the following command
Mongod--configsvr--dbpath "D:\Program files\mongodb\data\slide\data\config-1"--port 27019--logpath "D:\Program Files\mongodb\data\slide\log\config-1.log "--nojournalmongod--configsvr--dbpath" D:\Program Files\mongodb\data\ Slide\data\config-2 "--port 27020--logpath" D:\Program files\mongodb\data\slide\log\config-2.log "--nojournalmongod --configsvr--dbpath "D:\Program files\mongodb\data\slide\data\config-3"--port 27021--logpath "D:\Program Files\ Mongodb\data\slide\log\config-3.log "--nojournal

Use the shell to Connect or view the log text, make sure each configuration server is up and running, and verify that each process is listening on the configured port. View the logs for each configuration server and you should be able to see such content.

To view the Task Management window, the running process:


2.6StartMongos

The boot mongos must be started using the configdb option. It accepts a comma-separated list of configuration server addresses:

Mongos--configdb win--20141018ko:27019,win--20141018ko:27020,win--20141018ko:27021--logpath "D:\Program Files\ Mongodb\data\slide\log\mongos.log "--port 40000

Second, configure the cluster

On the login mongos , view the available commands:

Add the Shard shard-a, Shard-b to the Shard cluster:

View the Shard cluster in two ways :


"MongoDB" to build MongoDB Shard cluster under Windows platform (ii)

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.