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