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