Saturday, April 27, 2013

Shutdown of Database quickly based on how much rollback is needed for clean shutdown


Quick way to shutdown cleanly when multiple sessions are active


Obviously SHUTDOWN ABORT is the fastest way to shutdown an Oracle database but this leaves the database in a inconsistent state.  So demonstrating a combination of shutdown abort and shutdown immediate (dependent on amount of rollback) as demonstrated below.

Note : When SHUTDOWN ABORT; if any backup is taken it would require recovery at next startup.

Step 1 Determine how much rollback (in bytes) is needed for a clean shutdown 

select sum(used_ublk) * <block size of the undo / rollback segment tablespace> from v$transaction;

Step 2 SHUTDOWN ABORT


SQL> shutdown abort

This will terminate all processes (CLIENT and BACKGROUND) as quickly as possible with no transaction rollback

Step 3 Decide based on Step 1 output whether to go for step 4 to step 6


From the results in #1 and your experience with your database, determine if you can wait for a clean shutdown (shutdown immediate).  If you cannot wait for a shutdown immediate, then skip the remaining steps and at the next startup SMON will rollback the transactions.

Step 4 STARTUP RESTRICT

SQL>startup restrict

5) Watch the rollback (number of blocks) 

select sum(distinct(ktuxesiz)) from x$ktuxe where ktuxecfl = 'DEAD';

6) When the rollback has completed (which can be immediately after startup)

SQL>SHUTDOWN IMMEDIATE



Once this competes ... the database will be cleanly shutdown

Reference : Oracle support note ID 386408.1

No comments:

Post a Comment