Mongod -- configsvr -- dbpath ${MONGODB_PATH}/config/data - port 21000 - logpath ${MONGODB_PATH}/config/log/config. The log - fork
Mongod - shardsvr replSet shard1 - port 22001 - dbpath ${MONGODB_PATH}/shard1/data - the logpath ${MONGODB_PATH}/shard1/log/shard1 log - fork -- nojournal oplogSize 10
Mongod - shardsvr replSet shard2 - port 22002 - dbpath ${MONGODB_PATH}/shard2/data - the logpath ${MONGODB_PATH}/shard2/log/shard2 log - fork -- nojournal oplogSize 10
Mongod - shardsvr replSet shard3 - port 22003 - dbpath ${MONGODB_PATH}/shard3/data - the logpath ${MONGODB_PATH}/shard3/log/shard3 log - fork -- nojournal oplogSize 10
In 172.24.222.32 this server running on
Mongos - configdb 172.24.222.32:21000172.24. 222.39:21000172.24. 222.46:21000-20000 the port - the logpath ${MONGODB_PATH}/mongos/log/mongos.
log - forkShard server set up to check the configuration
Mongos> The runCommand ({1} listshards:)
{
"Shards" : [
{
"_id" : "shard1,"
"The host" : "shard1/172.24.222.32:22001172.24. 222.39:22001172.24. 222.46:22001"
},
{
"_id" : "shard2,"
"The host" : "shard2/172.24.222.32:22002172.24. 222.39:22002172.24. 222.46:22002"
},
{
"_id" : "shard3,"
"The host" : "shard3/172.24.222.32:22003172.24. 222.39:22003172.24. 222.46:22003"
}
],
"Ok" : 1
}
Then the table1 the kidwatch database collection shard
The runCommand ({enablesharding: "kidwatch"});
# specified database needs fragmentation collection and bonding
The runCommand ({shardcollection: "kidwatch. Table1", the key: {key_id: 1}})
Return all after successful
Use kidwatch
Then I insert the data
For (var I=1; i <=3000000; I++)
Db. Table1. The save ({key_id: I, "testkey" : "testval}");
After successful checking their shard
Mongos> Db. Table1. Stats ()
{
"Sharded" : true,
"Ns" : "kidwatch. Table1,"
"Count" : 2999999,
"NumExtents" : 13,
"Size" : 192000000,
"StorageSize" : 243314688,
"TotalIndexSize" : 181065696,
"IndexSizes" : {
"_id_" : 97343456,
"Key_id_1" : 83722240
},
"AvgObjSize" : 64.00002133334044,
"Nindexes" : 2,
"Nchunks" : 1,
"Shards" : {
"Shard1" : {
"Ns" : "kidwatch. Table1,"
"Count" : 2999999,
"Size" : 192000000,
"AvgObjSize" : 64.00002133334044,
"StorageSize" : 243314688,
"NumExtents" : 13,
"Nindexes" : 2,
"LastExtentSize" : 68579328,
"PaddingFactor" : 1,
"SystemFlags" : 1,
"UserFlags" : 0,
"TotalIndexSize" : 181065696,
"IndexSizes" : {
"_id_" : 97343456,
"Key_id_1" : 83722240
},
"Ok" : 1
}
},
"Ok" : 1
}
All the data are written to a chunk, and chunksize I have set to 1 MB
Mongos> Db. Settings. The find ()
{" _id ":" chunksize ", "value" : 1}
Now I don't know what causes mongo will not block, the great god, please answer, thank you very much
CodePudding user response:
You shard cluster, did not unlock the function of automatic subdivision, which is not open balancer, perform under mongos sh. StartBalancer (); Then enter the config library, the implementation of the db. Settings. The find (), you can see {" _id ":" balancer ", "stopped" : false}