MongoDB Replication set: Installing Deployment

Source: Internet
Author: User
Tags mkdir mongodb
 preparatory work

Software Environment

Os:oracle Linux 6.5

mongodb:mongodb3.2.3

Deploy schema

Analog has three servers

10.1.5.123:28001 Master Node

10.1.5.123:28002 from Node

10.1.5.123:28003 election node

Replica set Schema: one master, one from, one election node

Download Installation

Download Address: Https://www.mongodb.org/downloads

Mongodb-linux-x86_64-rhel62-3.2.3.tgz

Deployment Steps 1. Create Directories and Users

[Root@devtest mongodb]# mkdir conf data log

[Root@devtest data]# mkdir 28001 28002 28003

--Create MONGO user

[Root@devtest conf]# Groupadd Mongod

[Root@devtest conf]# useradd-g Mongod Mongod

2. Create a configuration file

--Configure three instance configuration files (modify the corresponding port number)

--Node 1

$ vi/home/mongod/mongodb3.2.3/conf/28001.conf

port=28001

Bind_ip=10.1.5.123

Logpath=/home/mongod/mongodb3.2.3/log/28001.log

dbpath=/home/mongod/mongodb3.2.3/data/28001/

Logappend=true

Pidfilepath=/home/mongod/mongodb3.2.3/data/28001/28001.pid

Fork=true

oplogsize=1024

Replset=mymongo

--Node 2

$ vi/home/mongod/mongodb3.2.3/conf/28002.conf

port=28002

Bind_ip=10.1.5.123

Logpath=/home/mongod/mongodb3.2.3/log/28002.log

dbpath=/home/mongod/mongodb3.2.3/data/28002/

Logappend=true

Pidfilepath=/home/mongod/mongodb3.2.3/data/28002/28002.pid

Fork=true

oplogsize=1024

Replset=mymongo

--Node 3

$ vi/home/mongod/mongodb3.2.3/conf/28003.conf

port=28003

Bind_ip=10.1.5.123

Logpath=/home/mongod/mongodb3.2.3/log/28003.log

dbpath=/home/mongod/mongodb3.2.3/data/28003/

Logappend=true

Pidfilepath=/home/mongod/mongodb3.2.3/data/28003/28003.pid

Fork=true

oplogsize=1024

Replset=mymongo

3. Start MONGO replication set

$ mongod-f/home/mongod/mongodb3.2.3/conf/28001.conf

$ mongod-f/home/mongod/mongodb3.2.3/conf/28002.conf

$ mongod-f/home/mongod/mongodb3.2.3/conf/28003.conf

4. Initializing the replica set

[Mongod@devtest ~]$ MONGO 10.1.5.123:28001/admin

MongoDB Shell version:3.2.3

Connecting To:10.1.5.123:28001/admin

Welcome to the MongoDB shell.

For interactive help, type ' help '.

For more comprehensive documentation

http://docs.mongodb.org/

Questions? Try the Support group

Http://groups.google.com/group/mongodb-user

> DB

Admin

> config = {

... "_id": "Mymongo",

... members:[

... {"_id": 0,host: "10.1.5.123:28001"},

... {"_id": 1,host: "10.1.5.123:28002"},

... {"_id": 2,host: "10.1.5.123:28003"}]

... }

{

"id": "Mymongo",

"Members": [

{

"_id": 0,

"Host": "10.1.5.123:28001"

},

{

"_id": 1,

"Host": "10.1.5.123:28002"

},

{

"_id": 2,

"Host": "10.1.5.123:28003"

}

]

}

--View Replica set members

> config.members

[

{

"_id": 0,

"Host": "10.1.5.123:28001"

},

{

"_id": 1,

"Host": "10.1.5.123:28002"

},

{

&nb

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.