MONGO Study Note (v): Shard

Source: Internet
Author: User

Sharding

Face: On behalf of the client, the client must say, you do not shard database shard with me, I told you to do what you do, there is no good to discuss.

MONGOs: First we need to understand the concept of "chip key", that is, what is the basis for splitting the set? To split a collection by what key value ....

Well, MONGOs is a routing server that will distribute the data to the Mongod cluster that it manages, based on the "tablet key" set by the administrator.

and the corresponding configuration information is stored on the "config server".

Mongod: An ordinary database instance, if not sharding, we will directly connect to the Mongod.

First, MONGO copy paste 7 copies

The date folder is an empty folder

Add a bat to each bin folder

Filename Content
Config1.bat Mongod--dbpath=f:\mongo\mongodb_config1\data--port 2001
Config2.bat Mongod--dbpath=f:\mongo\mongodb_config2\data--port 2002
Config3.bat Mongod--dbpath=f:\mongo\mongodb_config3\data--port 2003
Mongos.bat MONGOs--port 2222--configdb 127.0.0.1:2001,127.0.0.1:2002,127.0.0.1:2003
Mongod1.bat Mongod--dbpath=f:\mongo\mongodb_data1\data--port 2004
Mongod2.bat Mongod--dbpath=f:\mongo\mongodb_data2\data--port 2005
Mongod3.bat Mongod--dbpath=f:\mongo\mongodb_data3\data--port 2006

Start in sequence

Config1.bat

Config2.bat

Config3.bat

Mongos.bat

Mongod1.bat

Mongod2.bat

Mongod3.bat

Open a new cmd

F:
CD F:\mongo\mongodb_mongos\bin
MONGO 127.0.0.1:2222/admin
Db.runcommand ({"Addshard": "127.0.0.1:2004"})
Db.runcommand ({"Addshard": "127.0.0.1:2005"})
Db.runcommand ({"Addshard": "127.0.0.1:2006"})

Db.runcommand ({"enablesharding": "Test"})
Db.runcommand ({"Shardcollection": "Test.person", "key": {"name": 1}})

Inserting data

Use test
for (Var i=0;i<10000;i++) {
Db.person.insert ({"Name": "Jack" +i, "age": i})
}

View Effects

Questions:

1.mongos has always reported this: Distributed Lock ' balancer/**** ' unlocked

2. Fragmented, 1W of data is divided into 4444,5555,1 to 3 databases

MONGO Study Note (v): Shard

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.