|
Fragmentation
There is another cluster Mongodb within, slicing technology, a large amount of data to meet the growing demand for MongoDB.
When MongoDB to store vast amounts of data, a machine may be insufficient to store the data is sufficient to provide an acceptable read and write throughput. At this point, we can split the data on multiple machines, so that the database system can store and process more data.
Why slice
Copy all write operations to the primary node
Delay sensitive data in the master query
A single copy set is limited to 12 nodes
When the huge volume of requests will appear when the memory.
Local disk shortage
Vertical expansion is expensive
MongoDB slice
Shard:
Used to store the actual data block, the actual production environment, a shard server role can set a few machines relica set a commitment to prevent the host single point of failure
Config Server:
mongod instance, stores the entire ClusterMetadata, including the chunk information.
Query Routers:
The front end of the route, whereby the client access, and the whole cluster look like a single database front-end applications can transparently use.
Specific examples
Three shard using a configuration service
1. First start the database server port three are: 55555,55556,55557, host: localhost.
./mongod --port 55555 --dbpath = data / share1 --logpath = data / share1 / logs / s1.log --logappend --fork
./mongod --port 555556 - dbpath = data / share2 --logpath = data / share2 / logs / s2.log --logappend --fork
./mongod --port 55557 --dbpath = data / share3 --logpath = data / share3 / logs / s3.log --logappend --fork
2. Launch configuration server
./mongod --port 55558 --dbpath = data / config --logpath = data / config / logs / cnf.log --logappend --fork
3. Start routing services.
./mongos --port 55554 --dbpath = data / share --logpath = data / share / logs / route.log --logappend --fork --configdb localhost: 55558 --chunkSize 500
Wherein chunkSize to slice the size, configuration, services are mainly stored routing information
4. Add shard
use admin
db.runCommand ({addshard: "localhost: 55555"})
db.runCommand ({addshard: "localhost: 55556"})
db.runCommand ({addshard: "localhost: 55557"})
db.runCommand ({enablesharding: "test"}) // database test partakers sheet capacity
db.runCommand ({shardcollection: "test.log", key: {id: 1, time: 1}}) // specified document in the corresponding database table through what fragmentation. Here is a test based on the log table id and time slicing.
5. See fragment status
db.runCommand ({listshards: 1}) |
|
|
|