Oracle RMAN Cheat Sheet

RMAN> CONNECT TARGET /
RMAN> SHOW ALL;
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/u01/app/rmanbackup/%F’;
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   ‘/u01/app/rmanbackup/%U’;
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM ‘AES128’; # default
CONFIGURE COMPRESSION ALGORITHM ‘BASIC’ AS OF RELEASE ‘DEFAULT’ OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO ‘/u01/app/oracle/product/11.1/dbs/snapcf_ibm.f’; # default
RMAN> backup database plus archivelog;
Incremental Backup :
RMAN> BACKUP INCREMENTAL LEVEL 0 DATABASE;
RMAN> BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;
RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE;
Recovery Strategy dengan Tag Name :
RMAN> BACKUP INCREMENTAL LEVEL 1 FOR RECOVER oF COPY WITH TAG ‘incr_update’ DATABASE;
RMAN> RECOVER COPY OF DATABASE WITH TAG ‘incr_update’;
Validasi Data yang sudah dibackup, apakah Corrupt :
RMAN> BACKUP VALIDATE CHECK LOGICAL DATABASE ARCHIVELOG ALL;
Lihat Data yang sudah dibackup :
RMAN> LIST BACKUP OF DATABASE;
Lihat Report :
RMAN> REPORT OBSOLETE ;
RMAN> REPORT SCHEMA ;
Hapus backup yang Obsolete :
RMAN> LIST BACKUP OF DATABASE;
Jika ada Failure di database :
RMAN> LIST FAILURE;
RMAN> ADVISE FAILURE;
RMAN> REPAIR FAILURE;
 
Mekaniesme Recovery :
RMAN> REPORT SCHEMA;
RMAN> RESTORE DATABASE PREVIEW SUMMARY;
To recover the whole database:
RMAN> STARTUP FORCE MOUNT;
RMAN> RESTORE DATABASE;
RMAN> RECOVER DATABASE;
RMAN> ALTER DATABASE OPEN;
To recover tha tablespace :
RMAN> SQL ‘ALTER TABLESPACE users OFFLINE’;
RMAN> RUN
{
SET NEWNAME FOR DATAFILE ‘/disk1/oradata/prod/users01.dbf’
TO ‘/disk2/users01.dbf’;
RESTORE TABLESPACE users;
SWITCH DATAFILE ALL; # update control file with new file names
RECOVER TABLESPACE users;
}
RMAN> SQL ‘ALTER TABLESPACE users ONLINE’;
Setting RMAN menggunakan TAPE :
CONFIGURE CHANNEL DEVICE TYPE sbt PARMS ‘SBT_LIBRARY=pathname’;
ex pathname = /opt/oracle/extapi/[32,64]/{SBT}/{VENDOR}/{VERSION}/libobk.a
RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE sbt
PARMS ‘SBT_LIBRARY=/mydir/lib/libobk.so,
ENV=(OB_DEVICE=drive1,OB_MEDIA_FAMILY=datafile_mf)’;
}
Example 5–7 Backing Up the Server Parameter File to Tape
RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE sbt
PARMS ‘SBT_LIBRARY=/mydir/lib/libobk.so,
ENV=(OB_DEVICE=drive1,OB_MEDIA_FAMILY=datafile_mf)’;
BACKUP SPFILE;
# If your database does not use a server parameter file, use:
# BACKUP CURRENT CONTROLFILE;
}
Example 5–8 Restoring the Server Parameter File from Tape
RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE sbt
PARMS ‘SBT_LIBRARY=/mydir/lib/libobk.so,
ENV=(OB_DEVICE=drive1,OB_MEDIA_FAMILY=datafile_mf)’;
RESTORE SPFILE TO PFILE ‘/tmp/test_restore.f’;
# If your database does not use a server parameter file, use:
# RESTORE CURRENT CONTROLFILE TO ‘/tmp/test_restore.f’;
}
Configuring Automatic SBT Channels
The easiest technique for backing up to a media manager is to configure automatic SBT channels.
1. Configure a generic SBT channel.
In the configuration, enter all parameters that you tested “Testing Backup and
Restore Operations on the Media Manager” on page 5-12. The following example
configures vendor-specific channel parameters and sets the default device:
CONFIGURE CHANNEL DEVICE TYPE sbt
PARMS ‘ENV=(OB_RESOURCE_WAIT_TIME=1minute,OB_DEVICE=tape1)’;
2. Configure the default device type to SBT, as shown in the following command:
CONFIGURE DEFAULT DEVICE TYPE TO sbt;
If you use multiple tape devices, then you must specify the channel parallelism as
described in “Configuring Parallel Channels for Disk and SBT Devices” on
page 5-5. The following configuration enables you to back up to two tape drives in
parallel:
CONFIGURE DEVICE TYPE sbt PARALLELISM 2;
Optionally, check your channel configuration by running the following command:
SHOW CHANNEL FOR DEVICE TYPE sbt;
3. Make a test backup to tape.
The following command backs up the server parameter file to tape:
BACKUP SPFILE;
4. List your backups to ensure that the test backup went to the media manager:
LIST BACKUP OF SPFILE;
 
Kalau RMAN melakukan Integrasi dengan ProtecTer VTL, maka :
When using Data Protection for Oracle to backup the data to a ProtecTier VTL, it is important that the data is not changed during the backup process so that deduplication can process the data effectively.
The recommendation is to ensure that files are not multiplexed within the backup data, as this can cause the data to appear unique, thereby limiting the amount of deduplication that can occur. The suggestion is to setup RMAN with FILESPERSET=1 so that each object will be sent individually. This would allow any files that have not changed and have existing (identical) data to achieve a higher deduplication ratio.
This suggestion for a value of FILESPERSET=1 is based on how Oracle will manage the data being backed up. Oracle takes the datafile blocks included in the same backup set and multiplexes them, which means that the data blocks from all of the datafiles in the backup set are interspersed with one another. ProtecTIER will have a better dedup ratio when the data is not multiplexed. and this multiplexing of the data can be avoided by limiting the backupset to have only 1 file within it (ie, FILESPERSET=1).
The Data Protection for Oracle product can accommodate the ProtecTIER suggested configuration within the RMAN script. For example a relatively generic script would contain the FILESPERSET parameter:
run
{
allocate channel t1 type ‘sbt_tape’ parms
‘ENV=(TDPO_OPTFILE=/ora11/tdpo.opt)’;
allocate channel t2 type ‘sbt_tape’ parms
‘ENV=(TDPO_OPTFILE=/ora11//tdpo.opt)’;
….. —-> allocate more channels here based on the number of sessions to be used for the backup
backup
FILESPERSET 1
(database);
}
 
RMAN Cheat Sheet : http://howtodba.com/rman-cheat-sheet/
http://www-01.ibm.com/support/docview.wss?uid=swg21509124
 
Salah satu contoh penggunaan RMAN untuk mengembalikan file2 yang hilang/corupt adalah sebagai berikut :

rman target /
RMAN> list backup recoverable;
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
——- —- — ———- ———– ———— —————
22      Full    9.36M      DISK        00:00:04     01-MAY-12
        BP Key: 22   Status: AVAILABLE  Compressed: NO  Tag: TAG20120501T001147
        Piece Name: +XFRA/xdb/autobackup/2012_05_01/s_782093507.299.782093509
  SPFILE Included: Modification time: 30-APR-12
  SPFILE db_unique_name: XDB
  Control File Included: Ckp SCN: 1222523      Ckp time: 01-MAY-12
  
RMAN> run {
2> set until scn 1222523;
3> restore database;
4> recover database;
5> }

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *