MongoDB Master-slave replication configuration

Source: Internet
Author: User
Tags server port

In the MongoDB configuration file configuration described how to configure, here we are using the configuration file for Master/slave configuration implementation of Master-slave replication:

First, the configuration of the master-slave server:

1. master server configuration file: master.conf

port=27017

# Primary Server Port

Dbpath=e:\db\mongodb\data

#主服务进程数据存放目录

Logpath=mongodb.log

#主服务日志存放目录

Master=true

#配置为主服务

Logappend=true

#进行日志的追加而不是清空原有日志再添加

maxconns=1024

#数据库最大连接数

2. From the server configuration file: slave.conf

port=27018

#从服务器端口

Dbpath=e:\db\mongodb\data\slavepath

#从服务进程数据存放目录

Logpath=mongodbslave.log

#从服务日志存放目录

Logappend=true

#实现日志的追加

Slave=true

#配置为从服务

source=127.0.0.1:27017

#同步的主服务地址

Autoresync=true

#实现自动同步

3. Start the main server:

4. Start from the server:

5. The client connects to the master server and operates:

6. Add data to master and save:


7. Client connection from server:


8, from the database data query


From the query results we can see that the data from the library is synchronized with the main library

Connection status can also be viewed in the log

Here is a master and a slave between the replication, and the replication deployment method There is a complex, specific next study!

MongoDB Master-slave replication configuration

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.