RMAN - DOC

Document Sample
RMAN - DOC Powered By Docstoc
					RMAN
***************************************************************************
***************



BEFORE
******

create tablespace vfrman datafile 'c:\oracle\oradata\vinc\vfrman.dbf'
size 50M extent management local uniform size 256K;


create user v identified BY V TEMPORARY TABLESPACE TEMP DEFAULT TABLESPACE
VFRMAN
QUOTA UNLIMITED ON VFRMAN;

GRANT RECOVERY_CATALOG_OWNER TO V;
GRANT CONNECT, RESOURCE TO V;


In remote, it is mandatory to set the following variables:
NLS_LANG=american
or better
NLS_LANG=american_america.WE8ISO8859P1 (If you are going to use RMAN to
connect to a non-mounted database or to recover a tablespace)
NLS_DATE_FORMAT='Mon DD YYYY HH24:MI:SS'




CREATE CATALOG
**************

** lors de l'installation de la bd par défaut de 9i le catalogue est deja
cree dans rman/rman

RMAN> CONNECT CATALOG V/V@VINC

RMAN> CREATE CATALOG TABLESPACE VFRMAN;



REGISTER DATABASE
*****************

rman target sys/sys@sworcl catalog v/v@vinc
or
(connect target sys/sys@sworcl
connect catalog v/v@vinc)

RMAN> register database;



RMAN REPORTS
************
RMAN> report schema;

RMAN> list backup;

RMAN> list copy;

RMAN> list incarnation;

RMAN> report obsolete;

RMAN> list backup of archivelog all;

RMAN> list backup of controlfile;

RMAN> report unrecoverable;

RMAN> list device type disk backupset of database;



Backing Up a database
*********************

run {
allocate channel ch1 type disk;
backup database
format 'F:\rmanbkup\vinc\%U';
}



Backing Up a Tablespace
************************

RMAN> run {
2> allocate channel c1 type disk;
3> backup tablespace system;
4> }



Making Incremental Backups
**************************

run {
allocate channel ch1 type disk;
backup
   incremental level = 0 database
   format 'F:\rmanbkup\vinc\%U';
}

run {
allocate channel ch1 type disk;
backup
   incremental level = 1 database
   format 'F:\rmanbkup\vinc\%U';
   backup current controlfile
}
Validating a Restore
********************

RMAN> run {
  allocate channel c1 type disk;
  validate backupset 3;          /*id OF THE BACKUPSET */
  }



Backing Up Archived Redo Logs
*****************************

run {
  allocate channel ch1 type disk;
  backup
    format = 'f:\rmanbkup\sworcl\arch_%U.bak'
    archivelog
    until time 'sysdate'
    delete input;
}

run {
  allocate channel ch1 type disk;
  backup
    format = 'f:\rmanbkup\sworcl\arch_%U.bak'
    archivelog all
    delete input;
}


Détruire un backup du repository et l'enlever de l'OS
******************************************************

Allocate channel for maintenance type disk;

or to change his status:
change backupset #### delete;
  "       "        " unavailable;
  "       "        " available;



recover A COMPLETE DATABASE
***************************

shutdown immediate;
startup mount pfile=d:\oracle\admin\sworcl\initsworcl.ora

run {
allocate channel ch1 type disk;
  restore database;
  recover database;
}



recover a TABLESPACE
********************
run {
allocate channel ch1 type disk;
  restore tablespace tools;
  recover tablespace TOOLS;
}



To recover a tablespace and move the datafile to a new location.
****************************************************************

run {
allocate channel ch1 type disk;
sql 'alter tablespace rmantest offline for recover';
set newname for datafile 10 to 'E:\oracle\oradata\SWORCL\rmantest.dbf';
restore tablespace rmantest;
switch datafile all;                                      # change the
datafile name in the control file.
recover tablespace rmantest;
sql 'alter tablespace rmantest online';
}


After a resetlog (new incarnation)
***********************************

reset database;



Crosscheck
**********

allocate channel for maintenance type disk;
list backup;
change backupset 1306, 1392 crosscheck;




starting Remote Database
************************

When using RMAN to startup up a remote target database you need to copy the
parameter file for the remote database from the target machine to the local
machine and then specify the pfile option to the startup command.




Scripts
*******


create script alloc_disk {
    # Allocates one disk
    allocate channel dev1 type disk;
    setlimit channel dev1 kbytes 2097150 maxopenfiles 32 readrate 200;
    }

replace script rel_disk {
        # releases disk
        release channel dev1;
    }


replace script b_whole{
     # Performs a complete backup
     execute script alloc_disk;
     backup database format 'F:\rmanbkup\vinc\%U';
     backup current controlfile;
     sql 'ALTER SYSTEM ARCHIVE LOG ALL';
     backup archivelog all;
     execute script rel_disk;
}


---> run {
        execute script b_whole;
     }


Dynamic V$iew:
 select * from rc_stored_script_line
     order by script_name, line;



TROUBLESHOOTING:
****************

ERROR: RMAN-01005: resync got ORA-1220, retrying with sort_area_size = 1MB
SOLUTION : Comment out SORT_AREA_SIZE and SORT_AREA_RETAINED_SIZE from
init.ora



*PLUS**PLUS**PLUS**PLUS**PLUS**PLUS**PLUS**PLUS**PLUS**PLUS**PLUS**PLUS**PL
US*


Backing up in archivelog mode
*****************************

1. Backing up archived logs

#backs up all archive logs:
run {
    allocate channel dev1 type disk;
    backup
    format 'F:\rmanbkup\vinc\log_t%t_s%s_p%p' (archivelog all);
    release channel dev1;
    }

#backs up archive logs from sequence# 90 to 100:

    RMAN> run {
    2> allocate channel dev1 type disk;
    3> backup
    4> format '/oracle/backups/log_t%t_s%s_p%p'
    5> (archivelog from logseq=90 until logseq=100 thread 1);
    6> release channel dev1;
    7> }

The following script backs up all archive logs generated in the past
24 hours. Furthermore it actually deletes the logs after backing them
up. If the backup fails, logs will NOT be deleted:

    RMAN> run {
    2> allocate channel dev1 type disk;
    3> backup
    4> format '/oracle/backups/log_t%t_s%s_p%p'
    5> (archivelog from time 'sysdate-1' all delete input);
    6> release channel dev1;
    7> }

To view the archive logs in the catalog, use the following command:

    RMAN> list backupset of archivelog all;

Note that RMAN will backup   specified logs if it finds them. If it can't
find a log, it will report   rman-6089 error:
"archived log %s not found   or out of sync with catalog",
and it will abort a backup   session.


2. Backing up the online logs

Online logs CANNOT be backed up using RMAN; they must be archived first.
To do this, you can issue SQL commands from RMAN e.g.

    RMAN> run {
    2> allocate channel dev1 type disk;
    3> sql "alter system archive log current";
    4> backup
    5> format '/oracle/backups/log_t%t_s%s_p%p'
    6> (archivelog from time 'sysdate-1' all delete input);
    7> release channel dev1;
    8> }

The above script might be run after performing a full 'database open'
backup. It would ensure that all redo to recover the database to a
consistent state would be backed up.

Note, you cannot tag archive log backupsets.


Recovery
********

1. Database open, datafile deleted

Datafile has been deleted from a running database. There are two methods
of open database recovery: restore the datafile and recover either the
datafile, or the tablespace. The next two examples show both methods:

(a) Datafile recovery

    RMAN> run {
    2> allocate channel dev1 type disk;
    3> sql "alter tablespace users offline immediate";
    4> restore datafile 4;
    5> recover datafile 4;
    6> sql "alter tablespace users online";
    7> release channel dev1;
    8> }

(b) Tablespace recovery

    RMAN> run {
    2> allocate channel dev1 type disk;
    3> sql "alter tablespace users offline immediate";
    4> restore tablespace users;
    5> recover tablespace users;
    6> sql "alter tablespace users online";
    7> release channel dev1;
    8> }

Note that if it is the system tablespace datafiles to be restored, the
database must be closed. It is not possible to offline the system
tablespace.


2. Complete restore (lost online redo) and rollforward - database closed

    RMAN> run {
    2> allocate channel dev1 type disk;
    3> set until logseq=105 thread=1;
    4> restore controlfile to '/oracle/dbs/ctrltargdb.ctl';
    5> replicate controlfile from '/oracle/dbs/ctrltargdb.ctl';
    6> restore database;
    7> sql "alter database mount";
    8> recover database;
    9> sql "alter database open resetlogs";
    10> release channel dev1;
    11> }
    RMAN> reset database;
Notes:
- The 'set until' command dictates at which log sequence recovery will
stop. It is critical that this command is issued BEFORE datafiles
are restored, otherwise RMAN will attempt to restore the most recent
set of datafiles, which could be ahead of the specified log
- The 'replicate controlfile' copies the restored controlfile to
the controlfiles referenced in init.ora
- Because the database is opened with resetlogs, it is necessary to
register the new incarnation of the database with the RESET DATABASE
command. As with v7, it is important to take a full backup of the
database immediately after a resetlogs

3. Restore of a subset of datafiles, complete recovery

    RMAN> run {
    2> allocate channel dev1 type disk;
    3> sql "alter database mount";
    4> restore datafile 2;
    5> restore datafile 3;
    6> restore archivelog all;
    7> recover database;
    8> sql "alter database open";
    9> release channel dev1;
    10> }
Hints, tips, & best practices
*****************************

1. Resyncing the recovery catalog

The following sample shell script could be scheduled to
run hourly:

    rman target un/pw@<target alias> rcvcat un/pw@<rcvcat alias> << EOF
    resync catalog;
    exit;
    EOF


2. Deleting archive logs

As can be seen from an earlier example, it is possible to direct an SMR
server session to delete archived redo logs once they have been backed
up. This option should obviously be used with extreme caution! Only
ever delete archivelogs if you are 100% satisfied that you have good
copies/backups elsewhere.


3. Divers

Récupérer le return code sous windows - Sous unix $status
ou bien le RMAN-00569: ERROR

Set DB_FILE_DIRECT_IO_COUNT to set the size of the buffer   (for the
compression block)

Oracle can catalog an image copy and read the metadata, Only image copies
and archived logs can be cataloged

A la fin d'un backup checker V$BACKUP_CORRUPTION et v$copy_corruption



Vincent FENOLL (FR/EXT-DSIF-FOCAL)
15 avenue Louis Armand
95124 Ermont

Tel: 20 83 70
vincent.fenoll@acsi.com

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:14
posted:11/1/2011
language:
pages:8