Friday, September 26, 2008

RMAN Process - From 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.