8.MongoDB DBA Tutorials: MongoDB Replication Setup on Windows

preview_player
Показать описание
#MongoDB, #Replication #MongoDB Replication
In this video, we will see how to setup MongoDB replication on Windows environment. In this video, we have setup replication on three member servers. We can perform read and write operations only on Primary replica server. On secondary servers, read only operations performed. If we try others, then MongoDB will through error.

Actions performed on Primary Server.
rsconf={_id:r2schools,members:[{_id:0,host:"localhost:27017"}]}
rs,status()
On Secondary Servers run below commands
rs,status()

MongoDB Tutorials
How to setup MongoDB Replication on windows
MongoDB Replication Setup
Setup MongoDB Replication on windows
MongoDB Replication Setup on Windows
Step by Step MongoDB Replication Setup on Windows
Step by Step MongoDB Replication Setup
How to configure MongoDB Replication on Windows
MongoDB Replication Tutorial
MongoDB Tutorial for beginners
MongoDB Tutorial
MongoDB Replication
Рекомендации по теме
Комментарии
Автор

I just want to say thank you. Before watched your tutorial, i spent hours reading and watching other tutorial on google and youtube . but all of them didn't work. Now it works like a charm. Thanks

phamcuong
Автор

This is my understanding:

1. Define the mongodb path
and start the instances. This is non-daemon :

mongod --dbpath "C:\Program --logpath "C:\Program --port 27017 --storageEngine=wiredTiger --journal --replSet r2schools

mongod --dbpath "C:\data\data1\db" --logpath --port 27020 --storageEngine=wiredTiger --journal --replSet r2schools

mongod --dbpath "C:\data\data2\db" --logpath --port 27021 --storageEngine=wiredTiger --journal --replSet r2schools


2. Connect to the primary port through a terminal
:

mongod --port 27017
rsconf={_id:'r2schools', members:[{_id:0, host:"localhost:27017"}]}
rs.initiate(rsconf)

3. Connect to the secondary ports through two terminals :

mongod --port 27020
mongod --port 27020

4. From the Primary daemon port (step Number 2), add the local hosts of the secondary ports:

rs.add("localhost:27020")
rs.add("localhost:27020")

5. From the secondary daemon terminals (step Number 3), initiate them as slaves:

rs.slaveOk()

# For validation do rs.status() and rs.isMaster() to check whether the conversion took place correctly.

# Bonus.
6. Drop a Replica Set. Here I am dropping the Primary -> localhost:27017. From the daemon terminal of the primary type:

use admin;
db.shutdownServer() ;

Check within a minute, either localhost:27020 or localhost:27021 have become the primary by doing rs.isMaster() through their respective daemon terminal.

7. To once again pull back the localhost:27017 into the replica set, repeat step Number 1 and later do -> mongod --port 27017

tupaiadhikari
Автор

I will say it was excellent video I was able to create replication server now I can run commands to test for Mongo certification 👌👍

AnilKumar-lbqf
Автор

best video on replica, so far...thanks !!

dikshanain
Автор

Superb video .... Precise and on point ....thank you so much ! 👍

ihsaashi
Автор

Oh man, you're awesome! You just saved my school project! Thanks

ramboinside
Автор

You're a live saver, very useful video! Much love!

jason_m
Автор

Thank you for the clear explanation. It’s very helpful.

satyanarayanae
Автор

Sir, it was an good explanation but how to delete/remove our created ones replica set, for the next time new execution

lightningakash
Автор

great, thank you !
How about activating replica sets using dbs on Atlas and Compass?

mista_ia
Автор

Thanku so much sir....its really really helpful....its working for me

sumedhasaran
Автор

Thankyou so much for sharing your valuable knowledge. Subscribed and liked !!!

sureshkhatri
Автор

A very good tutorial. You are the best man!!!

adekunleadeyemo
Автор

Hey can you pls post the more videos on Linux offline installation using tar file.. mongoDB sharding and mongoDB.conf details, performance tuning etc...

ganeshbb
Автор

Very useful information and good teaching. Thank You so much

chandraiyer
Автор

I have a doubt, when these steps are done they must be in the main server console or in the secondary server console?

I am new and I would like to know this in detail.

4. Start the secondary server on port 27017.

mongod --dbpath "C:\SecondaryReplication1\db" --logpath --port 27017 --storageEngine=wiredTiger --journal --replSet servrep1

5. Log in to the secondary server.

mongo --port 27017

AlejandrxHdz
Автор

my db 27017 in is changed to secondary and its staus is stateStr: '(not reachable/healthy)',
how to change 27017 as primary or tell me how to delete the replicaset and create new set

ajaybalu
Автор

I have setup the replication and it's working fine but I also wanted to know how the failover and sync will work if the connection get lost

sandipchaudhary
Автор

Can you please help with Replication Across the server.

sandipchaudhary
Автор

I am trying to replicate from ServerA to ServerB with the same server it worked as per the instructions provided, when i am trying to initiate replication to server B it throws an error "Failed to set up listener : SocketException : the requested address is not valid in its context my config file is


bind_id=serverB ip adress
port=27017
command line is
mongod -- path "D:\MongoDB\rs01\db" --logpath serverB --port 27017 --stirageEngine=wiredRiger --journal --replset

narsinggoud