Mongodb distributed cluster (4. Integration of shards and replica sets) and mongodb Cluster
Overview
The previous three blogs talked about mongodb's distribution and clusters. The first type of master-slave replication is almost useless, which makes no sense. The remaining two types, no matter which one we use separately, there will be corresponding problems. A better solution is to use the set of shards and replica sets, which is perfect.
Deployment Diagram
Here, we need to note that the mongos server is configured as a cluster, so we need to add the corresponding addresses on the client separately, this is the same as the content of the blog in the replica set. The specific core code of the java client program is also provided to you in that blog. If this is unclear, let's take a look at the blog. Shard cluster configuration
Shard cluster configuration // start each Config mongod -- dbpath/data/mongodbtest/config/data -- port 27017 // start each mongos -- configdb 192.168.24.201: 27017,192.168 .24.202: 27017,192.168 .24.203: 27017 -- port 27017 // log on to each mongos to add shards (the replica set configuration process is omitted) use admin db. runCommand ({addshard: "Shard1/192.168.24.1: 27017,192.168 .24.2: 27017,192.168 .24.3: 27017"}); db. runCommand ({addshard: "Shard2/192.168.24.11: 27017,192.168 .24.12: 27017,192.168 .24.13: 27017 "});The above configuration is a core configuration, which involves the specific configuration of replica sets. You can refer to the previous articles and will not go into details here.
To sum up the learning process of mongodb, the most difficult stage is not to learn the content of distributed clusters, but to configure the simplest environment. In this process, I need to go to the official website, download the corresponding server, download the corresponding client driver, and then make the simplest instance. The process is the most difficult. Once you go through that process, nothing else will happen.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.