Implementation of MongoDB cluster construction and Sharding

Source: Internet
Author: User
The type of the MongoDB replication cluster built by the MongoDB cluster: · master-slave mode (masterslave) · replica set mode (replicaset). The replica mode has at least three nodes (one master, two slaves ), the slave node is responsible for copying the oplog of the master node

The type of the MongoDB replication cluster built by the MongoDB cluster: · master-slave mode (master/slave) · replica set mode (replicaset) replica and mode at least three nodes (one master, two slaves ), the slave node is responsible for copying the oplog of the master node






Go to the admin database, activate collection shards, and configure the shard key to be unique.

> Use admin

Mongos> db. runCommand ({shardcollection: "test11.testcoll", key: {_ id: 1}, unique: true })
{"Collectionsharded": "test11.testcoll", "OK": 1}

View shard status information

Mongos> db. printShardingStatus ();
--- Sharding Status ---
Sharding version :{
"_ Id": 1,
"Version": 3,
"MinCompatibleVersion": 3,
"CurrentVersion": 4,
"ClusterId": ObjectId ("532fa07065574826130abfbf ")
}
Shards:
{"_ Id": "rs0", "host": "rs0/172.23.214.47: 27017,172.23 .214.50: 27017,172.23 .215.61: 27017 "}
Databases:
{"_ Id": "admin", "partitioned": false, "primary": "config "}
{"_ Id": "test11", "partitioned": true, "primary": "rs0 "}
Test11.testcoll
Shard key: {"_ id": 1}
Chunks:
Rs0 1
{"_ Id": {"$ minKey": 1 }}-- >>{ "_ id": {"$ maxKey": 1 }}on: rs0 Timestamp (1, 0)
{"_ Id": "testdb", "partitioned": true, "primary": "rs0 "}
{"_ Id": "test", "partitioned": false, "primary": "rs0 "}



This article is from the "mood is still" blog. Please keep this source

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.