dba:oracle:docs:rman_basic_querys
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Last revisionBoth sides next revision | ||
dba:oracle:rman_basic_querys [2022/02/11 11:12] – ↷ Page moved from oracle:rman_basic_querys to dba:oracle:rman_basic_querys dodger | dba:oracle:docs:rman_basic_querys [2023/01/31 08:22] – removed - external edit (Unknown date) 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | |||
- | ====== [DOC] RMAN Basic queries ====== | ||
- | ===== Very basics commands ===== | ||
- | ==== Connect user OS auth ==== | ||
- | * '' | ||
- | |||
- | ==== Logging commands ==== | ||
- | This will display NO OUTPUT: | ||
- | * '' | ||
- | |||
- | So the best way is use tee: | ||
- | * '' | ||
- | |||
- | |||
- | ==== Using a script ==== | ||
- | Like SQL*: | ||
- | * '' | ||
- | |||
- | ==== Checking Syntax ==== | ||
- | When checking syntax, nothing is executed (test/ | ||
- | * '' | ||
- | |||
- | |||
- | |||
- | ===== Listar ===== | ||
- | ==== Configuration ==== | ||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | |||
- | |||
- | ==== Backups ==== | ||
- | <code sql>list backup ;</ | ||
- | O un poco más resumido: | ||
- | <code sql>list backup summary ;</ | ||
- | |||
- | ==== backupsets ==== | ||
- | by tag | ||
- | <code sql>LIST BACKUPSET TAG ' | ||
- | </ | ||
- | by date | ||
- | <code sql> list backupset completed after ' | ||
- | </ | ||
- | |||
- | ==== Backups Obsoletos ==== | ||
- | <code sql>list expired backup ;</ | ||
- | o | ||
- | <code sql>list expired backup summary ;</ | ||
- | ==== Archivers ==== | ||
- | <code sql>LIST ARCHIVELOG ALL; | ||
- | </ | ||
- | ==== Backup de Archivers ==== | ||
- | <code sql>LIST BACKUP OF ARCHIVELOG ALL; | ||
- | </ | ||
- | Summary; | ||
- | <code sql> | ||
- | LIST BACKUP OF ARCHIVELOG ALL SUMMARY; | ||
- | </ | ||
- | |||
- | http:// | ||
- | <code sql> | ||
- | col filesize_display format a20 | ||
- | SELECT BTYPE, | ||
- | BTYPE_KEY, | ||
- | SESSION_KEY, | ||
- | SESSION_RECID, | ||
- | SESSION_STAMP , | ||
- | ID1 , | ||
- | ID2 , | ||
- | THREAD#, | ||
- | SEQUENCE#, | ||
- | RESETLOGS_CHANGE#, | ||
- | RESETLOGS_TIME , | ||
- | FIRST_CHANGE# | ||
- | FIRST_TIME , | ||
- | NEXT_CHANGE# | ||
- | NEXT_TIME , | ||
- | FILESIZE , | ||
- | COMPRESSION_RATIO , | ||
- | FILESIZE_DISPLAY | ||
- | FROM V$BACKUP_ARCHIVELOG_DETAILS | ||
- | ORDER BY sequence# | ||
- | ; | ||
- | </ | ||
- | ==== Fichero de backup de Archiver ==== | ||
- | <code sql>LIST COPY OF DATABASE ARCHIVELOG ALL; | ||
- | </ | ||
- | |||
- | ==== Backup de datafile ==== | ||
- | <code sql>LIST BACKUP OF DATAFILE 1; | ||
- | </ | ||
- | |||
- | ==== Backup por fichero ==== | ||
- | <code sql>LIST BACKUP BY FILE; | ||
- | </ | ||
- | |||
- | ==== Datafilecopy ==== | ||
- | <code sql>list datafilecopy all; | ||
- | </ | ||
- | |||
- | ==== BBDD Incarnation ==== | ||
- | <code sql>LIST INCARNATION; | ||
- | </ | ||
- | |||
- | ==== Fallos ==== | ||
- | <code sql>LIST FAILURE; | ||
- | </ | ||
- | Detalles: | ||
- | <code sql>LIST FAILURE 641231 detail;</ | ||
- | |||
- | ===== CROSSCHECK ===== | ||
- | Crosscheck actualiza la bbdd de backups respecto a lo que realmente hay o explicado por oracle: | ||
- | |||
- | //The CROSSCHECK command synchronizes the logical records of RMAN backups and copies with the files on storage media. If a backup is on disk, then CROSSCHECK determines whether the header of the file is valid. If a backup is on tape, then RMAN queries the RMAN repository for the names and locations of the backup pieces. It is a good idea to crosscheck backups and copies before deleting them.// | ||
- | |||
- | ==== Backup ==== | ||
- | <code sql> | ||
- | </ | ||
- | <code sql> | ||
- | </ | ||
- | <code sql> | ||
- | </ | ||
- | ==== Copy ==== | ||
- | <code sql> | ||
- | </ | ||
- | ==== Archivelog ==== | ||
- | <code sql> | ||
- | </ | ||
- | |||
- | ===== Report ===== | ||
- | REPORT analiza qué ha cambiado e indica de qué ha de hacerse backup: | ||
- | |||
- | ^ Comando ^ Descripción ^ | ||
- | | '' | ||
- | | '' | ||
- | | '' | ||
- | | '' | ||
- | |||
- | |||
- | ===== Borrado ===== | ||
- | |||
- | ==== Forzar el borrado de backups antiguos ==== | ||
- | <code sql> | ||
- | |||
- | ==== Borrar TODOS los archivers de la FRA ==== | ||
- | CUIDADO CON ESTE COMANDO!!!! | ||
- | <code sql> | ||
- | DELETE ARCHIVELOG ALL ; | ||
- | </ | ||
- | |||
- | ==== Borrar TODOS los archivers de la FRA a sysdate-1 ==== | ||
- | CUIDADO CON ESTE COMANDO!!!! | ||
- | <code sql> | ||
- | DELETE ARCHIVELOG ALL COMPLETED BEFORE ' | ||
- | </ | ||
- | |||
- | ==== Borrar backups obsoletos ==== | ||
- | Después del crosscheck... | ||
- | <code sql> | ||
- | delete force noprompt expired backup ; | ||
- | </ | ||
- | |||
- | ==== Borrar backup por tag ==== | ||
- | Después del crosscheck... | ||
- | <code sql> | ||
- | DELETE BACKUP TAG ' | ||
- | </ | ||
- | |||
- | |||
- | ==== Borrar datafilecopy ==== | ||
- | Todo: | ||
- | <code sql> | ||
- | DELETE datafilecopy all; | ||
- | </ | ||
- | |||
- | By key: | ||
- | <code sql> | ||
- | DELETE datafilecopy <key> ; | ||
- | </ | ||
- | |||
- | by name: | ||
- | <code sql> | ||
- | DELETE datafilecopy ' | ||
- | </ | ||
- | |||
- | ===== Examples ===== | ||
- | ==== Restoring spfile from backup ==== | ||
- | * Connect: | ||
- | <code sql>$ rman</ | ||
- | <code sql> | ||
- | CONNECT TARGET / | ||
- | </ | ||
- | * If your database is not up and you don't use recovery catalog then use: | ||
- | <code sql>SET DBID 3386862614</ | ||
- | * Start the instance with dummy parameter file: | ||
- | <code sql> | ||
- | * Restore server parameter file to restore in default location: | ||
- | <code sql> | ||
- | * or restore in another location: | ||
- | <code sql> | ||
- | * If you want to restore to a pfile then use: | ||
- | <code sql> | ||
- | * Start the instance: | ||
- | <code sql> | ||
- | |||
- | ===== Validar ===== | ||
- | [[http:// | ||
- | |||
- | ==== la bbdd completa ==== | ||
- | <code sql> | ||
- | |||
- | ==== backupset ==== | ||
- | <code sql> | ||
- | |||
- | ==== Datafile ==== | ||
- | <code sql> | ||
- | | ||
- | </ | ||
- | |||
- | ====== SQL* ====== | ||
- | |||
- | ===== Status of the backups inside oracle ===== | ||
- | |||
- | Clean (only backup ops): | ||
- | <code sql> | ||
- | SET LINESIZE 280 | ||
- | COL OUTPUT_DEVICE_TYPE FORMAT A30 | ||
- | COL COMMAND_ID FORMAT A20 | ||
- | COL STATUS FORMAT A30 | ||
- | COL OPERATION FORMAT A60 | ||
- | |||
- | SELECT | ||
- | RECID, | ||
- | STAMP, | ||
- | PARENT_RECID, | ||
- | PARENT_STAMP, | ||
- | SESSION_RECID, | ||
- | SESSION_STAMP, | ||
- | -- COMMAND_ID, | ||
- | OPERATION, | ||
- | STATUS, | ||
- | MBYTES_PROCESSED, | ||
- | START_TIME, | ||
- | END_TIME, | ||
- | OPTIMIZED, | ||
- | OBJECT_TYPE, | ||
- | OUTPUT_DEVICE_TYPE | ||
- | FROM V$RMAN_STATUS | ||
- | WHERE NOT OPERATION IN (' | ||
- | order by start_time | ||
- | ; | ||
- | </ | ||
- | |||
- | All: | ||
- | <code sql> | ||
- | SET LINESIZE 280 | ||
- | COL OUTPUT_DEVICE_TYPE FORMAT A30 | ||
- | COL COMMAND_ID FORMAT A20 | ||
- | COL STATUS FORMAT A30 | ||
- | COL OPERATION FORMAT A60 | ||
- | |||
- | SELECT | ||
- | RECID, | ||
- | STAMP, | ||
- | PARENT_RECID, | ||
- | PARENT_STAMP, | ||
- | SESSION_RECID, | ||
- | SESSION_STAMP, | ||
- | -- COMMAND_ID, | ||
- | OPERATION, | ||
- | STATUS, | ||
- | MBYTES_PROCESSED, | ||
- | START_TIME, | ||
- | END_TIME, | ||
- | OPTIMIZED, | ||
- | OBJECT_TYPE, | ||
- | OUTPUT_DEVICE_TYPE | ||
- | FROM V$RMAN_STATUS | ||
- | order by start_time | ||
- | ; | ||
- | </ | ||
- | |||
- | |||
- | |||
- | ===== Destination of backups ===== | ||
- | <code sql> | ||
- | COLUMN NAME FORMAT A30; | ||
- | col space_limit format 999999999999999999 | ||
- | col SPACE_USED format 999999999999999999 | ||
- | col SPACE_RECLAIMABLE format 999999999999999999 | ||
- | select * from v$recovery_file_dest; | ||
- | </ | ||
- | |||
- | ===== Query FRA backup by type of file ===== | ||
- | <code sql> | ||
- | select file_type, | ||
- | | ||
- | | ||
- | | ||
- | from v$recovery_file_dest rfd, v$flash_recovery_area_usage frau; | ||
- | </ | ||
- | |||
- | ===== Kill RMAN session ===== | ||
- | <code sql> | ||
- | select 'ALTER SYSTEM KILL SESSION ''' | ||
- | from | ||
- | | ||
- | where | ||
- | | ||
- | like | ||
- | ' | ||
- | </ | ||
- | |||
- | ====== Flashback ====== | ||
- | https:// | ||
- | |||
- | ===== List restore points ===== | ||
- | <code sql> | ||
- | LIST RESTORE POINT ALL; | ||
- | </ | ||
- | |||
- | |||
- | ====== Create RMAN Catalog ====== | ||
- | To create an external catalog (in another database), Oracle recommends using the GridControl Database. | ||
- | Steps to do that, inside the Grid Database: | ||
- | * Create the tablespace for the RMAN catalog: | ||
- | <code sql> | ||
- | * Create the user for the catalog | ||
- | <code sql> | ||
- | TEMPORARY TABLESPACE temp | ||
- | DEFAULT TABLESPACE RMAN | ||
- | QUOTA UNLIMITED ON RMAN; | ||
- | </ | ||
- | * Grant it: | ||
- | <code sql> | ||
- | </ | ||
- | * Connect to the catalog (in the same host of the DB) | ||
- | <code sql>rman CATALOG rman/ | ||
- | </ | ||
- | * Create the catalog itself | ||
- | <code sql> | ||
- | * Now on the DB host, connect to the catalog: | ||
- | <code sql> rman TARGET / CATALOG rman/ | ||
- | </ | ||
- | * and register the database | ||
- | <code sql> | ||
- | </ | ||
- | * Done! Begin using the catalog | ||
- | |||
- | |||
- | |||
- | ====== DEBUG of common errors ====== | ||
- | ===== ORA-01547+ORA-01152+RMAN-06054 ===== | ||
- | |||
- | Something like: | ||
- | <code sql> | ||
- | unable to find archived log | ||
- | archived log thread=2 sequence=10583 | ||
- | Oracle Error: | ||
- | ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below | ||
- | ORA-01152: file 1 was not restored from a sufficiently old backup | ||
- | ORA-01110: data file 1: ' | ||
- | |||
- | RMAN-00571: =========================================================== | ||
- | RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== | ||
- | RMAN-00571: =========================================================== | ||
- | RMAN-03002: failure of Duplicate Db command at 10/27/2017 22:20:49 | ||
- | RMAN-05501: aborting duplication of target database | ||
- | RMAN-03015: error occurred in stored script Memory Script | ||
- | RMAN-06054: media recovery requesting unknown archived log for thread 2 with sequence 10583 and starting SCN of 39396106955 | ||
- | </ | ||
- | |||
- | Reference: | ||
- | * How to resolve ORA-01547 warning: RECOVER succeeded but OPEN RESETLOGS would get error below (Doc ID 1684437.1) | ||
- | * How to quickly check that Database is consistent after incomplete recovery (Point in Time Recovery) before OPEN RESETLOGS (Doc ID 1354256.1) | ||
- | * Incomplete recovery gives ORA-01152 (Doc ID 278856.1) | ||
- | |||
- | Summary: | ||
- | Use '' | ||
- | |||
- | I've seen in the destination datafiles with a '' | ||
- | In the source database I'm seeing correct '' | ||
- | In the backup everything is OK. | ||
- | So I just simply restore the datafiles: | ||
- | <code sql> | ||
- | RUN{ | ||
- | SET NEWNAME FOR DATAFILE 43 TO ' | ||
- | SET NEWNAME FOR DATAFILE 44 TO ' | ||
- | SET NEWNAME FOR DATAFILE 45 TO ' | ||
- | RESTORE DATAFILE 43; | ||
- | RESTORE DATAFILE 44; | ||
- | RESTORE DATAFILE 45; | ||
- | SWITCH DATAFILE 43; | ||
- | SWITCH DATAFILE 44; | ||
- | SWITCH DATAFILE 45; | ||
- | } | ||
- | </ | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
dba/oracle/docs/rman_basic_querys.txt · Last modified: 2023/01/31 08:22 by dodger