Welcome to Oracle Database Administrator Home

24x7 oracle database support and solutions
Oracle DBA Home     Routine Maintenance     PostgreSQL     Unix Commands     CVS     Oracle FAQ     Oracle Concepts     SQLPlus     OEM     ASM     Data Guard     RAC     RMAN     Networking     OAS     Partitioning      

RMAN - START to FINISH

 

To illustrate it, Let us explain it with an example. Let us backup our PRODUCTION database using RMAN.

 

C$>rman
rman>connect target /
rman>backup database;

 

That's it.

 

Let us explian the above example.

 

RMAN makes the bequeath connection to the target database that we have set up in our env. This means it checks the ORACLE_SID for an instance name and then spawns a server process at that instance, logging is as SYSDBA user. This connects us as the internal database user SYS. RMAN immediately spawns the channel processes that will use to perform the backup. In this case we are using default settings, so only one channel is allocated.

 

We are not using I/O slaves, so the process allocates memory in the PGA.

 

Next RMAN compilesa call to sys.dbms_rcvman to request the database schematic information from the target database control file, starting with a determination of the target database version. It gathers version information from the control files along with control file information itself like type of control file, current sequence number, when it was created etc.

 

Becuse this is a full backup, RMAN requests information for each datafile in the database and determines if any files are offline. RMAN ignores all disk affinity information and concentartes on compiling the list of files for inclusion in the backupset.

 

After the list is compiled, RMAN is ready to begin the backup process itself. To guarantee consistency, it the builds a snapshot control files, if one already exists it overwrites it with a new one.

 

After this RMAN creates a call to the DBMS_BACKUP_RESTORE package to create a backup piece. The backup piece will be built in the default file location.

 

RMAN has the file list, so it can allocate the memory buffers for performing the read from DISK, with 20 files RMAN allocates input buffer size 128 MB . 4 per file for total memory utilzation of 10 MB for input buffers. RMAN will only allocate 4 output buffers each of size 1 MB. This brings the total memory utilization 14MB for the backup.

 

After the memory is allocated, RMAN initilize the BACKUP PIECE. backup piece will be given unique name that guarnatees uniqueness.

RMAN then determines if there will be enough space for backup to be successful. It does by using a pessimistic algorithm that assumes that backup will be the same size as sum of the size of all the datafiles. Due to null compression this will not be the case.

 

Once the backup piece is initiated, then the channel process can begin the database backup process.
a) If you are using spfile, it backs it up automatically to the backupset,
b) RMAN then will backup the current control file to the backupset,
This control file backup is automatic whenever the SYSTEM tablespace is backed up, this behaviour is changed if you have CONTROL FILE AUTOBABKUP turned on.


c) Now its time to begin the datafile reads to pull data blocks into the memory. The channel process does this by doing a read-ahead on the disk and pulling several blocks into memeory at the same time. then memory-to-memory write from input buffer to output buffer occurs.

During this write, RMAN determines if the block has ever been initialized, or block header information is still zeroed out. If it is an unused block, the write to the output buffer never occur and the block is discarded. If the block has been used, RMAN performs the checksum on the block. If the header and footer of the block did not match, RMAN indicates a corrupt block and aborts the backup. If the block has been initialized and it passes the checksum, then the block is written into output buffer.

 

Once the output buffers fills its capacity, we dump the buffer to the backup file location.

 

RMAN buffers are being filled up with blocks from all the datafiles so there is no order to the blocks in the dump file.

 

While the blocks are being written out to backup piece, the status of the backup is being polled by the RMAN shadow process. It checks in on the RPCs at the target and passes the information to v$session_lonops for your review.

 

Once every block in the datafile has been read into an output buffer and its status determines, then RMAN completes the file backup by writing the datafile header out to the backup piece.

 

After all the files have their file headers written to the backup piece, RMAN makes a final call to sys.dbms_backup_restore which writes backup information to the control files. This information includes the name of the backup piece, the checkpoint SCN at the time it started and the time it completed.

 

And that it.

 

Duplicate a Database Using RMAN 

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.

 

Step1: Create a password file for the duplicate instance

orapwd file=/u01/app/oracle/product/9.2.0.1.0/dbs/orapwDUP password=password entries=10

 

Step2: add the appropriate entries into the tnsnames.ora and listener.ora files in the $ORACLE_HOME/network/admin directory. Remember to load the new configuration into the listener:

# Added to the listener.ora SID_LIST
(SID_DESC =
  (ORACLE_HOME = /u01/app/oracle/product/9.2.0.1.0)
  (SID_NAME = DUP)
)

# Added to the tnsnames.ora
DUP =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)
(HOST = server1.tshcomputing.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (ORACLE_SID = DUP)
    )
  )

# Reload listener
lsnrctl reload
create an init.ora file for the duplicate database. 
Since we are duplicating the database onto the same 
server as the original we must convert the file 
names so there is no conflict:
# Minimum Requirement.
DB_NAME=DUP
CONTROL_FILES=(/u02/oradata/DUP/control01.ctl,
               /u02/oradata/DUP/control02.ctl,
               /u02/oradata/DUP/control03.ctl)

# Convert file names to allow for different directory structure.
DB_FILE_NAME_CONVERT=(/u02/oradata/TSH1/,/u02/oradata/DUP/)
LOG_FILE_NAME_CONVERT=(/u01/oradata/TSH1/,/u01/oradata/DUP/)

# make sure block_size and compatible parameters
# match if you are not using the default.
DB_BLOCK_SIZE=8192
COMPATIBLE=9.2.0.0.0
 
Next we connect to the duplicate instance:
ORACLE_SID=DUP; export ORACLE_SID
sqlplus /nolog
conn / as sysdba
Next we create an SPFILE based on the init.ora:
CREATE SPFILE FROM PFILE='/u01/app/oracle/admin/DUP/pfile/init.ora';
 
Next we start the database in NOMOUNT mode:
STARTUP FORCE NOMOUNT;
With the duplicate database started we can now connect to it from RMAN. 
For the duplication to work we must connect to the original database 
(TARGET), the recovery catalog (CATALOG) and our duplicate database 
(AUXILIARY): 
ORACLE_SID=DUP; export ORACLE_SID
rman TARGET sys/password@tsh1 CATALOG rman/rman@tshadm AUXILIARY /
 
We can then dupicate the database using one of the following commands:
 
 
# Duplicate database to TARGET's current state.
DUPLICATE TARGET DATABASE TO DUP;

# Duplicate database to TARGET's state 4 days ago.
DUPLICATE TARGET DATABASE TO DUP UNTIL TIME 'SYSDATE-4';
The time it takes to complete varies depending on the size of 
the database and the specification of the server. Once the 
process is finished RMAN produces a completion message 
and you have your duplicate instance.