01.
Welcome to use ueditor!
MongoDB supports asynchronous data replication between different services to implement failover (failover, failover, failback) and redundancy (data redundancy).
At the same time, only one service node (primary or master) supports writing.
MongoDB supports two modes of replication:
Master/slave, master-slave replication, roles include Master and Slave.
Replica set, replica set replication, roles include primary and secondary.
To introduce the official address of Master/slave:
Http://www.mongodb.org/display/DOCS/Master+Slave
Describes the official address of replica set:
Http://www.mongodb.org/display/DOCS/Replica+Sets
Today's actual combat is Master-slave, that is, master-slave replication.
Start the service using Mongod first, and the parameters for startup can be found in the Http://www.mongodb.org/display/DOCS/Command+Line+Parameters page.
The following are some of the parameters used for master-slave copying:
--master, indicating that the current service is the master.
--slave, indicating that the current service is from.
--source, indicating the address of the main service, in the form of Server:port.
--only <db>, indicating that the specified database is currently copied from only the master, and that the database name is in DB.
The start service can specify a single parameter from the command line, or you can store the parameters in a file, and then start by specifying the file as the service's configuration file. The following methods are easy to manage and maintain, recommended for use.
First configure the main service.
01.port=30000
02.ddbpath=d:\mongodb\master1
03.directoryperdb=true
04.logpath=d:\mongodb\master1\log.log
05.logappend=true
06.master=true
07.bind_ip=192.168.0.111
Configure the parameters as shown above, copy the parameters above to a file, name "Master1.conf", and then use the following command to start the main service.
D:\mongodb\bin\mongod--config=d:\mongodb\master1\master1.conf
Above is the command initiated in Windows.
If used in Ubuntu, assume that the conf file is stored in the/home/andyshi/master1/directory, the Conf file content modified as follows.
port=30000
dbpath=/home/andyshi/master1
directoryperdb=true
logpath=/home/andyshi/master1/log.log
logappend=true
master=true
bind_ip=192.168.0.111
Use the following command to start the main service.
Mongod--conf=/home/andyshi/master1/master1.conf
It is noted that the main difference is the location of the catalogue, pay attention to it.
Then you can use the MONGO client to test the results of our configuration, or use Python+pymongo can also be tested, by the way familiar with the use of Python+pymongo.
Our client test environment uses ubuntu+python2.7+pymongo2.1.
Enter in the terminal
MONGO 192.168.0.111:30000