Rajkumar Yadav



Cloning a database using RMANContents:IntroductionPrerequisitesBackup based cloningActive database cloningCloning without target HYPERLINK "" \l "Cloning with recovery catalog" Cloning with recovery catalogIntroduction:RMAN has the ability to duplicate, or clone, a database from a backup or from an active?database. It is possible to create a duplicate database on a remote server with the same file?structure, a remote server will a different file structure or the local server with a different file?structure. The article assumes the duplicate database is being created on a separate server, using?the same SID (dev) and different file structure.Here on, dev will be referred to as ‘primary database’, and the server as ‘primary server’ and dev2,?dev3, dev4 will be referred as ‘auxiliary database’ and the server as ‘auxiliary server’ for ease of?understanding and to avoid confusion.Prerequisites:RMAN must be connected as AUXILIARY to the instance of the duplicate database. The?instance of the duplicate database is called the auxiliary instance. The auxiliary instance?must be started with the NOMOUNT option.An Oracle Home at the same version and patch level as the source databaseThe source and duplicate databases must be on the same platform. In the context of?duplicate, 32-bit and 64-bit versions of the same platform are considered the same?platform. However, after duplicating a database between 32-bit and 64-bit platforms, you?must run the utlirp.sql script to convert the PL/SQL code to the new format.?This script is?located in ORACLE_HOME/rdbms/admin on Linux.Types of RMAN cloning:(i) Backup based cloning:Startup the primary database and connect to RMAN and take a full backup with archive?logs using the following commands.$ rman target /RMAN> backup database plus archivelog;Create same file structure on the auxiliary server and copy the RMAN backup pieces?there as shown. Also create file structure for auxiliary database.??Create a password file using the syntax shown in the picture for the auxiliary instance.??Create pfile for the auxiliary instance and add convert parameters as shown in the picture?if you are using a different file system.?Create a listener on the auxiliary server as shown for RMAN to be able to access the?auxiliary database for duplication.??Add an entry in tnsnames.ora on primary server as shown below.Connect to the auxiliary instance and startup in nomount state.?On the primary server, using rman, connect to primary and auxiliary databases and issue?the command shown in the picture to complete the cloning process.?(ii)?Active database cloning:Oracle 11g introduced the ability to create duplicate databases directly without the need for a?backup. This is known as active database duplication. The process is similar to the backup-based?duplication, with a few exceptions. You don’t need a backup of the source system, but it does?have to be in ARCHIVELOG mode and the passwords in the password files must match for both?servers. Also, the destination server requires static listener configuration in a “listener.ora” file.Create file structure for auxiliary database.Create a password file using the syntax shown on the auxiliary side and primary side.On auxiliary:??On primary:?Create pfile for the auxiliary instance and add convert parameters as shown in the picture?if you are using a different file system.?Create a listener on the auxiliary server as shown for RMAN to be able to access the?auxiliary database for duplication.??Add an entry in tnsnames.ora on primary server as shown below.??Connect to the auxiliary instance and startup in nomount state.??With the duplicate database started we can now connect to it from RMAN. For the?duplication to work we must connect to the duplicate database (AUXILIARY), but?depending on the type of duplication we are doing we may optionally connect to the?original database (TARGET) and/or the recovery catalog (CATALOG). On the primary?server, using rman, connect to primary and auxiliary databases and issue the command?shown in the picture to complete the cloning process.?After successful completion of duplication following screen will be displayed,This completes active database cloning.?(iii) Cloning without target:Oracle 11gR2 comes with a great new feature where you can clone the database without?connecting to the target database and recovery catalog. So you can clone the database using only?backups of the database directly from the auxiliary server. For this, a new syntax, backup?location, was added to the duplicate command. In the following example, you will be shown the?steps of database duplication without target database connection and recovery catalog.Take backup of the target database and archivelogs.?Switch to the auxiliary server and create necessary folders for the backup files of the?target database and data files that will be restored. Then copy all backup files and p-file?from the target server to the auxiliary server.?After all files are copied, switch to the auxiliary server and On the Auxiliary server, edit?the p file that was copied earlier to the desired entries (dump locations, control file?location, data file locations, if using ASM then specify the desired disk group) and rename?it to the desired instance name file (init<SID>.ora).?Create a password file for the Auxiliary Database using the ORAPWD utility.$ orapwd file=/u01/app/oracle/product/11.2.0.1/dbs/orapwtestdb password=<mypassword>Connect to SQL*PLUS client and start the auxiliary database in no mount state as shown?below.?After the instance is started, connect to the auxiliary instance with RMAN and start?cloning the database. The duplication is done by specifying the location of the backup?pieces. The command to be used is DUPLICATE DATABASE TO ‘<auxiliary dbname>’?BACKUP LOCATION ‘<location of the backup pieces on the auxiliary server>’. It is?described in the picture below.? ? ? ? ? ? ? ? ? ? ? ? ??By running this command, RMAN starts automatically performing the following actions,Creates server parameter file and starts the database with it in no mount modeRestores the control file from backup and opens the database in mount modeRestores all data files and performs recoveryRecreates new control file in case you want to rename the name of the cloned databaseOpens database with reset logs option.?(iv) Cloning with recovery catalog:Recovery catalog is a database or repository of backup information of all the databases registered?with RMAN. Recovery catalog can either be created on a separate system or same system as?target database. Assuming “rcdb” is the name of your catalog database.?Follow the below steps to clone our primary database (DEV) to auxiliary database (dev5) using?catalog database (dev4).Create a recovery catalog database on the auxiliary server with database and sid names as?dev4.Configure a listener using NETCA or manually on the primary server and add the entries?in the tnsnames.ora file on both primary server and auxiliary server. Here, we are using?NETCA for creating a listener. The process of creating a listener using NETCA is?described using pictures below.?????????Now export ORACLE_SID of catalog database and connect to SQL*PLUS and check if?you are connected to recovery catalog database.??Now create a new user for recovery catalog, create a new tablespace and temporary?tablespace and assign those tablespaces to the user. Also grant connect, resource,?recovery catalog ownership privileges to that user.??Exit SQL*PLUS client and connect to RMAN using using the username and password?you created in the previous step.Create a catalog using ‘create catalog’ command to store all the backup information of all?the databases in it and exit the recovery manager.??Now create a listener on the auxiliary server using NETCA or manually by adding lines?in the listener.ora file and the entry in tnsnames.ora file on the primary server.??Add the following tns entry on the primary server,??Create required directories on the primary server for storing RMAN backups and on?auxiliary server for the database we are going to clone. In this case we are reusing the?directories we created for RMAN backups in the previous methods.?Now connect to the primary database and catalog from primary server, and use the below?command to register the target database with RMAN and hence forth any backup taken?on the target database gets registered in the recovery catalog. After registering take a?backup of the database and exit RMAN client.? ? ? ? ? ? ? ? ? ? ? ? ? ?Copy these backup pieces to same file system on the auxiliary server and copy the pfile?from primary database and add required parameters and also create a password file as?shown below.??To create a password file for the auxiliary instance,??As everything is configured now, connect to SQL*PLUS client and startup the auxiliary?database in nomount state and create a password file for the auxiliary instance.?Now connect to RMAN on primary using below illustrated command and issue duplicate?command to complete the duplication of primary database.? ? ? ? ? ? ? ? ? ? ? ?0? ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download