understanding of distributed clusters
There are many explanations for the concept of distributed clusters, and I prefer "distributed clustering" to two concepts, that is, distributed is a concept, and clustering is another concept.
Distributed is a whole system into several parts, respectively deployed to different servers, and then unified control by the central server, the formation of an external as a whole system. A cluster is the result of deploying a whole, as a whole, to multiple servers separately.
Both distributed and clustered are descriptions of deployment phenomena, involving the deployment of multiple servers, which are distributed and clustered in the same place, and of course have many of the same effects, but they describe two different phenomena. Let's talk about a distributed cluster of MongoDB databases today.
MongoDB's distributed cluster
MongoDB's distributed cluster mainly has master-slave replication, replica sets, shards, and a combination of shards and replicas, the main content of this blog is the configuration of master-slave replication, then the corresponding blog to describe the other several distributed clusters
Master-slave replication deployment diagram
Master-slave replication configuration
Command Window input //master server (local Database Slaves Table Store association information) mongod--dbpath c:/data/master--port 10000--master //Slave Server ( Sources Table Store Association information for the Local database) mongod--dbpath c:/data/slave1--port 10001--slave--source 192.168.24.131:10000 / /Add from server mongod--dbpathc:/data/slave2--port 10002--slave--source 192.168.24.131:20000
The configuration of the master-slave server is very simple, just add some parameters when you start the server.
Using a client connection on the primary server, and then inserting a number, when we use the client connection on the slave server, you can query to the data that you just inserted.
<span style= "FONT-SIZE:18PX;" > //master server MONGO 127.0.0.1:27017/test //Add (Increase collection and record) Db.documentName.insert ({name: "Qingshan", AGE:25}); Query db.documentName.find (); From the server MONGO 127.0.0.1:27017/test //can query the data inserted into the primary server Db.documentName.find ();</span>
advantages and disadvantages of master-slave replicationAdvantages
Read/write Separation: Master node data read and write, from node data read-only, from the node can not artificially insert data
Data backup: Complete backup of the primary database from the node the disadvantage of the data
Disadvantages
When the primary server fails, it is generally manual intervention, specifying the new master
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
MongoDB Distributed cluster (1, master-slave replication)