mongos

config server

sharding set


sh.addShardTarg(shard,tag)

Copy the code

Balancer:

View the balancer state. Sh. Getbalanceerstatus (sh). The stopbanlancer (sh). The startbalancer (sh). The movechunk (namespace, query, destination,Copy the code

Chunk:

The default value is 64 MB. The chunk setting problem: The setting is too small, which causes frequent splitting and relocation, affecting network performance. The size of the chunk is too large to be stored and read separately, causing data access bottlenecks. Chunk splitting: When the chunk size reaches the specified value. When document in chunk reaches its maximum value.Copy the code



Copy the code

shard

1Create index db.collocation_name. Ensureindex (db.collocation_name."field")
2
db.enablesharding("database_name")
3Collection_name (database_name. Collection_name, fragment key)Copy the code

Shard state

db.shardingstatus()

View the replication set status

rs.conf()

Rs. The add (/ IP | domain name, the port)

rs.conf().members[i].priority

rs.conf().members[i].slavedelay

rs.conf().members[i].hideen

Rs. Addarb (] [IP | domain name, the port)

Rs. Remove (] [IP | domain name, the port)

rs.stepdown()

db.ismaster()

sh.runcommand({removeshard:{shard_name}})

sh.runcommand({addshard:{shard_name}})

sh.status()

sh.getbalancer()

sh.startbalancer()

sh.stopbalancer()

sh.setbalancerstate(true)

sh.setbalancerstate(false)

sh.disablebalancing(database_name,collection_name)

sh.enablebalancing(database_name,collection_name)

Operating the insert ()

update()

remove()

$gt $eq $n $in $nin $and $or $nor $not $exist $set $push $pull $POP $inc $first $last $project specifies the field to display $substr intercept characters $Switch $TOLower to Lowercase $concat Connect $Split split $Add $Subtract $mutilply $divide $mod mutilply $Year $Month $week $hour $minute $second $dayofYear $dayofMonth $dayofweek $Group $Limit $SKIP $sort $LOOKUP $SUM $AVG $Max $mmin $push $addtoset $unwind $outCopy the code