Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Replica Sets

13,301 views

Published on

Published in: Technology, Business
  • Login to see the comments

Replica Sets

  1. 1. !"#$%&'()*+'*,+!"#$%&'+-"./+ 01%23.+4"55%6'*+78,6"559+ :;2"*+ <6)*2)=5+
  2. 2. >"*"5'$+?3%$)/)#3@+ •  -3'5,%*2+=)5+-&'$"ABC.+ •  !"#$%&'()*+=)5+DE+ •  F%.3+.3"+)&&'/%)*'$+"G&"#()*+ –  -6'$$+,'.'+/".H+6)/.$@+5"',/+
  3. 3. I'/%&/+ •  E+J%.+$%K"+4@-LM+5"#$%&'()*+ –  E/@*&35)*)C/+6'/."5N/$'O"+ –  M".P/+.5@+%.Q+
  4. 4. R)66'*,+M%*"+ •  AA6'/."5+SAA)#$)2-%T"+U4IVW+ •  AA/$'O"+X/)C5&"+U3)/.V+SAA)*$@+U,JVW+
  5. 5. Y3"+$)&'$+,J+ •  0)"/*P.+5"#$%&'."+ •  B*+6'/."5Z+ –  $)&'$[)#$)2[6'%*+ –  $)&'$[/$'O"/+ •  B*+/$'O"Z+ –  $)&'$[/)C5&"/+ > use local > db.sources.find()
  6. 6. E,6%*%/.5'()*+ > // master > use local > db.printReplicationInfo() > db.slaves.find() > db.oplog.$main.findOne() // slave > use local > db.printSlaveReplicationInfo()
  7. 7. Y)#)$)2%"/+ M->S M->S ->S ->S M->S(db1) ->S(db2) … M->S ->delayed_S M->S one machine can back up many M-/ (if it has enough resources) M<->M *very limited – best for experiments And Replica Sets (see below)
  8. 8. !"#$%&'+-"./+ • +>"*"5'$%T"H+%6#5)O"H+'*,+5"#$'&"+!"#$%&'+?'%5/+ • +E+&$C/."5+)=+]+/"5O"5/+ • +E*@+7)*"9+*),"+&'*+J"+#5%6'5@+ • +R)*/"*/C/+"$"&()*+)=+#5%6'5@+ • +EC.)6'(&+='%$)O"5+ • +EC.)6'(&+5"&)O"5@+ • +E$$+15%."/+.)+#5%6'5@+ • +!"',/+&'*+J"+.)+#5%6'5@+)5+'+/"&)*,+ • +0'.'+&"*."5+'1'5"+ • +^*+O:[_+7`YE+aC$@+b;:;9+
  9. 9. !"#$%&'+-"./+X+0"/%2*+R)*&"#./+ :[  E+15%."+%/+)*$@+.5C$@+&)66%c",+)*&"+%.+3'/+5"#$%&'.",+ .)+'+6'd)5%.@+)=+/"5O"5/+%*+.3"+/".[++7!"#$%&#'%()#*+,# $+&-,.%/+&#+*#)0(1#)0+230H+1%.3+2".M'/.`55)5[9+ b[  F5%."/+13%&3+'5"+&)66%c",+'.+.3"+6'/."5+)=+.3"+/".+ 6'@+J"+O%/%J$"+J"=)5"+.3"+.5C"+&$C/."5A1%,"+&)66%.+ 3'/+)&&C55",[++Y3%/+#5)#"5.@H+13%&3+%/+6)5"+5"$'G",+ .3'*+/)6"+.5',%()*'$+#5),C&./H+6'K"/+.3")5"(&'$$@+ '&3%"O'J$"+#"5=)56'*&"+'*,+'O'%$'J%$%.@+3%23"5[+ e[  B*+'+='%$)O"5H+%=+.3"5"+%/+,'.'+13%&3+3'/+*).+5"#$%&'.",+ =5)6+.3"+#5%6'5@H+.3"+,'.'+%/+,5)##",+7/""+<:9[+
  10. 10. E+-".+ 4"6J"5+:+ 4"6J"5+e+ 4"6J"5+b+
  11. 11. E+-".+ 4"6J"5+:+ 4"6J"5+e+ 4"6J"5+b+ ?!^4E!f+
  12. 12. E+-".+ 4"6J"5+:+ 4"6J"5+e+ ?!^4E!f+ 4"6J"5+b+ 0BF]+
  13. 13. E+-".+ 4"6J"5+:+ 4"6J"5+e+ ?!^4E!f+ 4"6J"5+b+ !`RBg`!A ^]>+
  14. 14. E+-".+ 4"6J"5+:+ 4"6J"5+e+ ?!^4E!f+ 4"6J"5+b+
  15. 15. R)*h2C5'()*+ { _id : <setname>, members: [ { _id : <ordinal>, host : <hostname[:port]>, [, priority: <priority>] [, arbiterOnly : true] [, votes : n] [, delay : time] } , ... ], settings: { [heartbeatSleep : <seconds>] [, heartbeatTimeout : <seconds>] [, heartbeatConnRetries : <n>] [, getLastErrorDefaults: <lasterrdefaults>] } }
  16. 16. ^*%('()*+ > cfg = { ... _id : "acme_a", ... members : [ ... { _id : 0, host : "sf1.acme.com" }, ... { _id : 1, host : "sf2.acme.com" }, ... { _id : 2, host : "sf3.acme.com" } ] } > use admin > db.runCommand({replSetInitiate:cfg})
  17. 17. R)66'*,/+ !"#$%&$'()"*"+"," +R3"&K/+%=+.3"+*),"+.)+13%&3+1"+'5"+&)**"&(*2+%/+&C55"*.$@+#5%6'5@[+ 4)/.+,5%O"5/+,)+.3%/+&3"&K+'C.)6'(&'$$@+'*,+.3"*+/"*,+5"iC%5"/+.)+ .3"+&C55"*.+#5%6'5@[+ !")(-./('0('/'&'1$"*"+"," +-.'.C/+%*=)56'()*+)*+.3"+5"#$%&'+/".+=5)6+.3%/+*),"j/+#)%*.+)=+O%"1[+ +3c#ZNN$)&'$3)/.Zbk;:lN5"#$-".>".-.'.C/m."G.+ !")(-./('23#4&'("*"567389:"," +^*%('."+'+5"#$%&'+/".[++ !")(-./(';)((<("*"5=77.:"," +n5""T%*2+'+5"#$%&'+/".+#5"O"*./+='%$)O"5/+=5)6+)&&C55%*2[+Y3%/+&'*+J"+ C/"=C$+,C5%*2+6'%*."*'*&"[+
  18. 18. -".+4"6J"5+Y@#"/+ •  ])56'$+ •  o0!p+7#5%)5%.@+U+:[;9+ –  Y@#%&'$$@+,%/.'*.+$)&'()*+)5+/6'$$"5+3'5,1'5"+ •  ?'//%O"+7#5%)5%.@+qq+;9+ •  E5J%."5+7*)+,'.'H+JC.+&'*+O)."9+
  19. 19. F%.3+-3'5,%*2+
  20. 20. 0)&/Z+111[6)*2),J[)52N,%/#$'@N0BR-N!"#$%&'r-"./+ LC"/()*/m+ 453"&#(1#0(,(&3#6#(&#72,+8"#9#:;<;#6#".%(=#21># ?'(30)@453"&;$+.# ]"G.+/"//%)*Z+ +EC.)A/3'5,%*2+ s#/.'%5/Z+ +D'&K+/"//%)*+

×