mongodb--Architecture (Master-slave, replica set) Master and slave

Source: Internet
Author: User



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

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.