MongoDB Sharding cluster (Sharding whith Replica Set)

Source: Internet
Author: User
Tags install mongodb mongodb sharding

MongoDB Sharding Cluster is a horizontally scalable mode. It is very powerful when the data volume is large. I have been trying to study three roles to build a MongoDB Sharding Cluster:

1. Shard Server: mongod instance, used to store actual data blocks. In the actual production environment, a role of Shard Server can be assumed by one Replica Set of several machines to prevent single point of failure (spof) on the host.

2. Config Server: mongod instance, which stores the entire Cluster Metadata, including Chunk information.

3. Route Server: mongos instance, front-end routing, access from the client, and make the entire cluster look like a single database, front-end applications can be used transparently.

The Sharding architecture is as follows:

650) this. width = 650; "border = 0>

Because it is an experimental environment, I only use a Linux server. The basic information is as follows:

1. Three Sharding parts

2. Each shard consists of three nodes, one master node and two slave Replica Set.

3. Three configuration nodes: Configsvr

4. 1 routing node Mongos

Shard replica set A (three shard nodes constitute A replica set): 127.0.0.1: 10000 127.0.0.1: 10001 127.0.0.1: 10002

Shard replica Set B (three shard nodes constitute a replica set): 127.0.0.1: 20000 127.0.0.1: 20001 127.0.0.1: 20002

Sharding replica set C (three sharding nodes constitute a replica set): 127.0.0.1: 30000 127.0.0.1: 30001 127.0.0.1: 30002

Configsvr (three configuration server nodes): 127.0.0.1: 40000 127.0.0.1: 40001 127.0.0.1: 40002

Mongos (a route node): 127.0.0.1: 50000

The procedure is as follows:

1. Download and install MongoDB and create a MongoDB user

 
 
  1. tar zxvf mongodb-linux-i686-2.0.4.tgz -C /usr/local/  
  2. mv /usr/local/mongodb-linux-i686-2.0.4/ /usr/local/mongodb/  
  3. ln -s /usr/local/mongodb/bin/* /usr/bin/  
  4.  
  5. groupadd -g 20001 mongodb  
  6. useradd -u 20001 -g mongodb mongodb  
  7.  
  8. su - mongodb 

2. Create related directories

 
 
  1. mkdir -p /home/mongodb/data/shard1/r0  
  2. mkdir -p /home/mongodb/data/shard1/r1  
  3. mkdir -p /home/mongodb/data/shard1/r2  
  4. mkdir -p /home/mongodb/data/shard1/config  
  5.  
  6. mkdir -p /home/mongodb/data/shard2/r0  
  7. mkdir -p /home/mongodb/data/shard2/r1  
  8. mkdir -p /home/mongodb/data/shard2/r2  
  9. mkdir -p /home/mongodb/data/shard2/config  
  10.  
  11. mkdir -p /home/mongodb/data/shard3/r0  
  12. mkdir -p /home/mongodb/data/shard3/r1  
  13. mkdir -p /home/mongodb/data/shard3/r2  
  14. mkdir -p /home/mongodb/data/shard3/config    
  • 1
  • 2
  • Next Page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.