This section describes the master-slave architecture
Master-Slave architecture--deprecated, recommended for use with replica sets
The master-slave configuration can be configured in the configuration file
From node can use command to append master node after startup, Db.source.insert ({"Host": "Ip+ Port"})
Connection node: MONGO 127.0.0.1:29991, master node allows read and write
A, from the node can be connected, but do not allow read and write, if you want to read can be set Db.getmongo (). Setslaveok ()
B. Run Db.getmongo () on the master node. Setslaveok ()
1. Set folder directory
2, the level of each directory is the DB directory, log directory, configuration file 3
3. configuration file Contents
Architecture:
A, master node configuration file
Dbpath=d:\ms\master\db
Logpath=d:\ms\master\log\s.log
Logappend=true
port=29991
Master=true
b, from the node configuration file
Node 1
Dbpath=d:\ms\slave2\db
Logpath=d:\ms\slave2\log\s.log
Logappend=true
port=29993
Slave=true
source=127.0.0.1:29991
Node 2
Dbpath=d:\ms\slave2\db
Logpath=d:\ms\slave2\log\s.log
Logappend=true
port=29993
Slave=true
source=127.0.0.1:29991
4, after the configuration file processing, use the cmd command line form, mongod--config configuration file path to start 4 instances. To start the successful interface as follows, you need to open multiple command shells in turn.
5. Use MONGO 127.0.0.1:29991 to link to an instance of the master node, then create collections and records within the instance, and synchronize directly to the other 3 slave nodes.
Arriving at this step will be the simplest test-master architecture to build successfully. (because there is no use of auth login authentication, etc., using the configuration file is also the old version of the wording, YAML version of the configuration file as follows:)
# Where and how to store data.
Storage
Dbpath:d:\ms\master\db
Journal
Enabled:true
# Where to write logging data.
Systemlog:
Destination:file
Logappend:true
Path:d:\ms\master\log\m.log
# Network Interfaces
Net
port:29991
#processManagement:
#security:
#operationProfiling:
#replication:
#sharding:
# # Enterprise-only Options:
#auditLog:
#snmp:
Project files
Http://pan.baidu.com/s/1c1BiCVY
mongodb--Architecture (Master-slave, replica set) Master and slave