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