<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DBAPundits.com &#187; Step-by-step</title>
	<atom:link href="http://www.dbapundits.com/blog/category/step-by-step/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dbapundits.com/blog</link>
	<description>Articles and resources for the DBAs.</description>
	<lastBuildDate>Wed, 23 Nov 2011 03:22:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Standby roll forward using RMAN incremental backup</title>
		<link>http://www.dbapundits.com/blog/step-by-step/standby-roll-forward-using-rman-incremental-backup/</link>
		<comments>http://www.dbapundits.com/blog/step-by-step/standby-roll-forward-using-rman-incremental-backup/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 00:34:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Standby/Data Guard]]></category>
		<category><![CDATA[Step-by-step]]></category>

		<guid isPermaLink="false">http://www.dbapundits.com/blog/?p=361</guid>
		<description><![CDATA[<script type="text/javascript"><!--
google_ad_client = "pub-9448554670318827";
google_alternate_color = "FFFFFF";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "image";
google_ad_channel ="Pundits";
google_color_border = "FFFFFF";
google_color_link = "0022C9";
google_color_bg = "FFFFFF";
google_color_text = "000000";
google_color_url = "128A00";
google_ui_features = "rc:0";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><p>Last week I came across a scenario where a standby database went out of synch with the primary and there was a big gap of archive logs to be applied. Instead of rebuilding the standby database from scratch or restoring and applying a zillion archives, we can make use of a feature available from the [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I came across a scenario where a standby database went out of synch with the primary and there was a big gap of archive logs to be applied. Instead of rebuilding the standby database from scratch or restoring and applying a zillion archives, we can make use of a feature available from the version 10.2 onwards called the standby roll forward that uses RMAN incremental backup to apply the changes on the standby.</p>
<p>For databases on non-ASM, it should work with the first 4 steps as indicated below. For databases on ASM, we need to perform some more steps. </p>
<p>To keep it simple, I have outlined the steps below and have attached the logs for reference. </p>
<p>1) Identify the last SCN on the Standby, take the minimum value returned by the below queries for further steps.</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt;
col current_scn for 99999999999999999999999
col int_scn for 99999999999999999999999

select current_scn FROM V$DATABASE;
select min(fhscn) int_scn from x$kcvfh;  

CURRENT_SCN
-----------------
47987632
</pre>
<p>2) Take an incremental backup on the primary database from this SCN to the current point.<br />
The incremental backup files will be generated on the filesystem under the directory “/ora001/backup/” in the example.<br />
Need to make sure that there is sufficient space in the filesystem to hold the backup. In this case, the backup files sized nearly 1.2G.</p>
<pre class="brush: sql; title: ; notranslate">
RMAN&gt; CONFIGURE CHANNEL c1 DEVICE TYPE DISK FORMAT   '/ora001/backup/std_%U';
RMAN&gt; BACKUP INCREMENTAL FROM SCN 47987632 DATABASE;
</pre>
<p>3) SCP the backup files to the server where the standby database is running and catalog the backup.</p>
<pre class="brush: sql; title: ; notranslate">
RMAN&gt; CATALOG START WITH '/ora001/backup/std_%U';
</pre>
<p>This makes the controlfile aware of the incremental backup.</p>
<p>4) Recover the standby database.</p>
<pre class="brush: sql; title: ; notranslate">
RMAN&gt;
RECOVER DATABASE NOREDO;
</pre>
<p>5) Check the archive gap and the SCN to see if the DB has applied the changes. </p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt;
col CURRENT_SCN for 99999999999999999999999
select * from v$archive_gap;
select current_scn from v$database;
</pre>
<p>The standby is in good shape if the SCN returned is a bigger value and there are no gaps.</p>
<p>&#8212;- Steps above should be sufficient for non-ASM databases; continue the steps below for databases on ASM. &#8212;-<br />
(It was found that the SCN was not as expected and the steps below were done)</p>
<p>5) Cancel the database recovery at the standby site.</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
</pre>
<p>6) Take the controlfile backup again on primary database and SCP it over to the standby server.</p>
<pre class="brush: sql; title: ; notranslate">
RMAN&gt;
BACKUP CURRENT CONTROLFILE FOR STANDBY FORMAT '/ora001/ctrl_bkp.bak';
</pre>
<p>7) Take pfile, controlfile backups and note the current controlfile location on the standby and shutdown the standby database.</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt;
select name  from v$controlfile;
shut immediate;
startup nomount;
</pre>
<p>8) Restore the standby controlfile created in step 6 on the standby site.</p>
<pre class="brush: sql; title: ; notranslate">
RMAN&gt;
RESTORE STANDBY CONTROLFILE FROM '/ora001/ctrl_bkp.bak';
sql 'alter database mount';
</pre>
<p>9) At this point, the controlfiles on the standby database will have the datafiles pointed to the locations on primary. This needs to be updated so that they point to the right datafiles.</p>
<p>(For eg: On primary, it would be something like ‘+DATA01_R5/prod’ and on standby, the structure will be something like  ‘+DATA01_R5/stby’)</p>
<pre class="brush: sql; title: ; notranslate">
RMAN&gt;
CATALOG START WITH '+DATA01_R5/stby';
</pre>
<p>(May need to repeat this if there are files in multiple diskgroups)</p>
<p>10) Imp: If there are datafiles created on the primary database after the last SCN on standby (the one on step 1), we’ll need to backup the datafile(s), catalog the backup, do the restore of those file(s) too. The files can be identified with the below SQL:</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt;
SELECT FILE#, NAME FROM V$DATAFILE WHERE CREATION_CHANGE# &gt; 47987632;
</pre>
<p>11) Perform the switch so that the controlfile points to the datafiles under the standby directory.</p>
<pre class="brush: sql; title: ; notranslate">
RMAN&gt;
SWITCH DATABASE TO COPY;
</pre>
<p>12) Clear redo log groups on the standby.</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; ALTER DATABASE CLEAR LOGFILE GROUP 1;
SQL&gt; ALTER DATABASE CLEAR LOGFILE GROUP 2;
SQL&gt; ALTER DATABASE CLEAR LOGFILE GROUP 3;
</pre>
<p>13) Check the SCN on the standby and start the managed recovery. The SCN should be number much higher than that was on step 1 and there shouldn’t be no archive gaps.</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt;
select current_scn from v$database;
select * from v$archive_gap;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;
</pre>
<p>14) Do a couple of log switches on the primary and verify from the alert log that the standby is catching up with the primary.</p>
<p>15) Verify the standby redologs and other settings as required depending on the configuration and make sure the standby is in good shape.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.dbapundits.com%2Fblog%2Fstep-by-step%2Fstandby-roll-forward-using-rman-incremental-backup%2F&amp;title=Standby%20roll%20forward%20using%20RMAN%20incremental%20backup" id="wpa2a_2"><img src="http://www.dbapundits.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.dbapundits.com/blog/step-by-step/standby-roll-forward-using-rman-incremental-backup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle 11g active database duplication on Unix/Windows</title>
		<link>http://www.dbapundits.com/blog/step-by-step/oracle-11g-active-database-duplication/</link>
		<comments>http://www.dbapundits.com/blog/step-by-step/oracle-11g-active-database-duplication/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 10:55:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Step-by-step]]></category>

		<guid isPermaLink="false">http://www.dbapundits.com/blog/?p=9</guid>
		<description><![CDATA[<p>In this post, let me take you through the step-by-step method of active database duplication, a new feature of Oracle 11g to create a duplicate database. Active database duplication can also be used to create a standby database, which is mentioned separately in another post.</p> Basics <p align="justify">Upto Oracle version 11g, RMAN ‘DUPLICATE’ command required [...]]]></description>
			<content:encoded><![CDATA[<p>In this post, let me take you through the step-by-step method of active database duplication, a new feature of Oracle 11g to create a duplicate database. Active database duplication can also be used to create a standby database, which is mentioned separately in another post.</p>
<h5>Basics</h5>
<p align="justify">Upto Oracle version 11g, RMAN ‘DUPLICATE’ command required a database backup for performing database duplication/cloning. This is called backup based database duplication. Starting from Oracle 11g, an active database can be cloned to the same host or another without using an RMAN backup and the recovery catalog and this is called active database duplication.This can also be used to create a physical standby database. RMAN copies the live database files over the network to create the duplicate/standby database.</p>
<h5><strong>Prerequisites</strong></h5>
<p align="justify"><strong>*</strong> The source database must be in ARCHIVELOG mode if it is open.<br />
<strong>*</strong> If the source database is in NOARCHIVELOG mode, it should be mounted after a clean shut down.<br />
<strong>*</strong> Connections to the auxiliary instance must be through a Net service name.<br />
<strong>*</strong> The auxiliary instance must have a password file created, the password for the SYSDBA user used for the activity must be the same.</p>
<h5>Practical issues and solutions</h5>
<p align="justify">When the source database server and the target database server follow the same filesystem structure,size and standards, the duplication works fine without any issues. This may not be the case in most of the environments. The source database will have files laid across the mountpoints (say) &#8216;/oracle/oradata1/PROD&#8217;, &#8216;/oracle/oradata2/PROD&#8217; etc. The target server may follow a totally different structure. In such cases, perform any of the following methods:</p>
<p align="justify">1) Use the &#8216;SET NEWNAME FOR DATAFILE&#8217; and &#8216;SET NEW NAME FOR TEMPFILE&#8217; in the run {} block while performing restore/duplication. When specified,  the &#8216;SET NEWNAME&#8217;  command will take precedence over the other methods of renaming the database files.</p>
<p align="justify">If the destination server follows a different filesystem layout and if the files needs to be restored to a separate set of directories different than that from the source database, &#8216;SET NEWNAME&#8217; command needs to be used for each datafile and tempfile (&#8216;SET NEW NAME FOR TEMPFILE&#8217; command is introduced in Oracle 11g)</p>
<p align="justify">Note:</p>
<p align="justify">If &#8216;SET NEWNAME&#8217; commands are used in a &#8216;run {}&#8217;  block while performing a restore operation, the &#8216;run {}&#8217; block must contain the command &#8216;SWITCH DATAFILE ALL;&#8217;  and &#8216;SWITCH TEMPFILE ALL;&#8217;  (SWITCH TEMPFILE ALL; is available starting from Oracle 11g). If the &#8216;SWITCH; command is missed out during a restore operation,  &#8216;ALTER DATABASE RENAME FILE&#8217;  command must be used for each datafile before proceeding with the recovery. The details required to perform the manual execution of &#8216;ALTER DATABASE RENAME FILE&#8217; can be found from the alert log. It is a tedious task to do so, so NEVER forget to add the SWITCH commands in the run block  if you are performing an RMAN restore. For database duplication using DUPLICATE command, &#8216;SWITCH DATAFILE/TEMPFILE’ commands are not required as this function is handled by RMAN automatically.</p>
<p align="justify">2) DB_FILE_NAME_CONVERT clause in the DUPLICATE statement. This method will have the precedence if the DB_FILE_NAME_CONVERT / DB_LOG_FILE_NAME_CONVERT parameters are used in the Init.ora file.</p>
<p align="justify">3) DB_FILE_NAME_CONVERT and DB_LOG_FILE_NAME_CONVERT parameters in Init.ora.</p>
<p>4) In case Oracle managed files are used in the source database, either you can specify &#8216;SET NEWNAME&#8217; commands for each datafile and/or specify the parameters DB_FILE_CREATE_DEST and DB_CREATE_ONLINE_LOG_DEST_n in the auxiliary instance to get the datafiles, temp files and redo logs created in the respective directories.</p>
<h5>Step-by-step</h5>
<p align="justify">Terms used to describe the method step by step:</p>
<p align="justify">Target: Database to be cloned. (Source database &#8211; ORCL instance)<br />
Auxiliary: Destination database to which the source database will be cloned (ORCLDUP instance)</p>
<p>This scenario explains that the source and target database instances are on a Windows server. The method is the same for database duplication across 2 different servers (on Unix also) except that some of the OS commands mentioned below may need to be changed.</p>
<p><strong>1) Prepare Init.ora file for the auxiliary instance</strong></p>
<p>Copy the Init.ora file from the source server to the target server, to the dbs/database directory based on the underlying platform. Make necessary modifications in the Init.ora file, mainly the below parameters:</p>
<pre class="brush: sql; title: ; notranslate">
*.db_name='ORCLDUP'
*.control_files='C:\ORACLE\ORADATA\ORCLDUP\control01.ctl,
C:\ORACLE\ORADATA\ORCLDUP\control02.ctl, C:\ORACLE\ORADATA\ORCLDUP\control03.ctl'
</pre>
<p><strong>2) Create Password file</strong></p>
<p>Copy the password file to the target server, rename it in the below format, this is the easiest method; you can always create the same with orapwd utility.</p>
<pre class="brush: plain; light: true; title: ; notranslate">
Unix Servers: orapw&lt;SID&gt;&lt;sid&gt;.ora
Windows Servers: PWD&lt;SID&gt;&lt;sid&gt;.ora
</pre>
<p><strong>3) Create Oracle related services (Required for Oracle on Windows only)<br />
</strong><br />
Use Oradim utility to create an Oracle service on Windows servers., this step is not applicable for Unix servers.</p>
<pre class="brush: powershell; title: ; notranslate">
oradim -new -sid orcldup -srvc oracleserviceorcldup
</pre>
<p><strong>4) Create directories for database files</strong></p>
<p>Create the required directories on the target server for datafiles, redo logs, control files, temporary files etc, this example assumes that all the database files will be stored under ‘C:ORACLEORADATAORCLDUP&#8217;</p>
<p><strong>5) Configure listener to user static service registration</strong></p>
<p>Static service registration for the listener must be done on the target server, this is because the database instance in NOMOUNT state (auxiliary instance before cloning) will not allow database connections, it will be BLOCKED. To configure static service registration with the listener, update the listener.ora file as below. Please note that, in this example the target and auxiliary instances are on the same server.</p>
<pre class="brush: plain; title: ; notranslate">
SID_LIST_LISTENER =
(SID_LIST = (SID_DESC =
(ORACLE_HOME = C:\oracle\product\11.1.0\db_1)
(SID_NAME = ORCL))
(SID_DESC = (ORACLE_HOME = C:oracle\product\11.1.0\db_1)
(SID_NAME = ORCLDUP))
)
</pre>
<p><strong>6) Reload the listener</strong></p>
<pre class="brush: sql; title: ; notranslate">
lsnrctl reload;
</pre>
<p><strong>7) Start and verify the auxiliary instance</strong></p>
<p>Start the auxiliary instance; verify the parameters db_name and control_files.</p>
<pre class="brush: sql; title: ; notranslate">

SQL&gt; show parameter db_name;
SQL&gt; show parameter control_files;
</pre>
<p><strong>8) Perform Oracle 11g Active database duplication</strong></p>
<pre class="brush: sql; title: ; notranslate">
RMAN&gt;
run {
SET NEWNAME FOR DATAFILE 1 TO 'C:\ORACLE\ORADATA\ORCLDUP\SYSTEM01.DBF';
SET NEWNAME FOR DATAFILE 2 TO 'C:\ORACLE\ORADATA\ORCLDUP\SYSAUX01.DBF';
SET NEWNAME FOR DATAFILE 3 TO 'C:\ORACLE\ORADATA\ORCLDUP\UNDOTBS01.DBF';
SET NEWNAME FOR DATAFILE 4 TO 'C:\ORACLE\ORADATA\ORCLDUP\USERS01.DBF';
SET NEWNAME FOR DATAFILE 5 TO 'C:\ORACLE\ORADATA\ORCLDUP\EXAMPLE01.DBF';
SET NEWNAME FOR TEMPFILE 1 TO 'C:\ORACLE\ORADATA\ORCLDUP\TEMP01.DBF';
duplicate target database to orcldup from active database;
}
</pre>
<p><strong>9) Logs</strong></p>
<p><a href="http://dbapundits.com/upload/11g_duplicate_log.txt">Oracle 11g Active database duplication Log</a></p>
<p><strong>10) References</strong></p>
<p>&nbsp;</p>
<p><a href="http://download.oracle.com/docs/cd/B28359_01/backup.111/b28270/rcmdupdb.htm">Oracle documentation on RMAN database duplication</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.dbapundits.com%2Fblog%2Fstep-by-step%2Foracle-11g-active-database-duplication%2F&amp;title=Oracle%2011g%20active%20database%20duplication%20on%20Unix%2FWindows" id="wpa2a_4"><img src="http://www.dbapundits.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.dbapundits.com/blog/step-by-step/oracle-11g-active-database-duplication/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

