MongoDB Replica Set Build cluster

Source: Internet
Author: User

MongoDB do cluster, version 3.2 of the recommended cluster mode replica set preparation server 3 two standard node (these two nodes directly can be mutually primary secondary). A arbiter node, holding a ballot in its hand, determines which of the two standard nodes above can become primay. The machine name and pre-assumed roles are as follows: Test39 primarytest41 secondarytest42 Arbiter introduces the parameters--dbpath data file path--logpath log file path--port port number, default  27017. This is the port number I'm using here.--replset Replica set name, a replica sets each node in this parameter to use a copy set name, here is Test.--replset test/ This is followed by the other standard node IP and port--maxconns maximum number of connections--fork run--logappend log files in the background, and if the log file is full, the new log overwrites the longest log. Operation Flow: 1. Three services on each start MONGO instance Bin/mongod--port 27017--dbpath/home/baoshan/cluster/mongodb/data/mongodb--replset Baoshan2. Add replica sets configuration, feel free to login to a MONGO instance >use admin;>cfg={_id: " Baoshan", members:[{_id:0,host: ' test39:27017 ', priority:2}, {_id:1,host: ' test41:27017 ', Priority:1},{_id:2,host: ' Test42 : 27017 ', arbiteronly:true}]};>rs.initiate (CFG); 3. Verify Success Rs.status () with this command, you can see the IP of each node, whether the role is normal rs.stepdown () This command can force primary and standard node roles to be interchanged to verify that failover functionality can be implemented. or the use Admin;db.shutdownserver () is performed on the primary, and the primary effect is broken off. Rs.ismaster () shows who is currently in primary MongoDB replica sets by setting the value of priority to determine the size of precedence, the range of this value is 0--100, the greater the value, the higher the priority. Problems encountered and Solutions:baoshan:secondary> show DBS; 2017-04-28t21:43:46.801+0800 E QUERY [thread1] error:listdatabases failed:{"OK": 0, "errmsg": "Not Master and s Laveok=false "," Code ": 13435}: [Email protected]/mongo/shell/utils.js:25:13 [Email protected]/mongo/shell/mongo.js:62:1 [Email protected]/mongo/shell/utils.js:760:19 [Email protected]/mongo/shell/utils.js:650:15 @ (SHELLHELP2): 1:1Baoshan:secondary> Rs.slaveok ()Baoshan:secondary> show Dbs;admin 0.000GBlocal 0.567GBmetadata 0.001GBservice 2.547GBtest 0.094GB Important reference officer Party documents: https://docs.mongodb.com/manual/Reference Document: Three ways to build a MongoDB cluster: http://blog.csdn.net/luonanqin/article/details/ 8497860replica sets replica set deployment detailed process: Http://blog.csdn.net/mchdba/article/details/51638131replica sets Configuration and setup:/http Blog.chinaunix.net/uid-23284114-id-2977686.html

MongoDB Replica Set Build cluster

Related Article

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.