MongodbreplSet startup and configuration Initialization

Source: Internet
Author: User
MongodbreplSet start and configure initialize the windows environment www.2cto.com start three instances: Java code d: mongodbbinmongod -- replSetrs1 -- port28010 -- dbpathd: mongodbdb28010 -- logpathd: mongo-- logappendd: mongodbbinmongod -- replSet

Start mongodb replSet and configure initialize the windows environment www.2cto.com to start three instances: Java code d: \ mongodb \ bin \ mongod -- replSet rs1 -- port 28010 -- dbpath d: \ mongodb \ db \ 28010 \ -- logpath d: \ mongodb \ logs \ 28010.log -- logappend d: \ mongodb \ bin \ mongod -- replSet

Mongodb replSet startup and configuration Initialization

Windows Environment

Www.2cto.com

Start three instances:

Java code

D: \ mongodb \ bin \ mongod -- replSet rs1 -- port 28010 -- dbpath d: \ mongodb \ db \ 28010 \ -- logpath d: \ mongodb \ logs \ 28010.log -- logappend

D: \ mongodb \ bin \ mongod -- replSet rs1 -- port 28011 -- dbpath d: \ mongodb \ db \ 28011 \ -- logpath d: \ mongodb \ logs \ 28011.log -- logappend

D: \ mongodb \ bin \ mongod -- replSet rs1 -- port 28012 -- dbpath d: \ mongodb \ db \ 28012 \ -- logpath d: \ mongodb \ logs \ 28012.log -- logappend

Configuration and initialization: (only configured at the first time)

Java code www.2cto.com

D: \ mongodb \ bin \ mongo-port 28010

Rscfg = {

"_ Id": "rs1 ",

"Members ":[

{

"_ Id": 0,

"Host": "localhost: 28010"

},

{

"_ Id": 1,

"Host": "localhost: 28011"

},

{

"_ Id": 2,

"Host": "localhost: 28012"

}

]

}

Rs. initiate (rscfg );

Rs. status ();

(When garbled characters are displayed in cmd, enter: chcp 65001 in cmd, and then change the display font to Lucida Console)

Access the slave database so that the slave database can be queried, so as to share a large number of query operations on the master database:

Java code

D: \ mongodb \ bin \ mongo-port 28011

Db. getMongo (). setSlaveOk ()

D: \ mongodb \ bin \ mongo-port 28012

Db. getMongo (). setSlaveOk ()

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.