MongoDB has a major feature is replication, there are many forms of replication, where master-slave replication is a more common one.
Master-slave replication works: first of all to have two or more servers, one of which is the master node, responsible for processing the client's request, the other is from the node, is responsible for mapping the master node data. The master node records all operations performed on it, and periodically polls the master for these operations from the node, and then performs these operations. Since the same operation is performed from the node and the primary node, the data from the node can be kept synchronized with the master node.
To explain the construction of MongoDB and master-slave replication, because there is only one server, so only through the modification of the port number of MongoDB master and slave, rather than through the implementation of multiple servers. In fact, the principle is the same ~, just do not make practical sense ~
Previously installed a version of MongoDB (2.6.11), since now MongoDB has been updated to 3.0.6, then from the library on the use of 3.0.6, anyway, it is testing purposes, no matter how much ~
installation
Mongodb
Download mongodb3.0.6 Execute Package and unzip, put binary execution file in/usr/local/mongo3.0.6 directory
Configuration Main Library configuration
# Mongod.conf#where to loglogpath=/var/log/mongodb/mongod-27017.loglogappend=true# Fork and run in backgroundfork= trueport=27017#dbpath=/var/lib/mongodbpath=/data/mongodb/mongo-27017# Location of pidfilepidfilepath=/var/run/ mongodb/mongod-27017.pidbind_ip=127.0.0.1,192.168.56.61#noauth=true# Ignore Query hints#nohints=true# Disable the HTTP interface (Defaults to localhost:27017). Nohttpinterface = Falserest = Truemaster = True
Configure from Library
# Mongod.conf#where to loglogpath=/var/log/mongodb/mongod-27018.loglogappend=true# Fork and run in backgroundfork= trueport=27018#dbpath=/var/lib/mongodbpath=/data/mongodb/mongo-27018# Location of pidfilepidfilepath=/var/run/ mongodb/mongod-27018.pid# Listen to local interface only. Comment out to listen on all interfaces. bind_ip=127.0.0.1,192.168.56.61#noauth=true# Ignore Query hints#nohints=true# Disable the HTTP interface (Defaults to localhost:27018). Nohttpinterface = Falserest = Trueslave = Truesource = 127.0.0.1:27017
Start
# Main Library start/usr/local/mongo2.6.11/mongod-f/etc/mongod/mongod-27017.conf# start/usr/local/mongo3.0.6/mongod-f/etc/from library Mongod/mongod-27018.conf
Certification
Different versions of MongoDB start Auth mode can be implemented by the following methods
1. Set all master and slave MongoDB to Unauth mode first
2. Add an account to master so that slave automatically synchronizes the account
3. Turn on Auth mode for all master and slave MongoDB
MongoDB different versions for master-slave replication