MongoDB practice (12) ReplicaSets + Sharding

Source: Internet
Author: User
MongoDBAuto-Sharding solves the problems of massive storage and dynamic resizing, but it is still a little away from the high reliability and high availability required by the actual production environment, so it has a "ReplicaSets + Sharding" solution. 1. Shard:

MongoDBAuto-Sharding solves the problems of massive storage and dynamic resizing, but it is still a little away from the high reliability and high availability required by the actual production environment, so it has a "ReplicaSets + Sharding" solution. 1. Shard:

MongoDB Auto-Sharding solves the problems of massive storage and dynamic resizing, but it is highly available from the actual production environment.
There are still some distance between high availability, so there is a "Replica Sets + Sharding" solution.
1. Shard:
Use Replica Sets to ensure that each data node has backup, automatic fault tolerance transfer, and automatic recovery capabilities.
2. Config:
Use three configuration servers to ensure metadata integrity
3. Route:
Use three routing processes to achieve load balancing and improve client access performance
The following figure shows the architecture of configuring a Replica Sets + Sharding environment.

Open ports are as follows:

Host ip service and Port

Server A192.168.3.231mongod shard1_1: 27017
Mongod shard2_1: 27018
Mongod config1: 20000
Mongs1: 30000

Server B192.168.3.232mongod shard1_2: 27017
Mongod shard2_2: 27018
Mongod config2: 20000
Mongs2: 30000

Server c192.168.3.233104d shard1_3: 27017
Mongod shard2_3: 27018
Mongod config3: 20000
Mongs3: 30000

Create a data directory


On Server:

On Server B:

On Server C:

Configure Replica Sets

1. Configure the Replica Sets used by shard1

On Server:

On Server B:

On Server C:

Use mongo to connect the mongod on port 27017 of one of the machines to initialize the Replica Sets "shard1" and execute:

Configure Replica Sets used by shard2

On Server:

On Server B:

On Server C:

Use mongo to connect mongod of port 27018 of one of the machines, initialize Replica Sets "shard2", and execute:

Configure three Config servers

Run the following command on Server A, B, and C:

Configure three Route Processes
Run the following command on Server A, B, and C:

Configure Shard Cluster

Activate database and set shards

Verify that Sharding works properly

Connect to the mongos process on port 30000 of one of the machines and switch to the test database to add test data.

We can see that the Sharding is successfully built, which is consistent with the expected results. Now we will Replica Sets and Sharding
The integrated architecture is also completed.

This article is from "phper-a little bit every day ~" Blog, please keep this source

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.