MongoDB Foundation (eight) Replication ⅱ-deployment Quorum node

Source: Internet
Author: User

An arbiter (arbiter) is a MongoDB instance in a replication set that does not hold data. The quorum node uses minimal resources and does not require hardware devices, cannot deploy arbiter in one dataset node, can be deployed on other application servers or monitoring servers, or can be deployed in a separate virtual machine. To ensure that there are an odd number of voting members (including primary) in the replication set, the quorum node needs to be added as a vote, otherwise primary will not automatically switch primary when it is not running.


A replication set can have 50 members, but only 7 voting members (including primary) and the rest are non-voting members (non-voting). A non-voting member is a backup copy of the data in the replication set and does not participate in the poll, but can be voted on or referred to as the primary node.


The structure is as follows:



In the previous article: http://blog.csdn.net/kk185800961/article/details/45700485

3 nodes are configured:

192.168.1.11:27017 (primary)
192.168.1.12:27018 (secondary)
192.168.1.13:27019 (secondary)


Current node Condition:

Rs0:secondary> Db.ismaster () {"SetName": "Rs0", "setversion": "IsMaster": false, "secondary": True, "hosts": ["Mon godb11.kk.net:27017 "," mongodb12.kk.net:27018 "," mongodb13.kk.net:27019 "]," PRIMARY ":" mongodb13.kk.net:27019 "," Me " ":" mongodb11.kk.net:27017 "," maxbsonobjectsize ": 16777216," maxmessagesizebytes ": 48000000," maxwritebatchsize ": "LocalTime": Isodate ("2015-05-17t10:10:02.537z"), "Maxwireversion": 3, "minwireversion": 0, "OK": 1}

now remove the node "mongodb13.kk.net:27019" in primary:

Rs0:primary> rs.remove ("mongodb13.kk.net:27019") rs0:primary> rs.conf ()
[[email protected] ~]# Vi/etc/mongod.conf#replset=rs0[[email protected] ~]# service Mongod restart


The remaining 2 nodes after deletion are as follows:

192.168.1.11:27017 (primary)
192.168.1.12:27018 (secondary)


The service process was removed in 192.168.1.11:27017 (primary), and primary did not switch:

[Email protected] ~]# Ps-ef | grep mongmongod    4592     1  0 20:00?        00:00:02/usr/bin/mongod-f/etc/mongod.confroot      4648  2580  0 20:00 pts/0 00:00:00    MONGO Mongodb11.kk.net:27017root      4738  2618  0 20:06 pts/1    00:00:00 grep mong[[email protected] ~]# [[ Email protected] ~]# kill 4592

in 192.168.1.12:27018 (secondary), view the results as:

Rs0:secondary> Rs.status () {"Set": "Rs0", "date": Isodate ("2015-05-17t12:02:55.595z"), "MyState": 2, "members": [{"_ ID ": 0," "Name": "mongodb11.kk.net:27017", "Health": 0, "state": 8, "Statestr": "(not Reachable/healthy)", "uptime": 0, "op Time ": Timestamp (0, 0)," optimedate ": Isodate (" 1970-01-01t00:00:00z ")," Lastheartbeat ": Isodate (" 2015-05-17t12:0 2:53.655z ")," Lastheartbeatrecv ": Isodate (" 2015-05-17t12:02:28.462z ")," Pingms ": 0," lastheartbeatmessage ":" Failed Attempt to connect to mongodb11.kk.net:27017; Couldn ' t connect to server mongodb11.kk.net:27017 (192.168.1.11), connection attempt failed "," configversion ": -1},{" _id ': 1, ' name ': ' mongodb12.kk.net:27018 ', ' health ': 1, ' state ': 2, ' statestr ': ' Secondary ', ' uptime ': 726, ' optime ': timest AMP (1431860765, 1), "Optimedate": Isodate ("2015-05-17t11:06:05z"), "InfoMessage": "Could not find member-sync from", "C Onfigversion ": +," Self ": true}]," OK ": 1}

After starting the 192.168.1.11:27017 (primary) Mongod service, the discovery is automatically switched:

192.168.1.11:27017 (secondary)
192.168.1.12:27018 (primary)


Easy to test, change the primary back to the original:

192.168.1.11:27017 (primary)
192.168.1.12:27018 (secondary)


A quorum node will now be added: 192.168.1.13:27019


To create a data file directory:

[Email protected] ~]# Mkdir/var/lib/mongo/arbiter
[Email protected] ~]# chown Mongod:mongod/var/lib/mongo/arbiter


Configuration parameter file:

[Email protected] ~]# vi/etc/mongod.conf

pidfilepath=/var/run/mongodb/mongod.pidlogpath=/var/log/mongodb/mongod.logbind_ip=192.168.1.13dbpath=/var/lib/ Mongo/arbiterport=27019logappend=falsefork=truereplset=rs0


then restart the service:
[Email protected] ~]# service Mongod restart


Add the quorum node in 192.168.1.11:27017 (primary) and view the results:


Now, add to finish! ~


Test again to remove the service process in 192.168.1.11:27017 (primary):

[Email protected] ~]# Ps-ef | grep mongmongod    4771     1  0 20:08?        00:00:09/usr/bin/mongod-f/etc/mongod.confroot      4827  2580  0 20:08 pts/0 00:00:00    MONGO Mongodb11.kk.net:27017root      5255  2618  0 20:33 pts/1    00:00:00 grep mong[[email protected] ~]# kill 4771


to 192.168.1.12:27018 (secondary) view, primary switch to 192.168.1.12


primary can switch on and off normally! ~


Now look at arbiter, connected to 192.168.1.13:27019.

[Email protected] ~]# MONGO 192.168.1.13:27019

Rs0:arbiter> rs0:arbiter> Rs.slaveok ();rs0:arbiter> db.ismaster ()

Arbiter the most arbitrators, no copies of the data are stored locally and can read the information of the replica set.




Reference:

Replication Introduction

Replica Set Elections

Replica sets with four or more members

Add an arbiter to Replica Set



MongoDB Foundation (eight) Replication ⅱ-deployment Quorum node

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.