</head>
<!-- hhmts start -->
-Last modified: Mon Apr 11 17:08:40 JST 2011
+Last modified: Sun May 1 18:34:53 JST 2011
<!-- hhmts end -->
<body bgcolor="#ffffff">
<dt><a name="RECOVERY_1ST_STAGE_COMMAND"></a>recovery_1st_stage_command</dt>
<dd>
<p>
-This parameter specifies a command to be run at the first stage of online
+This parameter specifies a command to be run by master(primary) PostgreSQL server at the first stage of online
recovery. The command file must be put in the database cluster directory
for security reasons.
For example, if recovery_1st_stage_command = 'sync-command', then
<dt><a name="RECOVERY_2ND_STAGE_COMMAND"></a>recovery_2nd_stage_command</dt>
<dd>
<p>
-This parameter specifies a command to be run at the second stage of online
+This parameter specifies a command to be run by master(primary) PostgreSQL server at the second stage of online
recovery. The command file must be put in the database cluster directory
for security reasons.
<p>
In master/slave mode with streaming replication, online recovery can be
performed.
-Only a standby node can be recovered. You cannot recover the primary node.
-To recover the primary node, you have to stop all DB nodes and pgpool-II, and
-then restore it from a backup.
+In the online recovery procedure, primary server acts as a master server and recoveres specified standby server.
+Thus the recovery procedure requires that the primary server is up and running.
+If the primary server goes down, and no standby server is promoted, you need to stop
+pgpool-II and all PostgreSQL servers and recover them manually.
</p>
<p>
That's it.
Now you should be able to use pcp_recovery_node (as long as the standby
node stops) or push "recovery" button of pgpoolAdmin to perform online recovery.
+If something goes wrong, please examin pgpool-II log, primary server log and standby server log(s).
+</p>
+<p>
+For your reference, here are the steps taken in the recovery procedure.
+<ol>
+<li>Pgpool-II connects to primary server's template1 database as user = recovery_user, password = recovery_password.
+<li>Primary server executes pgpool_recovery function.
+<li>pgpool_recovery function executes recovery_1st_stage_command.
+Note that PostgreSQL executes functions with database cluster as the current directory.
+Thus recovery_1st_stage_command is executed in the database cluster directory.
+<li>Primary server executes pgpool_remote_start function.
+This function executes a script named "pgpool_remote_start" in the database cluster directory, and it executes pg_ctl command on the standby server to be recovered via ssh.
+pg_ctl will start postmaster in background.
+So we need to make sure that postmaster on the standby actually starts.
+<li>pgpool-II tries to connect to the standby PostgreSQL as user = recovery_user and password = recovery_password.
+The database to be connected is "postgres" if possible. Otherwise "template1" is used.
+pgpool-II retries for <a href="#RECOVERY_TIMEOUT">recovery_timeout</a> seconds.
+If success, go to next step.
+<li>If <a href="#FAILBACK_COMMAND">failback_command</a> is not empty, pgpool-II parent process executes the script.
+<li>After failback_command finishes, pgpool-II restart all child processes.
+</ol>
</p>
<h3>Parallel Mode</h3>
<body>
<!-- hhmts start -->
-Last modified: Mon Apr 11 17:24:54 JST 2011
+Last modified: Sun May 1 18:23:46 JST 2011
<!-- hhmts end -->
<body bgcolor="#ffffff">
<dt><a name="RECOVERY_1ST_STAGE_COMMAND"></a>recovery_1st_stage_command</dt>
<dd>
<p>
- \e$B:G=i$K%*%s%i%$%s%j%+%P%jCf$K5/F0$9$k%3%^%s%IL>$r;XDj$7$^$9!#%3%^%s%I\e(B
- \e$B%U%!%$%k$O%;%-%e%j%F%#>e$N4QE@$+$i%G!<%?%Y!<%9%/%i%9%?0J2<$K$"$k%3%^\e(B
- \e$B%s%I$d%9%/%j%W%H$N$_$r8F$S=P$7$^$9!#\e(B
-
+ \e$B%*%s%i%$%s%j%+%P%jCf$K5/F0$9$k%3%^%s%IL>$r;XDj$7$^$9!#\e(B
+ \e$B$3$N%9%/%j%W%H$O\e(BPostgreSQL\e$B$N%^%9%?%5!<%P\e(B(\e$B%W%i%$%^%j%5!<%P\e(B)\e$B$,5/F0$7$^$9!#\e(B
+ \e$B%3%^%s%I%U%!%$%k$O%;%-%e%j%F%#>e$N4QE@$+$i%G!<%?%Y!<%9%/%i%9%?0J2<$K$"$k%3%^%s%I$d%9%/%j%W%H$N$_$r8F$S=P$7$^$9!#\e(B
\e$BNc$($P!"\e(Brecovery_1st_stage_command = 'sync-command' \e$B$H@_Dj$7$F$"$k>l\e(B
\e$B9g!"\e(B$PGDATA/sync-command \e$B$r5/F0$7$h$&$H$7$^$9!#\e(B
</p>
<dt><a name="RECOVERY_2ND_STAGE_COMMAND"></a>recovery_2nd_stage_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%9%?$H$7!"\e(Bstandby\e$B%5!<%P$r%j%+%P%j$7$^$9!#\e(B
+primary\e$B%5!<%P$,F0:n$7$F$$$k$N$,$3$NJ}K!$NA0Ds>r7o$G$9$N$G!"\e(B
+primary\e$B%5!<%P$,Dd;_$7$F$$$k>uBV$G$O%*%s%i%$%s%j%+%P%j$O$G$-$^$;$s!#\e(B
+primary\e$B%5!<%,Dd;_$7$F$$$k>uBV$+$i$NI|5l$O!"$9$Y$F$N\e(BDB\e$B%N!<%I$H\e(Bpgpool-II\e$B$rDd;_$5$;$F<jF0$G<B;\$7$J$1$l$P$J$j$^$;$s!#\e(B
</p>
<p>
<li> recovery_1st_stage_command \e$B$r@_Dj$7$^$9!#\e(B
\e$B$3$3$G;XDj$9$k%U%!%$%k$O!"\e(Bprimary\e$B%5!<%P$+$i%Y!<%9%P%C%/%"%C%W$r<hF@$7!"\e(Bstandby\e$B%5!<%P$K%j%9%H%"$9$k$b$N$G$J$1$l$P$J$j$^$;$s!#\e(B
+recovery_1st_stage_command \e$B$O!"\e(Bprimary\e$B$N\e(BPostgreSQL\e$B$+$i!"\e(Brecovery_user\e$B$N8"8B$G5/F0$5$l!"$=$N;~$K0z?t$r<u$1$H$j$^$9!#\e(B
+\e$B>\:Y$O!"\e(B<a href="#RECOVERY_1ST_STAGE_COMMAND">recovery_1st_stage_command</a>\e$B$N@_Dj9`L\$r$4Mw$/$@$5$$!#\e(B
\e$B$3$N%9%/%j%W%H%U%!%$%k$O!"\e(Bprimary\e$B$N%G!<%?%Y!<%9%/%i%9%?2<$KG[CV$7!"<B9T8"8B$rM?$($F$*$-$^$9!#\e(B
\e$B%5%s%W%k$H$7$F!"\e(Bprimary/standby\e$B$=$l$>$l0lBf9=@.$N>l9g$N%9%/%j%W%H\e(B<a href="basebackup.sh">(basebackup.sh)</a>\e$B$r<($7$^$9!#\e(B
\e$B$3$N%9%/%j%W%H$G$O!"\e(Brecovery_user \e$B$,%Q%9%o!<%I$J$7$G%j%+%P%jBP>]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J>e$G%*%s%i%$%s%j%+%P%j$N@_Dj$,=*N;$7$^$7$?!#\e(B
standby\e$B%N!<%I$rDd;_$7$?>uBV$G!"\e(Bpcp_recovery_node\e$B$rMxMQ$9$k$+!"\e(BpgpoolAdmin\e$B$N!V%j%+%P%j!W%\%?%s$G%*%s%i%$%s%j%+%P%j$,=PMh$k$h$&$K$J$C$?$O$:$G$9!#\e(B
-
+\e$B$&$^$/$$$+$J$$>l9g$O!"\e(Bpgpool-II\e$B$N%m%0!"\e(Bprimary\e$B%5!<%P!"\e(Bstandby\e$B%5!<%P$N%m%0$r3NG'$7$F$/$@$5$$!#\e(B
+</p>
+<p>
+\e$B;29M$^$G$K!"%9%H%j!<%_%s%0%l%W%j%1!<%7%g%s$G$N%*%s%i%$%s%j%+%P%j$NFbIt=hM}$NN.$l$r@bL@$7$^$9!#\e(B
+<ol>
+<li>pgpool-II\e$B$O!"\e(Bprimary\e$B%5!<%P$K%f!<%6\e(B: recovery_user, \e$B%Q%9%o!<%I\e(B: recovery_password \e$B$G\e(Btemplate1\e$B%G!<%?%Y!<%9$K@\B3$7$^$9\e(B
+<li>primary\e$B%5!<%P$G!"\e(Bpgpool_recovery\e$B4X?t$r<B9T$7$^$9\e(B
+<li>pgpool_recovery\e$B4X?t$O!"\e(Brecovery_1st_stage_command \e$B$G;XDj$5$l$?%9%/%j%W%H$r<B9T$7$^$9!#\e(B
+\e$B$J$*!"\e(BPostgreSQL\e$B$O!"%G!<%?%Y!<%9%/%i%9%?%G%#%l%/%H%jCf$G4X?t$r<B9T$7$^$9!#\e(B
+\e$B$h$C$F!"\e(Bpgpool_recovery\e$B4X?t$b\e(Bprimary\e$B%5!<%P$N%G!<%?%Y!<%9%/%i%9%?%G%#%l%/%H%jCf$G4X?t$r<B9T$5$l$k$3$H$KCm0U$7$F$/$@$5$$!#\e(B
+<li>primary\e$B%5!<%P$G!"\e(Bpgpool_remote_start\e$B4X?t$r<B9T$7$^$9!#\e(B
+\e$B$3$N4X?t$O!"\e(Bprimary\e$B%5!<%P$N%G!<%?%Y!<%9%/%i%9%?%G%#%l%/%H%jCf$K$"$k\e(Bpgpool_remote_start\e$B$H$$$&L>A0$N%9%/%j%W%H$r5/F0$7!"$3$3$+$i\e(Bssh\e$B7PM3$G%j%+%P%jBP>]$N\e(Bstandby\e$B%5!<%P$N\e(BPostgreSQL\e$B$r\e(Bpg_ctl\e$B%3%^%s%I$r;H$C$F5/F0$7$^$9!#\e(B
+\e$B5/F0$O%P%C%/%0%i%&%s%I$G9T$o$l!"5/F0$G$-$?$+$I$&$+$O<!$N%9%F%C%W$G3NG'$5$l$^$9!#\e(B
+<li>pgpool-II\e$B$+$i!"\e(Bstandby\e$B%5!<%P$N\e(BPostgreSQL\e$B$N\e(Bpostgres\e$B%G!<%?%Y!<%9\e(B(postgres\e$B%G!<%?%Y!<%9$,$J$$>l9g$O\e(Btemplate1\e$B%G!<%?%Y!<%9\e(B)\e$B$K!"%f!<%6\e(B: recovery_user, \e$B%Q%9%o!<%I\e(B: recovery_password \e$B$G\e(Btemplate1\e$B%G!<%?%Y!<%9$K@\B3$r;n$_$^$9!#\e(B
+\e$B%j%H%i%$$O!"\e(B<a href="#RECOVERY_TIMEOUT">recovery_timeout</a>\e$BIC4V9T$o$l$^$9!#\e(B
+PostgreSQL\e$B$N5/F0$K@.8y$7$?$i!"<!$N%9%F%C%W$K0\$j$^$9!#\e(B
+<li><a href="#FAILBACK_COMMAND">failback_command</a>\e$B$,6u$G$J$$>l9g$O!"\e(Bpgpool-II\e$B$N?F%W%m%;%9$O;XDj$5$l$?%9%/%j%W%H$r5/F0$7$^$9!#\e(B
+<li>failback_command\e$B$,=*N;$7$?$i!"\e(Bpgpool-II\e$B$N;R%W%m%;%9$r$9$Y$F:F5/F0$7$^$9!#\e(B
+</ol>
</p>
<h2>Streaming Replication\e$B$G$N%/%(%j?6$jJ,$1\e(B</h2>