Você está na página 1de 5

RMAN Basic Commands RMAN COLD backup RMAN> run { sql 'alter database close'; allocate channel d1 type

disk; backup full tag full_offline_backup format '/oracle/backup/db_t%t_s%s_p%p' (database); release channel d1; sql 'alter database open'; } Individual Tablespace Backup RMAN> run { allocate channel d1 type disk; backup tag tbs_users_read_only format '/backups/tbs_users_%t_%s' (tablespace users); release channel d1; } Backup all archive logs RMAN> run { allocate channel d1 type disk; backup format '/backups/log_t%t_s%s_p%p' (archivelog all); release channel d1; }

Backup Database with Archivelog and delete the archivelog after backup RUN { ALLOCATE CHANNEL d1 DEVICE TYPE disk; BACKUP Format /backups/db_full_%t_%s (DATABASE PLUS ARCHIVELOG ALL DELETE INPUT); Release channel d1; } Perform a point-in-time recovery RUN { ALLOCATE CHANNEL d1 DEVICE TYPE disk;

ALLOCATE CHANNEL d2 DEVICE TYPE disk; ALLOCATE CHANNEL d3 DEVICE TYPE disk; SET UNTIL TIME = '2007-02-27:09:00:00'; RESTORE DATABASE; RECOVER DATABASE; SQL 'alter database open resetlogs'; } Restore a tablespace RUN { SQL "ALTER TABLESPACE users OFFLINE IMMEDIATE"; RESTORE TABLESPACE tools; RECOVER TABLESPACE tools; SQL "ALTER TABLESPACE tools ONLINE"; } Crosscheck If the archivelogs are moved/deleted/compressed, then archivelog backup would error out with the following error RMAN-06059, either bring back the archive logs or do the following to clear them out run { allocate channel c1 type disk ; crosscheck archivelog all ; release channel c1 ; } To check the validity of database backup and archivelog files

Checks physical corruptions RMAN> BACKUP VALIDATE DATABASE ARCHIVELOG ALL; Checks logical corruptions RMAN> BACKUP VALIDATE CHECK LOGICAL DATABASE ARCHIVELOG ALL;

Important RMAN Commands To see status information on jobs in V$RMAN_STATUS use the following query: SELECT OPERATION, STATUS, MBYTES_PROCESSED, START_TIME, END_TIME from V$RMAN_STATUS; To correlate a channel with a process, run the following query in SQL*Plus while the RMAN job is executing:

SQL> SQL> SQL> SQL>

COLUMN COLUMN COLUMN SELECT WHERE

CLIENT_INFO FORMAT a30 SID FORMAT 999 SPID FORMAT 9999 s.SID, p.SPID, s.CLIENT_INFO FROM V$PROCESS p, V$SESSION s p.ADDR = s.PADDR AND CLIENT_INFO LIKE 'rman%';

To calculate the progress of an RMAN job, run the following query in SQL*Plus while the RMAN job is executing: SQL> SELECT SID,SERIAL#,CONTEXT,SOFAR,TOTALWORK, ROUND(SOFAR/TOTALWORK*100,2) "% COMPLETE" FROM V$SESSION_LONGOPS WHERE OPNAME LIKE 'RMAN%' AND OPNAME NOT LIKE '%aggregate%' AND TOTALWORK != 0 AND SOFAR <> TOTALWORK;

A row in V$SESSION_WAIT corresponding to an sbt event name does not indicate a problem, because the server updates these rows at runtime. The rows appear and disappear as calls are made and returned. However, if the SECONDS_IN_WAIT column is high, then the media manager may be hung. To monitor the sbt events, you can run the following SQL query: COLUMN COLUMN COLUMN COLUMN EVENT FORMAT a10 SECONDS_IN_WAIT FORMAT 999 STATE FORMAT a20 CLIENT_INFO FORMAT a30

SELECT p.SPID, EVENT, SECONDS_IN_WAIT AS SEC_WAIT, sw.STATE, CLIENT_INFO FROM V$SESSION_WAIT sw, V$SESSION s, V$PROCESS p WHERE sw.EVENT LIKE 's%bt%' AND s.SID=sw.SID AND s.PADDR=p.ADDR ; This example lists all backups in default verbose mode: RMAN> LIST BACKUP; The following example lists a summarized version of all RMAN backups: RMAN> LIST BACKUP SUMMARY; This example groups all backups by file: RMAN> LIST BACKUP BY FILE;

Control File V$ View V$ARCHIVED_LOG V$BACKUP_DATAFILE V$BACKUP_CORRUPTION V$BACKUP_DATAFILE V$BACKUP_FILES V$BACKUP_PIECE V$BACKUP_REDOLOG V$BACKUP_SET V$BACKUP_SPFILE V$DATAFILE_COPY V$COPY_CORRUPTION V$DATABASE

Recovery Catalog View RC_ARCHIVED_LOG RC_BACKUP_CONTROLFILE RC_BACKUP_CORRUPTION RC_BACKUP_DATAFILE RC_BACKUP_FILES RC_BACKUP_PIECE RC_BACKUP_REDOLOG RC_BACKUP_SET RC_BACKUP_SPFILE RC_CONTROLFILE_COPY RC_COPY_CORRUPTION RC_DATABASE

View Describes Archived and unarchived redo logs Control files in backup sets Corrupt block ranges in datafile backups Datafiles in backup sets RMAN backups and copies in the repository. Backup pieces Archived logs in backups Backup sets Server parameter files in backup sets Control file copies on disk Information about datafile copy corruptions Databases registered in the recovery catalog (RC_DATABASE) or information about the currently mounted database (V$DATABASE)

V$DATABASE_BLOCK_CORRUPTION RC_DATABASE_BLOCK_CORRUPTION Database blocks marked as corrupt in the most recent RMAN backup or copy V$DATABASE_INCARNATION V$DATAFILE V$DATAFILE_COPY V$LOG_HISTORY V$OFFLINE_RANGE V$PROXY_ARCHIVEDLOG V$PROXY_CONTROLFILE V$PROXY_DATAFILE V$LOG and V$LOGFILE RC_DATABASE_INCARNATION RC_DATAFILE RC_DATAFILE_COPY RC_LOG_HISTORY RC_OFFLINE_RANGE RC_PROXY_ARCHIVEDLOG RC_PROXY_CONTROLFILE RC_PROXY_DATAFILE RC_REDO_LOG All database incarnations registered in the catalog All datafiles registered in the recovery catalog Datafile image copies Historical information about online redo logs Offline ranges for datafiles Archived log backups created by proxy copy Control file backups created by proxy copy Datafile backups created by proxy copy Online redo logs for all incarnations of the database since the last catalog resynchronization All redo threads for all incarnations of the database since the last

V$THREAD

RC_REDO_THREAD

Control File V$ View

Recovery Catalog View

View Describes catalog resynchronization

n/a V$RMAN_CONFIGURATION V$TABLESPACE

RC_RESYNC RC_RMAN_CONFIGURATION RC_TABLESPACE

Recovery catalog resynchronizations RMAN persistent configuration settings All tablespaces registered in the recovery catalog, all dropped tablespaces, and tablespaces that belong to old incarnations

Você também pode gostar