<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/styles/XMLStylesDoc_xhtml11_en.xsl"?><!DOCTYPE document SYSTEM "/schemas/XMLStyles10.dtd">
<document xmlns="http://XMLStyles.com/namespaces/styles" xmlns:xst="http://XMLStyles.com/namespaces/styles" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:date="http://exslt.org/dates-and-times">
   <noxml>
      <p xmlns="http://www.w3.org/1999/xhtml"/>
      <!-- You are viewing the source.  The following message should be ignored if you did "View Source" in your browser. -->
      <p xmlns="http://www.w3.org/1999/xhtml">
ATTENTION: XML WEB PAGES NOT SUPPORTED
   If you see this message, your current browser does not support the
   1999 XSLT 1.0 (or later) standard for XML web pages such as this one.
   Please upgrade your browser to a newer version
   that supports 1999 or later standards such as:
      Mozilla Firefox version 1.0.2 or later (GetFirefox -&gt; http://www.GetFirefox.com/)
      Netscape version 8 or later
      Safari version 1.3 or later
      Opera version 9 or later
      Microsoft Internet Explorer (MSIE) version 5 or later
   For further assistance, contact the software vendor for your browser.
   To go to the X<!-- extended HTML -->HTML version of this page click the following link:
<a href="index.html">index.html</a>
      </p>
      <p xmlns="http://www.w3.org/1999/xhtml">&#160;</p>
   </noxml>
   <path>/computers/databases/oracle/</path>
   <site>How To Guides</site>
   <logo xlink:type="simple" xlink:href="/images/howtohome.jpg" media="screen" width="240" height="34">How To Guides</logo>
   <logo xlink:type="simple" xlink:href="/images/howtoguides.jpg" media="print" width="240" height="34">How To Guides</logo>
   <logo xlink:type="simple" xlink:href="/images/howtoguidesmobile.jpg" media="handheld" width="150" height="17">How To Guides</logo>
   <navigation where="sections">
      <label>How To Guides</label>
      <link xlink:type="simple" xlink:href="/business/index.xml">Business</link>
      <link xlink:type="simple" xlink:href="/computers/index.xml">Computers</link>
      <link xlink:type="simple" xlink:href="/computers/databases/index.xml">Databases</link>
      <link xlink:type="simple" xlink:href="/internet/index.xml">Internet</link>
      <link xlink:type="simple" xlink:href="/mobile/index.xml">Mobile</link>
      <link xlink:type="simple" xlink:href="/money/index.xml">Money</link>
      <link xlink:type="simple" xlink:href="/movies/index.xml">Movies</link>
      <link xlink:type="simple" xlink:href="/computers/os/index.xml">Operating Systems</link>
   </navigation>
   <navigation where="up">
      <link xlink:type="simple" xlink:href="../../">Computers</link>
      <link xlink:type="simple" xlink:href="../">Databases</link>
   </navigation>
   <navigation where="subsections">
      <link xlink:type="simple" xlink:href="/computers/databases/design.xml">Design</link>
      <link xlink:type="simple" xlink:href="/computers/databases/tuning.xml">Tuning</link>
      <link xlink:type="simple" xlink:href="/computers/databases/derby/">Apache Derby</link>
      <link xlink:type="simple" xlink:href="/computers/databases/ibmdb2/">IBM DB2</link>
      <link xlink:type="simple" xlink:href="/computers/databases/mysql/">MySQL</link>
      <link xlink:type="simple" xlink:href="index.xml">Oracle</link>
      <link xlink:type="simple" xlink:href="/computers/databases/sqlserver/">SQL Server</link>
   </navigation>
   <section id="body" type="body">
      <pages name="recovery">
         <title>Recovery Scenarios</title>
         <label>Recovery</label>
         <navigation where="up">
            <link xlink:type="simple" xlink:href="index.xml">Oracle</link>
         </navigation>
         <h1>Recovery Scenarios</h1>
         <page id="N103D0" name="tsprestore">
            <title>Restore A Tablespace</title>
            <label>Tablespace</label>
            <description>Restoring one tablespace to an auxiliary instance.</description>
            <subpage id="N103D8" name="tsprestore1a">
               <p>This can be used to recover the data in individual tables,
                  possibly after a table has been dropped, for example.
                  The tablespace containing the table is restored to an auxiliary instance,
                  after which the data can be manually copied back to the original instance.
               </p>
               <p class="warning">Note: Although the tablespace point in time recovery (TSPITR)
                  initially restores the tablespace to an auxiliary instance, it also <i>recovers</i>
                  the tablespace by transporting it back to the original instance.
               </p>
               <p>See Oracle Metalink Document #228257.1
                  <link xlink:type="simple" xlink:href="https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&amp;p_id=228257.1">RMAN "Duplicate Database" Feature in Oracle 9i and Oracle 10g</link>.
               </p>
            </subpage>
            <subpage id="N103E9" name="tsprestore1b">
               <ol>
                  <li>Log onto the system using the ID for starting the Oracle database.
                  </li>
                  <li>Shut down the auxiliary instance:
                     <blockcode>
                        <l>export ORACLE_SID=<i>auxsvc</i>​</l>
                        <l>sqlplus '<i>username</i>/<i>password</i> as sysdba'</l>
                        <l>show parameter db_name</l>
                        <l>shutdown immediate</l>
                     </blockcode>
                  </li>
                  <li>The control file of the auxilary instance will be replaced.
                     If the instance will need to be restored back to its original state then
                     make a copy of the existing control file before starting the restore.
                  </li>
                  <li>Start up the instance in <code>nomount</code> mode:
                     <blockcode>
                        <l>startup nomount</l>
                        <l>exit</l>
                     </blockcode>
                  </li>
                  <li>Generate a list of tablespaces to be skipped:
                     <blockcode>
                        <l>sqlplus <i>username</i>/<i>password</i>@<i>tspsid</i>​</l>
                        <l>set pages<span class="optional">ize</span> 50000</l>
                        <l>select tablespace_name || ',' from dba_tablespaces where contents not in ('TEMPORARY','UNDO') and tablespace_name not in ('SYSTEM','<i>tspname</i>',...) order by 1</l>
                     </blockcode>
                     where <i>tspsid</i> is the instance containing the tablespace to be restored.
                     Include a list of the tablespaces to be restored in the second <code>in</code> clause.
                     If there are indexes in separate tablespaces, they should also be restored; otherwise
                     the primary key constraints and/or other indexes on the tables in the tablespaces
                     that are restored will need to be dropped in order to access the data in the tables.
                  </li>
                  <li>Get the file IDs and file names of the data files to be restored:
                     <blockcode>
                        <l>select file_id, file_name from dba_data_files where tablespace_name in ('<i>tspname</i>',...);</l>
                     </blockcode>
                     Change the file name to avoid overwriting any existing files.
                  </li>
                  <li>Determine the number of groups of redo logs and the number of copies of each.
                  </li>
                  <li>Start RMAN, connecting to the target, catalog and auxiliary instances.
                     <blockcode>
                        <l>rman target sys/<i>password</i>@<i>tspsid</i> catalog <i>rmanid</i>/<i>rmanpass</i>@<i>catsid</i> auxiliary sys/<i>auxpass</i>[@<i>auxsid</i>]</l>
                     </blockcode>
                  </li>
                  <li>Resyncronize the catalog if necessary, to include any new archive logs:
                     <blockcode>
                        <l>list archivelog all;</l>
                        <l>resync catalog;</l>
                     </blockcode>
                  </li>
                  <li>Execute the following RMAN command to restore the tablespace to the auxiliary instance:
                     <blockcode>
                        <l>run {</l>
                        <l>  allocate auxiliary channel 'tape1' device type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo_<i>tspsid</i>.opt)';</l>
                        <l>  set until time "to_date('<i>mm/dd/yyyy hh:mm:ss</i>','mm/dd/yyyy hh24:mi:ss')";</l>
                        <l>  set newname for datafile 1 TO '/u##/oradata/<i>auxsid</i>/sys<i>tspsid</i>01.dbf';</l>
                        <l>  set newname for datafile 2 TO '/u##/oradata/<i>auxsid</i>/undo<i>tspsid</i>01.dbf';</l>
                        <l>  set newname for datafile <i>fileid</i> TO '/u##/oradata/<i>auxsid</i>/<i>tspsid</i>
                           <i>filename</i>';</l>
                        <l>  duplicate target database to <i>auxsid</i>​</l>
                        <l>     skip tablespace</l>
                        <l>        <i>list of tablespaces to be skipped</i>​</l>
                        <l>     logfile</l>
                        <l>        group 1 ('/u01/oradata/<i>auxsid</i>/redo<i>tspsid</i>01a.log',</l>
                        <l>                 '/u02/oradata/<i>auxsid</i>/redo<i>tspsid</i>01b.log') size 10M reuse,</l>
                        <l>        group 2 ('/u01/oradata/<i>auxsid</i>/redo<i>tspsid</i>02a.log',</l>
                        <l>                 '/u02/oradata/<i>auxsid</i>/redo<i>tspsid</i>02b.log') size 10M reuse,</l>
                        <l>        group 3 ('/u01/oradata/<i>auxsid</i>/redo<i>tspsid</i>03a.log',</l>
                        <l>                 '/u02/oradata/<i>auxsid</i>/redo<i>tspsid</i>03b.log') size 10M reuse;</l>
                        <l>}</l>
                     </blockcode>
                  </li>
                  <li>Wait for the restore and recovery to complete, then exit RMAN:
                     <blockcode>
                        <l class="output">Starting restore at ...</l>
                        <l class="output">channel tape1: starting datafile backupset restore</l>
                        <l class="output">channel tape1: restore complete</l>
                        <l class="output">Finished restore at ...</l>
                        <l class="output">Starting recover at ...</l>
                        <l class="output">starting media recovery</l>
                        <l class="output">media recovery complete</l>
                        <l class="output">Finished recover at ...</l>
                        <l class="output">database dismounted</l>
                        <l class="output">Oracle instance shut down</l>
                        <l class="output">connected to auxiliary database (not started)</l>
                        <l class="output">Oracle instance started</l>
                        <l>exit</l>
                        <l class="output">Recovery Manager complete.</l>
                     </blockcode>
                  </li>
                  <li>If the restore fails after media recovery, it may be possible
                     to continue without having to restore again.  For example:
                     <blockcode>
                        <l class="output">sql statement: drop tablespace  XDB including contents</l>
                        <l class="output">RMAN-00571: ===========================================================</l>
                        <l class="output">RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============</l>
                        <l class="output">RMAN-00571: ===========================================================</l>
                        <l class="output">RMAN-03002: failure of Duplicate Db command at 11/15/2007 22:24:22</l>
                        <l class="output">RMAN-03015: error occurred in stored script Memory Script</l>
                        <l class="output">RMAN-03009: failure of sql command on clone_default channel at 11/15/2007 22:24:22</l>
                        <l class="output">RMAN-11003: failure during parse/execution of SQL statement: drop tablespace  XDB including contents</l>
                        <l class="output">ORA-29857: domain indexes and/or secondary objects exist in the tablespace</l>
                        <l>export ORACLE_SID=<i>auxsvc</i>​</l>
                        <l>sqlplus '<i>username</i>/<i>password</i> as sysdba'</l>
                        <l>set pages<span class="optional">ize</span> 50000</l>
                        <l>select name, open_mode from v$database;</l>
                        <l>column name format a60</l>
                        <l>select status, name, enabled from v$datafile;</l>
                     </blockcode>
                  </li>
                  <li>If any required indexes were not restored, an error will occur when attempting to
                     access the data in the restored table.  Those indexes will need to be dropped.
                     <blockcode>
                        <l class="output">ERROR at line 1:</l>
                        <l class="output">ORA-00376: file ## cannot be read at this time</l>
                        <l class="output">ORA-01111: name for data file ## is unknown - rename to correct file</l>
                        <l class="output">ORA-01110: data file ##: '/u01/app/oracle/product/<i>version</i>/dbs/MISSING000##'</l>
                        <l>alter table <i>owner</i>.<i>table_name</i> drop constraint <i>constraint_name</i>;</l>
                     </blockcode>
                  </li>
                  <li>To keep the restored data in the auxiliary instance,
                     reset the database to indicate that a RESETLOGS has been done:
                     <blockcode>
                        <l>export ORACLE_SID=<i>auxsvc</i>​</l>
                        <l>rman target sys/<i>password</i>[@<i>auxsid</i>] catalog <i>rmanid</i>/<i>rmanpass</i>@<i>catsid</i>
                        </l>
                        <l>reset database;</l>
                     </blockcode>
                     To return to the original data in the auxiliary instance, shut down the instance:
                     <blockcode>
                        <l>sqlplus '<i>username</i>/<i>password</i> as sysdba'</l>
                        <l>show parameter db_name</l>
                        <l>shutdown immediate</l>
                        <l>exit</l>
                     </blockcode>
                     Rename the control files back, then start up the instance in <code>nomount</code> mode:
                     <blockcode>
                        <l>sqlplus '<i>username</i>/<i>password</i> as sysdba'</l>
                        <l>startup nomount</l>
                        <l>exit</l>
                     </blockcode>
                     Reset the database incarnation to the one that matches the restored control files:
                     <blockcode>
                        <l>rman target sys/<i>password</i>[@<i>auxsid</i>] catalog <i>rmanid</i>/<i>rmanpass</i>@<i>catsid</i>
                        </l>
                        <l>list incarnation of database <i>auxsid</i>;</l>
                        <l>reset database to incarnation <i>inckey</i>​</l>
                        <l>exit</l>
                     </blockcode>
                  </li>
               </ol>
            </subpage>
            <updated local="2007-11-19">Monday November 19, 2007</updated>
         </page>
      </pages>
   </section>
   <copyright>Copyright © 2006 How To Guides .com. Alteration of content, including addition of any function such as hypertext links or pop-up advertising, or interference with the hypertext links or other functions of this site is expressly prohibited.</copyright>
   <disclaimer>All information, links, forms, applications and other items on this site or obtained from it are provided <b>AS IS</b>, WITHOUT WARRANTY OF ANY KIND EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.</disclaimer>
   <ids urchin="UA-779578-2"/>
</document>

