Тёмный

[ MongoDB 6 ] How to Deploy a MongoDB ReplicaSet 

Just me and Opensource
Подписаться 66 тыс.
Просмотров 59 тыс.
50% 1

Опубликовано:

 

29 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 227   
@rsrini7
@rsrini7 4 года назад
Addicted to Venket's Videos... Slideless practical way of teaching. Thank you.
@justmeandopensource
@justmeandopensource 4 года назад
Hi Srini, thats great to hear and many thanks for watching. Cheers.
@lorenzomagnus2183
@lorenzomagnus2183 3 года назад
Dont know if anyone gives a damn but if you guys are stoned like me atm then you can watch pretty much all of the new series on instaflixxer. Have been binge watching with my brother for the last few days =)
@nelsonsamir3611
@nelsonsamir3611 3 года назад
@Lorenzo Magnus definitely, been watching on InstaFlixxer for years myself =)
@timothyari9528
@timothyari9528 3 года назад
@Lorenzo Magnus Definitely, have been watching on instaflixxer for since december myself :)
@jrosimo098
@jrosimo098 Год назад
I just found this video, i couldve saved hours from the things i did which is only 12 minutes in this videos creating a replica set with 3 instances of mongdb. Wow! im gonna watch the whole series now. Thank you so much!
@justmeandopensource
@justmeandopensource Год назад
Hi Jeff, glad to hear that. Thanks for watching.
@josuedegbun6270
@josuedegbun6270 11 месяцев назад
the greatest video about MongoDB i ever watch
@justmeandopensource
@justmeandopensource 11 месяцев назад
Thanks for watching.
@achyuthvishwamithra
@achyuthvishwamithra 2 года назад
Great job Venkat, this is really helpful!
@justmeandopensource
@justmeandopensource 2 года назад
Hi Achyuth, thanks for watching.
@xuantungtrinh5584
@xuantungtrinh5584 3 года назад
Great demonstration. Thank you for the video!
@justmeandopensource
@justmeandopensource 3 года назад
Hi Xuan, Thanks for watching.
@nikhilrajan2370
@nikhilrajan2370 4 года назад
what would be connecting string if we wanted to connect to this same replica set using the mongsqld commands i used './mongosqld --mongo-uri "mongodb://mongo-0.mongo:27017,mongo-1.mongo:27017,mongo-2.mongo:27017/?replicaSet=rs0&readPreference=secondary"' and i am getting the error current topology: Type: ReplicaSetNoPrimary, unable to discover
@VenkateshMogili
@VenkateshMogili 3 года назад
Thank you bro, got the clear idea on mongodb replica set.👍
@justmeandopensource
@justmeandopensource 3 года назад
Hi Venkatesh, thanks for watching.
@jaypdevaney
@jaypdevaney 2 года назад
I love your videos. Great quality work and very useful and practical. Thanks!
@justmeandopensource
@justmeandopensource 2 года назад
Hi Jay, thanks for watching.
@leonardoanez217
@leonardoanez217 4 года назад
As always - phenomenal video Venkat!! You're the best buddy :)
@justmeandopensource
@justmeandopensource 4 года назад
Hi Leonardo, many thanks for your comment.
@ernestledo341
@ernestledo341 4 года назад
you are such a blessing. Keep up the good work Venkat
@justmeandopensource
@justmeandopensource 4 года назад
Hi Ernest, many thanks for watching this video and taking time to comment/appreciate. Cheers.
@ernestledo341
@ernestledo341 4 года назад
The appreciation is yours Venkat for the great work you are doing to share knowledge.
@justmeandopensource
@justmeandopensource 4 года назад
@@ernestledo341 Kind of you. Thanks.
@WyeOakMobileDeviceRepairEaston
@WyeOakMobileDeviceRepairEaston 4 года назад
Excellent video. Very in depth.
@justmeandopensource
@justmeandopensource 4 года назад
Thanks for watching.
@mackynikat8833
@mackynikat8833 3 года назад
. bos i subscribed to your channel , now already had another one to depend at times like this . got ur back
@justmeandopensource
@justmeandopensource 3 года назад
Thanks for watching and subscribing. Cheers.
@mackynikat8833
@mackynikat8833 3 года назад
@@justmeandopensource . hahaha . your so much , just let me thank you for my sub, like and support :DD
@justmeandopensource
@justmeandopensource 3 года назад
@@mackynikat8833 :)
@mackynikat8833
@mackynikat8833 3 года назад
@@justmeandopensource ^^_
@mackynikat8833
@mackynikat8833 3 года назад
. forgot about it boss , do you a video about what is a seed list in mongodb ? can u send me the link ?
@rommeldavid9972
@rommeldavid9972 4 года назад
Nice series bro. I've learned and enjoying a lot. Keep it up! New subscriber here!
@justmeandopensource
@justmeandopensource 4 года назад
Hi Rommel, many thanks for watching and subscribing. Cheers.
@sreekanthadari1
@sreekanthadari1 3 года назад
Wonderful, appriciate the efforts to help
@justmeandopensource
@justmeandopensource 3 года назад
Thanks for watching.
@manojkumar-py3fu
@manojkumar-py3fu 4 года назад
Great explanation .
@justmeandopensource
@justmeandopensource 4 года назад
Hi Manoj, thanks for watching.
@mostaphaghribi7512
@mostaphaghribi7512 2 года назад
thankkkkkkkkssss you are literally a life saver
@justmeandopensource
@justmeandopensource 2 года назад
Thanks for watching.
@satyabratakhatua2391
@satyabratakhatua2391 4 года назад
Very good video for beginners . The demo is excellent
@oleksandrsavinkov8635
@oleksandrsavinkov8635 4 года назад
Very helpful video. Thanks!
@justmeandopensource
@justmeandopensource 4 года назад
Hi Oleksandr, thanks for watching.
@burakkartal6666
@burakkartal6666 3 года назад
This is gold. Thank you..
@justmeandopensource
@justmeandopensource 3 года назад
Hi Burak, thanks for watching. Cheers.
@vipinkoul595
@vipinkoul595 3 года назад
Awesome!
@justmeandopensource
@justmeandopensource 3 года назад
Thanks for watching. Cheers.
@djosefandersson7605
@djosefandersson7605 3 года назад
thanks , really clever explanation!
@justmeandopensource
@justmeandopensource 3 года назад
Hi Djosef, thanks for watching.
@vuat1494
@vuat1494 Год назад
Hey Bro You forgot an experiment in this Lab mongodb replica set with 3 Nodes will be very good but if 1 of 3 Nodes die then there is no problem. But if 2 out of 3 nodes, an even number, die, you know the consequences. Without a Primary Node, what will you do now? And the next thing is that the Primary's job is divided among the Slave Nodes. But the main responsibility is still the Primary Node. Suppose at some point your Primary Node is Full Disk and your system resources cannot be scaled vertically, what do you plan to do with your MongoDB Cluster?. Please give me your answer as soon as possible. Thanks!!!
@sambasiva1702
@sambasiva1702 Год назад
Excellent..do you have any video to show cross region replication for mongodb 3 pods?
@justmeandopensource
@justmeandopensource Год назад
I am afraid not. THanks for watching.
@david_cuna_tuna
@david_cuna_tuna 4 года назад
Thanks for the video Venkat. But something wrong when i have connect to replica Sets like this: "client = MongoClient("mongodb://mongodb0:27017,mongodb1:27017,mongodb2:27017/?replicaSet=rs0")" and error below: "ServerSelectionTimeoutError errno 11001 getaddrinfo failed python" seem the Primary did not connect to Secondary for reading data. Could you help?
@DunSety
@DunSety 3 года назад
Thank you from Russia))
@justmeandopensource
@justmeandopensource 3 года назад
Many thanks for watching.
@snv94
@snv94 3 года назад
Why I got "writeConcern is not allowed within a multi-statement transaction" when trying the "multi-document transaction". I ran in on primary node. Please help!
@nimaiahluwalia5678
@nimaiahluwalia5678 3 года назад
Hello, I had a question that can we set up sync or replication between my on-prem MongoDB server and my azure VM MongoDB server.
@justmeandopensource
@justmeandopensource 3 года назад
Hi Nirmal, thanks for watching. You can do that. In fact you can set up a replicaset with nodes running anywhere. But you have to bear in mind the latency and other stuff. To be able to setup a replicaset, all you need is mongo instances running. It can run anywhere. You have to take into account firewall, latency and security. If the nodes can talk to each other on port 27017, then you can hook them up.
@nimaiahluwalia5678
@nimaiahluwalia5678 3 года назад
@@justmeandopensource Thank you very much for your response.
@justmeandopensource
@justmeandopensource 3 года назад
@@nimaiahluwalia5678 You are welcome.
@trijit96
@trijit96 4 года назад
Do you recommed to run mongodb node vms in replica set to close proximities to each other when deploying vm in public cloud?
@justmeandopensource
@justmeandopensource 4 года назад
Hi thanks for watching. I would run them each in its own availability zone.
@NamanJain-wo9zp
@NamanJain-wo9zp Год назад
At 10:46 when you execute the cat command, I cannot see the IP Address of my 3 mongodb's, and all my 3 machines are running, can you tell how can I add this data?
@sushilmaurya6260
@sushilmaurya6260 4 года назад
VERI NICE STUFF ,TNKS SIR.
@justmeandopensource
@justmeandopensource 4 года назад
Hi Sushil, thanks for watching. Cheers.
@jameswongleongyew6098
@jameswongleongyew6098 2 года назад
Hi, using the local server with three instances without issue, but if have three separate servers, facing node not found error. Are you able to advice? Thank you.
@richardwang3438
@richardwang3438 4 года назад
real nice stuff, thanks
@justmeandopensource
@justmeandopensource 4 года назад
Thanks for watching Richard.
@david19993
@david19993 4 года назад
Great video, quick question. I used docker and not lxc. If i put all three "mongoDb servers" on three dockers, it works fine. If I use two dockers, and my local machine, it does not work and it says network is unreachable. Any idea why this might be the case? I've exposed ports, and mapped them correct `docker run -p 27017:27017` A bit confused as to why the dockers can interact with each other, but my host machine cannot interact with any of the containers?
@justmeandopensource
@justmeandopensource 4 года назад
At what point it says network is unreachable? During rs.initiate() stage?
@david19993
@david19993 4 года назад
@@justmeandopensource yes! rs.initiate() doesn't work. Then I put my "host machine mongoDb" on to a docker as well, and works with 3 dockers beautifully.
@justmeandopensource
@justmeandopensource 4 года назад
@@david19993 Are you defining a separate network for your docker containers in your docker-compose file? I haven't actually tried that setup to be honest.
@david19993
@david19993 4 года назад
@@justmeandopensource well, my dockers have `172.17.0.*` as IPs, and so I just use my host machines IP address. It may be something to do with my firewall. Anyway, this is not a question about mongoDb but more docker. Thanks for the video, the response, and just being a great experience! Subscribed!
@justmeandopensource
@justmeandopensource 4 года назад
@@david19993 Thanks for subscribing. Much appreciated.
@GurdeepSabarwal
@GurdeepSabarwal 5 лет назад
nice video venkat..keep doing!.
@justmeandopensource
@justmeandopensource 5 лет назад
Thanks for watching this video Gurdeep.
@deepakshah4037
@deepakshah4037 2 года назад
very nice video
@justmeandopensource
@justmeandopensource 2 года назад
Hi , Thanks for watching.
@rajeshkunda6704
@rajeshkunda6704 4 года назад
Hi Venkat, these mongodb series are very very useful and clearly explained many things. Can you please make some videos on Mysql DB. Thanks.
@davidb.3266
@davidb.3266 3 года назад
Thank you so much
@justmeandopensource
@justmeandopensource 3 года назад
Thanks for watching David.
@atruismoti2402
@atruismoti2402 2 года назад
Awesome Thank's
@justmeandopensource
@justmeandopensource 2 года назад
Thanks for watching.
@azadpoursadegh9761
@azadpoursadegh9761 3 года назад
awesome thanks.
@justmeandopensource
@justmeandopensource 3 года назад
You are welcome.
@varun898
@varun898 4 года назад
I have to execute rs.slaveOk() everytime on the secondary nodes to read databases. How can I avoid executing this everytime when connecting to the secondary.
@justmeandopensource
@justmeandopensource 4 года назад
Hi Varun, I don't think there is a way to set the rs.slaveOk() in a permanent way. rs.slaveOk() is set per connection session. This is needed only when you are directly connecting to a secondary member of the replicaset. Why do you want to connect directly to a secondary member. You can still connect to the full replicaset and direct the reads to secondary members by passing readPreference option in the connection string. For example, if your replicaset name is myrepl and your hosts are mongo-0, mongo-1 & mongo-2, then you can use below connection string. $ mongo mongodb://mongo-0:27017,mongo-1:27017,mongo-2:27017/admin?replicaSet=myrepl&readPreference=secondary This will do any reads from secondary and writes will happen on primary. Cheers.
@david19993
@david19993 4 года назад
lets say I make some changes in primary (create database test-db, and db.tester.insert() some values) Without doing rs.slaveOk() how can I simply view the changes in secondary? So when I update primary, I don't want to update the values. But how can I do a .find() in my secondary servers without explicitly entering `rs.slaveOk()`?
@justmeandopensource
@justmeandopensource 4 года назад
@@david19993 The replica set will take care of the replication between its members. May I ask you why you want to connect directly to a secondary member? If you want to directly connect to a secondary member, then there is no way other than running rs.slaveOk() to interact with the database.
@mdellertson
@mdellertson 3 года назад
Great video thanks for sharing! Do you need to have a minimum of three servers to configure a replica set? Or can I set one up with only two?
@justmeandopensource
@justmeandopensource 3 года назад
Hi Mike, thanks for watching. Minimum would be a 3 node replicaset.
@mdellertson
@mdellertson 3 года назад
@@justmeandopensource Good to know.
@justmeandopensource
@justmeandopensource 3 года назад
No worries.
@mks2443
@mks2443 2 года назад
Is there any gui tool to setup replication rather than running through manual procedures?
@cpastesfrite4708
@cpastesfrite4708 4 года назад
nice Vidéo very helpfull
@justmeandopensource
@justmeandopensource 4 года назад
Hi, thanks for watching.
@nikolabozic3918
@nikolabozic3918 3 года назад
Thanks for very helpful video. I have one confusion When you connected to first mongo instance and did rs.initiate() In mongo prompt appears that is secondary but after you rs.status() it shows that node is primary?
@skkummetha
@skkummetha 3 года назад
Hi Venkat, Thanks for nice video. I did mongodb replica set by seeing your vidoe, however noticed secondary node asks to run rs.slaveOk() command before run any command when i connects to its(secondary node) mongo shell. Could you please let me know is this expected beheaviour.
@justmeandopensource
@justmeandopensource 3 года назад
Hi Sunil, thats expected when you connect directly to a secondary node instead of a replica set connection uri.
@kingsite8328
@kingsite8328 3 года назад
Do we have to install docker on each machine (mongodb0...)
@1487atul
@1487atul 3 года назад
what is the difference between rs.initiate() vs rs.initiate( { _id : "rs0", members: [ { _id: 0, host: "localhost:27017" }, { _id: 1, host: "localhost:27018" }, { _id: 2, host: "localhost:27019" } ] }) what is the condition of both cases.
@justmeandopensource
@justmeandopensource 3 года назад
Hi Atul, thanks for watching. rs.initiate() requires replicaset configuration. You either add the configuration beforehand and run rs.initiate() or pass the replicaset configuration within this method.
@johnkennedy6888
@johnkennedy6888 5 лет назад
wonderful
@justmeandopensource
@justmeandopensource 5 лет назад
Hi John, thanks for watching this video.
@varun898
@varun898 4 года назад
Is there anyway of doing a multi master set-up in mongodb like mysql. I have a multi-cloud replica setup on digitalocean and linode where my primary is on digitalocean . I would like to have one-more master on linode so that in case the communication is cut between the two environments I would still want my application on linode to perform write operations.
@justmeandopensource
@justmeandopensource 4 года назад
HI Varun, thanks for watching. The master node in MongoDB cluster is called Primary. No master/slave concept. It is Primary/Secondary. By design, you can't have two primaries in a cluster. What you can do is spread your replicaset across different providers DO and Linode. If one of the provider has problem, then a secondary from another provider can take the primary role.
@abhimanyukumar4185
@abhimanyukumar4185 4 года назад
can we just have one primary and one secondary when doing a replica? if not why? and why its necessary to have three.
@justmeandopensource
@justmeandopensource 4 года назад
Hi Abhimanyu, thanks for watching. Not just Mongodb cluster, generally in any cluster you will have odd number of nodes. In mongodb replicaset, the minimum nodes recommended is 3. You can however run just two nodes with one primary and one secondary. As long as the master node is running fine, you won't see any problem. But if master dies, the only secondary node will have to take the primary role but it might not have catched up with the master. So loss of data might happen. If there are two secondaries, there will be election to find out which can become the primary.
@revellipraveen6902
@revellipraveen6902 3 года назад
Hi venkat I am from India..the explanation was really great but I have one doubt: I have converted my standalone to replica sets in windows lastday but today after restarting my system 1.I am unable to Rerun my replica sets(getting this error: connect failed to replica set myReplicaSet/localhost:27017,localhost:27027,localhost:27037). 2.when I run my primary node(27017)..it is telling me that " "errmsg" : "This node was not started with the replSet option" when i typed rs.status() and also giving throwing as "Document(s) exist in 'system.replset', but started without --replSet." PLEASE HELP ME VENKAT
@justmeandopensource
@justmeandopensource 3 года назад
Hi, when you say you converted standalone to replicaset, how exactly you did it?
@revellipraveen6902
@revellipraveen6902 3 года назад
@@justmeandopensource When I installed MongoDb in Windows it showed showed as Standalone cluster(mongo compass UI) hosted with port number: 27017 then..in shell I used the below command to make it as replica set. mongod --dbpath "C:\Program Files\MongoDB\Server\4.4\data" --logpath "C:\Program Files\MongoDB\Server\4.4\log\mongod.log" --port 27017 --storageEngine=wiredTiger --journal --replSet myReplicaSet
@yuomtheara
@yuomtheara 5 лет назад
Dear, How to use/set `/etc/hosts` for difference ip? Does you do this on your local machine? 10.92.25.103 mongo0 10.92.250.227 mongo1 10.92.250.62 mongo2 What difference with 3 docker container in difference port? ports: - 40001:27017 ports: - 40002:27017 ports: - 40003:27017
@justmeandopensource
@justmeandopensource 5 лет назад
Hi Theara, Thanks for watching this video. Are you running these three mongodb containers on the same machine or on a separate virtual machines? If you want to run all 3 mongo containers on the same machine using docker-compose, you need to map them to different ports on your host machine. If you are running each of the mongo containers in its own virtual machine, then you can just run them on 27017 the default port. Thanks.
@yuomtheara
@yuomtheara 5 лет назад
​@@justmeandopensource Thanks, Very clear
@yuomtheara
@yuomtheara 5 лет назад
@@justmeandopensource Excuse me, I have some issue on your github repo. Could you check?
@justmeandopensource
@justmeandopensource 5 лет назад
Hi Theara, I just responded to the github issue. Please use this RU-vid chat section for all your queries. This will help other viewers as well. Thanks.
@giovanni.piedimonte
@giovanni.piedimonte 2 года назад
Hi very good tutorial thanks. A question how to enable authentication into a replicaset? Only on primary and how using a docker? Thanks.
@justmeandopensource
@justmeandopensource 2 года назад
Hi, thanks for watching. This below video will give you some idea. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-SY_9zwb29LA.html Basically you bring up a replicaset with authentication enabled on all nodes either through a config file or through a command line option "--auth" and then set up users/roles on primary which will get replicated.
@giovanni.piedimonte
@giovanni.piedimonte 2 года назад
@@justmeandopensource Amazing thanks :)
@justmeandopensource
@justmeandopensource 2 года назад
@@giovanni.piedimonte No worries.
@milonhossain4554
@milonhossain4554 3 года назад
Thanks a lot!
@justmeandopensource
@justmeandopensource 3 года назад
Hi Milon, thanks for watching.
@1487atul
@1487atul 3 года назад
hi Sir, I am getting some different message of the command rs.status() rs.status() { "ok" : 0, "errmsg" : "not running with --replSet", "code" : 76, "codeName" : "NoReplicationEnabled" } What is the meaning of this ?
@justmeandopensource
@justmeandopensource 3 года назад
Please follow my steps carefully.
@abhimanyukumar4185
@abhimanyukumar4185 4 года назад
Hello.....I am back again with one question... So, I deployed a replica set of MongoDB and I have three machines (Mongo1:127.0.0.1(Primary), Mongo2:127.0.0.2(sec), Mongo3:127.0.0.3(sec)). Now we know if the mongo1(primary) will die then one of the secondary will be primary and when it will b back it will be one of the secondary nodes. Suppose I am using the mongo1 IP in all my scripts and application which is 127.0.0.1 and as we know all read and write are on primary so suppose if it will die then I have to go and change the primary IP in all my script. How I can handle this problem.
@justmeandopensource
@justmeandopensource 4 года назад
Hi Abhi, thanks for watching. Whenever you are connecting to a replicaset from a mongo shell or from any client application, you will have to use the replicaset uri and not the ip address of a single mongo node. In your case, you will have to replicaset uri like "mongodb://mongo1:27017,mongo2:27017,mongo3:27017/database?replicaSet=replicaset-name". By using this URI format, the connection will be made to any available mongo node in the cluster. Cheers.
@abhimanyukumar4185
@abhimanyukumar4185 4 года назад
@@justmeandopensource one last question Does this provide it the order to failover with?
@justmeandopensource
@justmeandopensource 4 года назад
@@abhimanyukumar4185 By using that connection string, it will connect to any available instance in the replicaset. In a replicaset if the master node goes down, one of the secondaries will become the primary. You will have to implement some form of monitoring to get alerted when a node goes down and bring it as soon as possible.
@abhimanyukumar4185
@abhimanyukumar4185 4 года назад
@@justmeandopensource I got that. Suppose mongo1 is master and it goes down and mongo3 will be next master so it will go to that one. If i am getting it right.
@justmeandopensource
@justmeandopensource 4 года назад
@@abhimanyukumar4185 Yeah one of the other secondary will become master by holding an election.
@Dieudonne64796
@Dieudonne64796 3 года назад
thank you for this very explanatory tutorial. I have a question: can we just use 2 machines for replication or 3 machines is the minimum? I can't find anything about it in the documentation Thanks.
@justmeandopensource
@justmeandopensource 3 года назад
Hi Chatti, thanks for watching. I would always advise to go with a minimum of 3 node replicaset with all of them containing the data. If a node goes down, then you will only be left with one node if you had just 2 node replicaset. If you don't want to replicate the data on 3 nodes, you can just have 2 nodes that contains data and an arbiter node that only takes part in election and doesn't hold the actual data. docs.mongodb.com/manual/core/replica-set-architecture-three-members/
@haraldhacker
@haraldhacker 2 года назад
17:39 show dbs run into an error. now it works. Ok bro nice but what have you changed, I'm having the same issue.. thanks
@aponiartest2802
@aponiartest2802 4 года назад
Hi Venkat, can you provide me a link for how to create lxc container, which you have shown in this video.
@justmeandopensource
@justmeandopensource 4 года назад
Hi, thanks for watching. I have a separate series covering LXC/LXD concepts. If you are interested. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-CWmkSj_B-wo.html
@aponiartest2802
@aponiartest2802 4 года назад
@@justmeandopensource it's getting error when I give cmd lxc launch ubuntu:16.04
@justmeandopensource
@justmeandopensource 4 года назад
@@aponiartest2802 What error do you get?
@aponiartest2802
@aponiartest2802 4 года назад
@@justmeandopensource Error: Failed container creation: Create LXC container: LXD doesn't have a uid/gid allocation. In this mode, only privileged containers are supported
@sameermohd2687
@sameermohd2687 5 лет назад
very nice explanation...can you make videos on cassandra
@justmeandopensource
@justmeandopensource 5 лет назад
Hi Sameer, thanks for watching this video. I don't know much about Cassandra. At the moment, I am focusing on Kubernetes and AWS series. Cheers.
@josephuzuegbu7431
@josephuzuegbu7431 Год назад
Nice video. @Just me and Opensource can you show how you set-up docker
@kayoutube690
@kayoutube690 4 года назад
Hello, how to create read replicas in mongodb in AWS?
@justmeandopensource
@justmeandopensource 4 года назад
Hi James, What do you mean by read replicas? You can just add additional secondary members to your replicaset if your read traffic is increasing. All your reads will happen on secondary members when you pass the "readPreference=secondary" to the mongodb connection string when connecting. Cheers.
@pmg83
@pmg83 Год назад
There does not seem to be mongo services deployed on docker swarm , just separate mongodb containers on different hosts. Mapping in /etc/hosts also seems counter productive , because it implies you always want mongo0 on hostA , mongo1 on hostB and mongo2 on hostC. That is not how services deployed on docker swarm work - mongo0 , mongo1 and mongo2 as services could be deployed randomly on hostA or hostB or hostC.
@MrKiraBR
@MrKiraBR 4 года назад
THANK YOOOOU!
@justmeandopensource
@justmeandopensource 4 года назад
No worries. You are welcome.
@RAJESHNAYAK-wg5li
@RAJESHNAYAK-wg5li 5 лет назад
Hey hi, thanks for the such a great video. I have question, i have 3 slave and 1 master node mongodb replicaset in kubenates. I used the replicaset name to connect inside the cluster as you shown in video. Now i want to connect outside the cluster, how can i do that. Thank in advance.
@justmeandopensource
@justmeandopensource 5 лет назад
Hi Rajesh, thanks for watching this video. I actually have this in my list. The video will be about deploying mongodb as a statefulset inside a Kubernetes cluster. Only if you are deploying mongodb replicaset outside the k8s cluster you will have to think about traditional architecture and accessing the replicaset uri, by passing all the replicas in the uri. Whereas if you are deploying inside a kubernetes cluster, you can just deploy them as a normal kubernetes replicaset. And expose the deployment as a LoadBalancer or nodeport service. I haven't tried any of these. But will soon record a video for it. Thanks.
@RAJESHNAYAK-wg5li
@RAJESHNAYAK-wg5li 5 лет назад
Thanks for your reply, When i exposed as LoadBlaancer or Node Port, it will switch b/w primary and secondary(works in round robbin .).My question is how can handle in the application. Should i use Drivers or any think else. Please helm me here. Thanks in advance.
@justmeandopensource
@justmeandopensource 5 лет назад
@@RAJESHNAYAK-wg5li You don't deploy them as a mongodb replicaset with primary and secondary inside the cluster. Its like any other deployment with number of replicas. So all of them are same and no primary/secondary concept. Thanks.
@etiennedaher
@etiennedaher 4 года назад
Thank you so much for this tutorial. It's great! I have a problem, it would be great if you can help! (i've searched a lot online, but no luck) i did the exact replicaset over 2 servers: Server A in docker: db1, db2 & Server B in docker: db3 if db1 was primary & i stop the container db1, db2=> will be set to primary, and everything will keep on working fine same story for db2 however if i stop db1 and db2 (or if i shutdown the whole server of db1 and db2), db3 is staying forever secondary! any idea?
@yuomtheara
@yuomtheara 5 лет назад
Could we create Mongos Router/Mongos with 2, 3.. nodes like ReplicaSet? `version: "3" services: mongos: container_name: mongos image: mongo:4.0.6 command: mongos --configdb cfgrs/192.168.1.105:40001,192.168.1.105:40002,192.168.1.105:40003 --bind_ip 0.0.0.0 --port 27017 ports: - 60000:27017 ........ `
@justmeandopensource
@justmeandopensource 5 лет назад
Hi Theara, mongos router is very light-weight and acts as an interface/gateway to your shards. From your applications you connect to one of the mongos router and do the db operations. Mongos will read/write data to the appropriate shard. Config servers are deployed as replicaset which stores information about the shards in your cluster. mongos router retrieves these information from config servers and uses it to find the data in the shard. You don't need to deploy mongos as a replicaset. You can run as many mongos router as you want on any machine. Typically a mongos router will be configured on the server where your client application reside. For more information you can check the official mongos documentation in the below link. docs.mongodb.com/manual/core/sharded-cluster-query-router/ Thanks.
@yuomtheara
@yuomtheara 5 лет назад
@@justmeandopensource thanks, It is not easy to understand. I will try from you
@yuomtheara
@yuomtheara 5 лет назад
@@justmeandopensource It mean that we don't need to deploy `Mongo Route/Mongos` on mongo server. We config it on `Application` side???
@justmeandopensource
@justmeandopensource 5 лет назад
Yes. It can be deployed anywhere on any machine, preferably on the server itself where your client application is running. Once you create the mongos router anywhere, you connect to it and add the shards that you want. Thanks.
@yuomtheara
@yuomtheara 5 лет назад
@@justmeandopensource Could We connect to config server/shard without `mongos/router`?
@Haile1Selassie
@Haile1Selassie 2 года назад
thanks)
@justmeandopensource
@justmeandopensource 2 года назад
Thanks for watching.
@abhishekjalan84
@abhishekjalan84 4 года назад
Thanks for the awesome video Venkat :) I have a small question. -> I am setting up 3 mongo docker containers in the same centos machine. but I am not able to change the default port. I don't want to use docker-compose file, do u have any solution for Dockerfile? where I can change the default MongoDB port? mongodb0 docker run --hostname mongodb0 -d -p 25000:27017 -v /data/mongodb0:/data/db/ --network='database' --name mongodb0 mongo:latest --replSet "rs0" mongodb1 docker run --hostname mongodb1 -d -p 26000:27017 -v /data/mongodb1:/data/db/ --network='database' --name mongodb1 mongo:latest --replSet "rs0" mongodb2 docker run --hostname mongodb2 -d -p 27000:27017 -v /data/mongodb2:/data/db/ --network='database' --name mongodb2 mongo:latest --replSet "rs0"
@justmeandopensource
@justmeandopensource 4 года назад
Hi Abhishek, thanks for watching. Your docker run commands seems to right. Since you are running all these containers on the same host machine, you will have to bind them to different ports like what you did. I am not entirely sure what you are after?
@AmL-iu2sq
@AmL-iu2sq 4 года назад
thanks you :D
@justmeandopensource
@justmeandopensource 4 года назад
HI Am, thanks for watching.
@varun898
@varun898 4 года назад
I have a Question. How can we configure authentication for client connections on a replica set? One other thing, have been following your new AWS series and I am really learning a lot.
@justmeandopensource
@justmeandopensource 4 года назад
Hi Varun, thanks for watching and for your interest in this series. I have done a video on configuring authentication in Mongo DB which you can watch it at ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-SY_9zwb29LA.html Thanks.
@yuomtheara
@yuomtheara 5 лет назад
Could advise number of `DigitalOcean droplets` for Mongo Sharding? - Number of droplets - Droplets size - ....
@justmeandopensource
@justmeandopensource 5 лет назад
Hi Theara, there is no specific answer to this question. It depends on a lot of factors like - how many shards you need - how big you expect your database to grow - what OS you are going to use - whether you are going to run mongo as docker containers or install directly on droplets For production use case, consider reading the below article www.mongodb.com/blog/post/capacity-planning-and-hardware-provisioning-mongodb-ten-minutes For just learning purpose, you can do with just one Digital Ocean droplet and run as many mongodb containers as you want in as many shards as you like. I have done couple videos on sharding, hope you watched them as well. If not here are the links. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-7Lp6R4CmuKE.html ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-LGERGvEaPW0.html ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Rwg26U0Zs1o.html Thanks
@yuomtheara
@yuomtheara 5 лет назад
@@justmeandopensource thanks
@justmeandopensource
@justmeandopensource 5 лет назад
You are welcome.
@yuomtheara
@yuomtheara 5 лет назад
@@justmeandopensource I will try with 2 or 3 droplets.
@justmeandopensource
@justmeandopensource 5 лет назад
Yeah. that sounds good.
@anushapulichintha3709
@anushapulichintha3709 3 года назад
Hi , thanks for the great tutorial. is it possible to get the docker file that you used for this deployment?
@mayikx
@mayikx 4 года назад
thanks for your amazing videos. Quick question . Can I have my own cluster of mongodb ? , If yes why I need to pay amazong and other companies to do that . I am thinking that I'm missing something very important. For example I'm never going to use docker to run my relational database . Can you please help me to understand it in a better way
@leothomas9080
@leothomas9080 4 года назад
Hi bro great video i followed the steps and I created the three mongodb instance but when i am using read preference its not connecting via spring boot can you advice getting this error" No server chosen by com.mongodb.client.internal.MongoClientDelegate"
@justmeandopensource
@justmeandopensource 4 года назад
Hi Leo, thanks for watching. Can you check if you can access the replicaset from a mongo shell first? And what is the connection string you are using from your spring boot application?
@leothomas9080
@leothomas9080 4 года назад
@@justmeandopensource I can connect to replica set without read preference but when read preference is given its not going to shell ,but replication is happening when i create some collections in primary node
@justmeandopensource
@justmeandopensource 4 года назад
@@leothomas9080 Okay. Can you share your connection string? I don't have any experience in Spring Boot.
@leothomas9080
@leothomas9080 4 года назад
@@justmeandopensource mongo mongo-admin:Phdxhhxyhsx@mongodb-server-1a:27017,mongodb-server-1b:27017,mongodb-server-1c:27017/admin?replicaSet=‌rs0&readPreference=secondaryPreferred
@1487atul
@1487atul 3 года назад
why ddn't you use rs.add("ServerB") rs.add("ServerC")
@justmeandopensource
@justmeandopensource 3 года назад
Hi Atul, thanks for watching. There are different ways to add members to a replicaset. What I have shown in this video is one method. If you want to add individual members later, you can follow your approach. Cheers.
@phanindrakumarkondeti2590
@phanindrakumarkondeti2590 2 года назад
Hi bro thank you for this very explanatory . how to bind multiple ip address
@krishnareddy9814
@krishnareddy9814 4 года назад
Can you please show how to enable security in replica sets?
@yuomtheara
@yuomtheara 5 лет назад
Thanks for your video. I base on Mac. I tried to run 3 docker container that difference by port (Not 3 host machine). I have problem with mongo connection ``` mongo 'mongodb://mongo1:27018,mongo2:27019:27020/?replicaSet=rs0 --- no primary found in replicaset or invalid replica set name ``` cat /etc/hosts ``` 127.0.0.1 mongo1 127.0.0.1 mongo2 127.0.0.1 mongo3 ```
@justmeandopensource
@justmeandopensource 5 лет назад
Hi Theera, Thanks for watching this video. I am not sure how you are starting the 3 docker containers for mongodb. Basically you run the same docker mongodb container in the default port 27017 but map to different host port on your mac. And don't have 127.0.0.1 entries in your /etc/hosts file. That will cause other problems. I am not sure if you have watched my other mongodb videos around sharding concept. I have docker-compose.yaml file ready for you to use. Check the below docker-compose file. github.com/justmeandopensource/learn-mongodb/blob/master/sharding/shard1/docker-compose.yaml Download it and run "docker-compose up -d". It will start 3 mongodb containers. All these containers use the default port 27017 but they are mapped to host machine on 50001, 50002 and 50003. Now you need to connect to one of the instance and initialize the replicaset. Check the below doc under shard1 servers. github.com/justmeandopensource/learn-mongodb/blob/master/sharding/00-setup-sharding-doc.md Now you can connect to the replicaset with the ip address of your mac machine. For example, if you mac's ip is 192.168.1.5, you can use the below command to connect. mongo mongodb://192.168.1.5:50001,192.168.1.5:50002,192.168.1.5:50003/?replicaSet=rs0 Use the replicaset name in the above command as what you defined while initializing the replicaset. Hope this makes sense. Thanks
@yuomtheara
@yuomtheara 5 лет назад
@@justmeandopensource Thanks for your quick reply. Yes I tried with `docker-composer.yml`, and mapped to host machine on difference port. Ex: 27018:27017, 27019:27017, 27020:27017 But don't use `--shardsvr`. I don't understand about `--shardsvr` option?. Oh I connect to mongo with `localhost:27018,localhost:27019, localhost:27020/?.....` I will try with your doc...
@justmeandopensource
@justmeandopensource 5 лет назад
Don't use the --shardsvr option unless you are setting up a sharded cluster. Otherwise the steps should be similar. Thanks.
@yuomtheara
@yuomtheara 5 лет назад
@@justmeandopensource Now I work fine (no --shardsvr) ``` version: "3" services: mongo1: container_name: mongo1 image: mongo:4.0.6 command: mongod --replSet rs0 --port 27017 --dbpath /data/db ports: - 5001:27017 volumes: - mongo1:/data/db mongo2: container_name: mongo2 image: mongo:4.0.6 command: mongod --replSet rs0 --port 27017 --dbpath /data/db ports: - 5002:27017 volumes: - mongo2:/data/db mongo3: container_name: mongo3 image: mongo:4.0.6 command: mongod --replSet rs0 --port 27017 --dbpath /data/db ports: - 5003:27017 volumes: - mongo3:/data/db volumes: mongo1: {} mongo2: {} mongo3: {} ``` Config rs.initiate(config) ``` config = { "_id": "rs0", "members": [ { "_id": 0, "host": "192.168.1.12:5001" }, { "_id": 1, "host": "192.168.1.12:5002" }, { "_id": 2, "host": "192.168.1.12:5003", }, ], } ``` Connection ``` mongo 'mongodb://localhost:5001,localhost:5002,localhost:5003/?replicaSet=rs0' ```
@yuomtheara
@yuomtheara 5 лет назад
@@justmeandopensource Excuse me, I can't fine the volume path ``` volumes: mongo1: {} mongo2: {} mongo3: {} ```
@ahfa7983
@ahfa7983 2 года назад
How to force secondry to become primery
@NamanJain-wo9zp
@NamanJain-wo9zp Год назад
At 14:50 when you run this command I am getting this error - MongoNetworkError: getaddrinfo ENOTFOUND mongodb0 Can you help me in resolving this issue?
@AshishKumar-ft6wv
@AshishKumar-ft6wv Год назад
Are you still facing the same error?
@swatisharma4676
@swatisharma4676 3 года назад
How to update hosts
Далее
Always Help the Needy
00:28
Просмотров 15 млн
MongoDB Schema Design Best Practices
50:39
Просмотров 172 тыс.
[ MongoDB 9 ] Sharding a MongoDB Collection
18:28
Просмотров 48 тыс.
Uber Writes A Data Store To Save 6 Million
14:28
Просмотров 125 тыс.