MongoDB Cluster Build-replica set
Conceptual knowledge, you can refer to my blog address:
Http://www.cnblogs.com/zlp520/p/8088169.html
I. Replica SET scheme (replica set or replica set):
1. There are two ways to build a replica set:
One: On a server, through the way the file and the port number of the way to distinguish;
Second: Find at least three servers, each server through the following configuration;
IP planning for each server to assume the job:
192.168.0.100:27017 Host
192.168.0.101:27017 Replica Set
192.168.0.102:27017 arbitration
Here's an example of building on three servers:
2. Step: (Just follow the steps, 100% success)
(1) Create folders and files:
Folder:
Create Data folder;
Create a DB folder;
Create a logs folder;
Create a configuration folder;
File:
Create a log file;
Example:
For example, my database is stored under the DB folder, and the logs are stored under the logs file:
Database storage location: D:\MongoDB\data\db
Log storage location: D:\MongoDB\data\logs\mongodb.log
(2) Create the configuration file and configuration:
D:\MongoDB\config\mongod.conf
Mongod.conf content:
Dbpath=D:\MongoDB\data\dblogpath=D:\MongoDB\data\logs\mongod.logjournal=true BIND_IP=192.168.0.100Port=27017replset=rs
(3) Start MongoDB as a configuration file:
DOS command:
You must switch to the directory where the Mogod.exe is located or configure the Windows system environment variables
Mongod--config D:\MongoDB\config\mongod.conf
Use the MONGO Shell to perform actions: (execute each command individually, do not execute together, I tried, error)
DOS command:
Switch to the Mongo.exe directory:
MONGO--port 27017--host 192.168.0.100 To configure the replica set with 100 of this server, (host)rs.initiate () rs.conf () Rs.add (" 192.168.0.101:27017 " ) Rs.addarb ("192.168.0.102:27017") rs.status ()
(4) test Result:
When the host is down, the quorum will execute the poll, and if there are more than one replica set server, a multi-voting service is working as a host. (test method, you can stop the host to see if the copy synchronizes the host's data)
3. Conclusion:
Reduce downtime to a minimum, even without downtime.
Baidu downtime of about 30 minutes, in this earn sub-second internet era, was transmitted swirl, Baidu How can go down, he is not Baidu, and so on topic.
----believe that they can do great things.
MongoDB Cluster Build-replica set