MongoDB as a document database, support shard storage, scale-out, cluster automatic switch, the following summary configuration steps summarized as follows:
Several important concepts:
Database: Collection--record--cursor (tag ordinal at query)
Sharding Shard: Start shard Server, start config server, start route process, configure Shard cluster, store the specified collection Shard , each shard consists of multiple chunk, Adding multiple shard servers to a collection in a specified database is used for sharding. Increased scalability, and load balancing
Replica sets: Specify the data save directory, log directory, master-slave key file (all instances in each sets, the contents of the key file must be consistent); Start the instance (if you use shards, you can not launch the instance); Configure initialization replica Sets (primarily server IP, port), respectively, for a single Shard server setting sets
The following is based on two physical servers
1. Planning
1) Server A
shard1_1:10000
shard2_1:10001
Monngod config1:20000
mongs1:30000
2) Server B
shard1_2:10000
shard2_2:10001
Monngod config1:20000
mongs1:30000
2. Create Data Catalog
1) Server A
Mkdir-p/data/shard1_1
Mkdir-p/data/shard2_1
Mkdir-p/data/config
1) Server B
Mkdir-p/data/shard1_2
Mkdir-p/data/shard2_2
Mkdir-p/data/config
3, configuration replica sets (Master-slave)
1) Configure the configuration parameters required for Shard1,shard2 on each physical server, log files
2) Initialize replica sets
3) Configuring config server
4. Configuring Router Process (front-end routing)
1)/apps/mongo/bin/mongos--congigdb
--chunksize 1
--logpath/data/mongos.log--logappend--fork
5, Configuration Shard Cluster
Connect to a 30000 configuration port on one of the physical machines and switch to the admin database to do the configuration
1) addshard Add Shard node
2) enablesharding "database name" to set the database for the Shard store
3) shardcollection "database name. Collection name", Key:{_id:1} sets the collection name of the Shard, and must specify Shard key, the system automatically creates an index
6, verify sharding normal work
1) switch to the specified database
2) Adding records
3) View Shard condition
Legacy issues:
1) The directory of the data files, where does the final storage space come from? Docking that storage engine? (Does the underlying storage provide LUNs or file shares?) )
Answer:
2) The relationship between Chunk,shard,sets:
Answer: Each chunk default is 200MB size, you can specify the size when you start the route process;
Each shard can be made up of multiple chunk
MONGO officially recommend a shard for a group of replica sets, so that you can implement shard within each aoto-failover
3)
2016-11-16 MongoDB Configuration steps