Mogodb Replica Cluster

Source: Internet
Author: User

First, the environment

centos6.5

node1:172.30.31.114

node2:172.30.31.115

node3:172.30.31.108

NODE4:172.30.31.109 arbitration Point

Second, installation

Four nodes are required to perform a

1. Install the Package

#yum install-y MongoDB Mongodb-server

#echo "This is key file" >/home/keyfile

#chown Mongodb/home/keyfile

#chmod 600/home/keyfile

#vim/etc/mongodb.conf

Port = 27017

Fork = True

Pidfilepath =/var/run/mongodb/mongodb.pid

LogPath =/var/log/mongodb/mongodb.log

DBPath =/var/lib/mongodb

Journal = True

Logappend = True

Replset = Mongotest

KeyFile =/home/keyfile

Auth = True

Oplogsize = 10000

#/etc/init.d/mongod start

#chkconfig Mongod on

Iii. Creating a replication set

Execute on 1node1

#mongo Admin

>db.runcommand ({"replsetinitiate": {"_id": "Mongotest", "members": [

{"_id": 1, "host": 172.30.31.114 "},

{"_id": 2, "host": 172.30.31.115 "},

{"_id": 3, "host": 172.30.31.108 "}

]}})

>{"info": "Config now saved locally. Should come online in about a minute. "," OK ": 1}

>exit

#mongo Admin

Mongotest:primary>use Admin

Mongotest:primary>db.adduser ("root", "MongoDB")

Create a management account, at which point the NODE2,NODE3 Use this account password. Even if the management account used by NODE2,NODE3 is different, it will be overwritten for this

Iv. Adding the quorum node

1 executing on the master node

Mongotest:primary>rs.addarb ("172.30.31.109:27017")

Mongotest:primary>rs.status () #查看集群状态

Note the secondary node does not have Read permission by default, and execution Rs.slaveok () can be turned on. The quorum node only participates in voting and does not participate in synchronizing the data.






This article is from the "Bremen Band" blog, declined reprint!

Mogodb Replica Cluster

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.