Skip to content

📦 Vagrant setup with MongoDB 3-nodes cluster with replica set

Notifications You must be signed in to change notification settings

danlucian/vagrant-mongodb-cluster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bt-mongodb-cluster

Vagrant Box (CentOS/7) with MongoDB(v3.4) 3-nodes cluster including a replica set.

mongodb replica

Start vagrant and setup replica set

Run in terminal: vagrant up

Connect to main box (mongo1) via ssh: vagrant ssh mongo1

Run the setup script for replica set:

    cd /vagrant/
    sudo sh ./setup.sh

Information about port-forwarding

    mongo1.vm.network "forwarded_port", guest: 27017, host: 27017
    mongo2.vm.network "forwarded_port", guest: 27017, host: 27018
    mongo3.vm.network "forwarded_port", guest: 27017, host: 27019

So you are able to connect to the mongo servers from the host via: 127.0.0.1:27017 for mongo1, 127.0.0.1:27018 for mongo2 and so on.

MongoDB configuration

    config = { _id: "mongo-replica-set", members:[
           { _id : 0, host : "192.168.22.10:27017"},
           { _id : 1, host : "192.168.22.20:27017"},
           { _id : 2, host : "192.168.22.30:27017"} ]
    };

Releases

No releases published

Packages

No packages published

Languages