Master Slave Pgpool
Master Slave Pgpool
Abo!t me
G
"#$#/%/"
ats!o Ishii
"
G G
G G
.stablishe) in "##/ &rovi)s commercial s!pport 0or &ostgreS'( an) other OSS +o MyS'( s!pport Sells commercial packages base) on &ostgreS'( rainings an) certi0ications S!pports &ostgreS'( comm!nity
G G
"#$#/%/"
1rom I&A6In0ormation technology promotion agency78s s!rvey in "##* "#$#/%/" ats!o Ishii 5
"#$#/%/"
ats!o Ishii
,hat is pgpool-II>
G
G G
?et another cl!ster mi))le ware )e)icate) 0or &ostgreS'( @omm!nity )evelope) open so!rce so0tware proAect Rich 0eat!res
G G G G G G
Synchrono!s replication (oa) balancing A!tomatic 0ailover @onnection pooling &arallel 9!ery @ollaborating with other replication tools
G
"#$#/%/"
9!ery
"#$#/%/"
ats!o Ishii
he architect!re o0 pgpool-II
+ew in pgpool-II -.#
pcp process pgpool-II parent ;ealth @hecking &ostgreS'( @lient pgpool-II pgpool-II chil) chil) '!ery worker process
A)min
'!ery
'!ery
"#$#/%/" ats!o Ishii
&ostgreS'(
*
Replication mo)e
ransparent against both &ostgreS'( server an) client 9!ery &ostgreS'( server
9!ery
&ostgreS'( client
9!ery
"#$#/%/"
ats!o Ishii
&ros
G G
G G
Synchrono!s replicationD no nee) to worry abo!t Eevent!ally consistentF problem. +o transaction loss A!tomatic 0ailoverD no phone calls 0rom angry c!stomers while yo! are in be) @onnection pooling an) loa) balancingD boost per0ormance Online recovery. ,itho!t stopping pgpool-II, yo! can repair or a)) a B4 no)e .asy to con0ig!re
@ons
G
,rite per0ormance is not goo)6abo!t -#: overhea)7 G Some 9!eries con0!se pgpool-IID ran)om67, se9!ences, 0!nctions those have a si)e e00ect6write to the )atabase7 "#$#/%/" ats!o Ishii
$#
write 9!ery
9!ery
&ostgreS'( client
"#$#/%/"
ats!o Ishii
$$
&ros
G G G
,rite per0ormance is goo) 6$#-"#: overhea)7 A!tomatic 0ailover o0 slaves @onnection pooling an) loa) balancingD boost per0ormance Asynchrono!s replication
G
@ons
G
+o BB( replication
G
G G
"#$#/%/"
"#$#/%/"
ats!o Ishii
$-
.asy to manage
rea) 9!ery
"#$#/%/"
ats!o Ishii
$/
"#$#/%/"
ats!o Ishii
$=
"#$#/%/"
ats!o Ishii
$%
;owever...
G G G
+o a!tomatic 0ailover +o connection pooling, loa) balancing ?o! nee) to know what the stan)by )islikeD
Bata Manip!lation (ang!age 6BM(7 - I+S.R , 2&BA ., B.(. ., @O&? 1ROM, R2+@A .. +ote that there are no allowe) actions that res!lt in a trigger being e<ec!te) )!ring recovery. Bata Be0inition (ang!age 6BB(7 - @R.A ., BRO&, A( .R, @OMM.+ . his also applies to temporary tables also beca!se c!rrently their )e0inition ca!ses writes to catalog tables. S.(.@ ... 1OR S;AR. H 2&BA . which ca!se row locks to be written R!les on S.(.@ statements that generate BM( comman)s. (O@I that e<plicitly re9!ests a mo)e higher than RO, .J@(2SIK. MOB.. (O@I in short )e0a!lt 0orm, since it re9!ests A@@.SS .J@(2SIK. MOB.. ransaction management comman)s that e<plicitly set non-rea)-only stateD 4.3I+ R.AB ,RI ., S AR S. RA+SA@ IO+ R.AB ,RI . RA+SA@ IO+ R.AB ,RI ., S. S.SSIO+ @;ARA@ .RIS I@S AS RA+SA@ IO+ R.AB ,RI .
S. transactionLrea)Lonly M o00 wo-phase commit comman)s - &R.&AR. RA+SA@ IO+, @OMMI &R.&AR.B, RO((4A@I &R.&AR.B beca!se even rea)-only transactions nee) to write ,A( in the prepare phase 6the 0irst phase o0 two phase commit7. Se9!ence !p)ates - ne<tval67, setval67 (IS .+, 2+(IS .+, +O I1? "#$#/%/" ats!o Ishii $*
pgpool-II
rea)/write 9!ery
rea) 9!ery
"#$#/%/"
ats!o Ishii
$C
&ros
G G G G G
,rite per0ormance is goo) 6$#-"#: overhea)7 A!tomatic 0ailover o0 slaves @onnection pooling an) loa) balancingD boost per0ormance BB( replication (arge obAect replication Asynchrono!s replication
G
@ons
G
"#$#/%/"
ats!o Ishii
"#
+ew master/slave Es!bLmo)eF )e)icate) 0or Streaming replication an) ;ot stan)by A!tomatic 9!ery )ispatches
G
Sen) write 9!eries to the primary &rior releasesD sen) rea) 9!eries to the stan)by whenever possible -.#D @heck the replication )elay between the primary an) the stan)by. I0 it8s e<cee)s E)elayLthreshol)F, then sen) to the primary only.
ats!o Ishii "$
"#$#/%/"
call the 0!nctions every health check perio)s secon). calc!late the )i00erence. i0 it e<cee)s )elay threshol), sen) rea) 9!eries to the primary only. worker process
"#$#/%/" ats!o Ishii ""
logLstan)byL)elay
G G
8none8D no logging )elay 8i0LoverLthreshol)8D log only when )elay e<cee)s )elayLthreshol) 8always8D always log )elay
"#$#-#=-"* $/D/$D-" (O3D pi) $-""-D Replication 0rom the primary server 6no)eD#7 "#$#-#=-"* $/D/$D5" (O3D pi) $-""-D Replication 0rom the primary server 6no)eD#7 "#$#-#=-"* $/D/$D/" (O3D pi) $-""-D Replication 0rom the primary server 6no)eD#7 "#$#-#=-"* $/D/"D#" (O3D pi) $-""-D Replication 0rom the primary server 6no)eD#7 "#$#-#=-"* $/D/"D$" (O3D pi) $-""-D Replication 0rom the primary server 6no)eD#7 "#$#-#=-"* $/D/"D"" (O3D pi) $-""-D Replication 0rom the primary server 6no)eD#7 o0 no)eD$ is behin) $""**## bytes o0 no)eD$ is behin) --"/C/" bytes o0 no)eD$ is behin) C%5*5* bytes o0 no)eD$ is behin) "CC##*# bytes o0 no)eD$ is behin) C#$$"# bytes o0 no)eD$ is behin) "5--#"5 bytes
"-
"#$#/%/"
ats!o Ishii
,e can a)) stan)by servers witho!t sacri0icing per0ormance More stan)by servers means better rea) per0ormance with loa) balancing
"#$#/%/"
ats!o Ishii
"5
S!mmary
G G
pgpool-II overview Kario!s con0ig!rations o0 pgpool-II an) their pros an) cons
G G G
Replication mo)e Master/Slave mo)e 6Slony-I7 Master/Slave mo)e 6Streaming replication G ;ot stan)by7
pgpool-II -.# G Streaming replication G ;ot stan)by will o00er one o0 the i)eal replication sol!tions
G G G
"#$#/%/"
2R(S
G
httpD//pg0o!n)ry.org/proAects/pgpool/
Kisit SRA OSS8s website i0 yo! nee) commercial s!pport 0or pgpool-II an)/or &ostgreS'(D
G
httpD//www.srasoss.co.Ap/in)e<Len.php
"#$#/%/"
ats!o Ishii
"=