MONGDB Copy Set

Source: Internet
Author: User

Steps:

First, start three processes

1./bin/mongod--dbpath=/home/work/app/mongodb/mongodb-linux-x86_64-amazon-3.2.7/data/r0--logpath=/home/work/ Logs/mongodb/r0.log--fork--port=27017--replset=rs1

2./bin/mongod--dbpath=/home/work/app/mongodb/mongodb-linux-x86_64-amazon-3.2.7/data/r1--logpath=/home/work/ Logs/mongodb/r1.log--fork--port=27018--replset=rs1

2./bin/mongod--DBPATH=/HOME/WORK/APP/MONGODB/MONGODB-LINUX-X86_64-AMAZON-3.2.7/DATA/R2--logpath=/home/work/ Logs/mongodb/r2.log--fork--port=27019--replset=rs1

The most important thing is to declare that three MONGO processes are using a replica set --replset=rs1

Second, the configuration

1, with MONGO client arbitrarily connected to a process./bin/mongo, cut to use admin

var rsconf = {

_id: ' Rs1 ',
members:[
{
_id:0,
Host: ' 192.168.1.201:27107 '
},
{
_id:1,
Host: ' 192.168.1.201:27108 '
},
{
_id:2,
Host: ' 192.168.1.201:27109 '
},
]
}

2, according to the configuration to do replcation set of the first mother of

Rs.initiate (rsconf);

3. Adding nodes

rs.add (' 192.168.1.201:27018 ');

Rs.add (' 192.168.1.201:27019 ');

4. View status

Rs.status ();

5. Deleting nodes

Rs.remove (' 192.168.1.201:27019 ');

If you are using a node, the following error occurs

JavaScript execution Failed:error: {"$err": "Not Master and Slaveok=false", "Code": 13435}

The above error occurs because slave is not allowed to read and write by default

Rs.slaveok ();

MONGDB Copy Set

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.