MongoDB Replica Set Setup

Source: Internet
Author: User
Tags install mongodb yum install mongodb

1/Installing MongoDB

Configuration repo:

[mongodb-org-3.4]
Name=mongodb Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
Gpgcheck=1
Enabled=1
Gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc

Then yum install Mongodb-org-y

Configuration/etc/mongod.conf:

Net
port:27017
bindip:192.168.88.5

Replication
Replsetname:teststrs

Then service Mongod start;

MONGO Ip:port, Executive:

cfg={_id: "Teststrs", members:[{_id:0,host: ' 192.168.88.4:27017 ', priority:1},
{_id:1,host: ' 192.168.88.4:27018 ', priority:2},
{_id:2,host: ' 192.168.88.5:27017 ', priority:3},
{_id:3,host: ' 192.168.88.5:27018 ', priority:4},

{_id:4,host: ' 192.168.88.5:27019 ', priority:5}] };


Rs.initiate (CFG)

Rs.status ()

Rs.conf ()

Note: Replica set when the number of hosts down in a cluster is greater than half of the cluster, it will not be able to be elected, at which time only the elections can be manually intervened:

Rs.reconfig (Cfg,{force:true})

MongoDB Replica Set Setup

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.