Showing posts with label RMAN. Show all posts
Showing posts with label RMAN. Show all posts

How does one create a RMAN recovery catalog?

Start by creating a database schema (usually called RMAN)

Assign an appropriate table space to it and grant it recovery_catalog_owner role.

sqlplus sys
SQL>create user RMAN identified by RMAN;
SQL> alter user RMAN default table space tools temporary tablespace temp;
SQL> alter user RMAN quota unlimited on tools;
SQL> grant connect, resource, recovery_catalog_owner to RMAN;

Next, log in to RMAN and create the catalog schema.

Prior to Oracle 8i this was done by running catRMAN.sql script.

RMAN> catalog RMAN/RMAN
RMAN>create catalog tablespace tools;
RMAN> exit; 

You can now continue by registering your databases in the catalog.

RMAN catalog RMAN/RMAN target backdba/backdba
RMAN> register database; 

How does one backup archived log files

One can backup archived log files using RMAN or any operating system backup utility. 

Remember to delete files after backing them up to prevent archive log directory from filling up. If the archive log directory becomes full, your database will hang!

Look at this simple RMAN backup script

RMAN> run {
Allocate channel dev1 type disk;
Backup Format '/app/oracle/arch_backup/log_t%t_s%s_p%p'
(Archive log all delete input);
Release channel dev1;

How does one backup a database using RMAN

The biggest advantage of RMAN is that it only backup used space in the database.
RMAN doesn't put tablespaces in backup mode, saving on redo generation overhead.
RMAN will re – read database blocks until it gets a consistent image of it.

Look at this simple backup example

RMAN target sys/*** nocatalog
Run {
Allocate channel t1 type disk;
Backup
Format '/app/oracle/db_backup/%d_t%t_s%s_p%p'
(Database);
 Release channel t1;
}

Example
RMAN restore
RMAN target sys/*** nocatalog

Run {
Allocate channel t1 type disk;
 # set until time 'Aug 07 2000:51';
Restore table space users;
Recover table space users;
Release channel t1;
}

Examples above are extremely simplistic and only useful for illustrating basic concepts.
By default Oracle uses the database control files to store information about backups.
Normally one would rather setup a RMAN catalog database to store RMAN metadata in.
Read Oracle Backup and Recovery Guide before implementing any RMAN backups

Note: RMAN cannot write image copies directly to tape. One needs to use a third party media manager that integrates with RMAN to backup directly to tape.

Alternatively one can backup to disk and then manually copy the backups to tape. 

ORA - 19625: error identifying file

RMAN> BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT;

 Starting backup
 current log archived
 using channel ORA_DISK_1
 RMAN-00571: ===========================================================
 RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
 RMAN-00571: ===========================================================
 RMAN-03002: failure of backup plus archivelog command at 10/09/2014 00:16:23
 RMAN-06059: expected archived log not found, loss of archived log compromises recoverability
 ORA-19625: error identifying file /u01/app/oracle/oradata/archive/1_241_850299214.arc
 ORA-27037: unable to obtain file status
 Linux-x86_64 Error: 2: No such file or directory
 Additional information: 3

Cause: RMAN cannot find the following archive log file in corresponding destination cause of expire or delete file.

Solution: You can check your expire archive log list and delete expired archive log files from RMAN, If you really lost your archive log file and you are not able to collect this file.

RMAN> CROSSCHECK ARCHIVELOG ALL;

 released channel: ORA_DISK_1
 allocated channel: ORA_DISK_1
 channel ORA_DISK_1: SID=98 device type=DISK
 validation failed for archived log
 archived log file name=/u01/app/oracle/oradata/archive/1_241_850299214.arc RECID=351 STAMP=860457193
 validation failed for archived log
 archived log file name=/u01/app/oracle/oradata/archive/1_242_850299214.arc RECID=351 STAMP=860457670
 validation succeeded for archived log
 archived log file name=/u01/app/oracle/oradata/archive/1_243_850299214.arc RECID=352 STAMP=860458582
 Crosschecked 3 objects

 RMAN> DELETE EXPIRED ARCHIVELOG ALL;

 released channel: ORA_DISK_1
 allocated channel: ORA_DISK_1
 channel ORA_DISK_1: SID=98 device type=DISK
 List of Archived Log Copies for database with db_unique_name ORA11GS
 =====================================================================

 Key     Thrd Seq     S Low Time
 ------- ---- ------- - ---------
 2730    1    241     X 08-OCT-14
         Name: /u01/app/oracle/oradata/archive/1_241_850299214.arc

 3002    1    242     X 08-OCT-14
         Name: /u01/app/oracle/oradata/archive/1_242_850299214.arc

 Do you really want to delete the above objects (enter YES or NO)? yes
 deleted archived log
 archived log file name=/u01/app/oracle/oradata/archive/1_241_850299214.arc RECID=351 STAMP=860457193
 deleted archived log
 archived log file name=/u01/app/oracle/oradata/archive/1_242_850299214.arc RECID=351 STAMP=860457670
 Deleted 2 EXPIRED objects

 RMAN> BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT;

 Starting backup
 current log archived
 using channel ORA_DISK_1
 channel ORA_DISK_1: starting archived log backup set
 channel ORA_DISK_1: specifying archived log(s) in backup set
 input archived log thread=1 sequence=243 RECID=352 STAMP=860458582
 input archived log thread=1 sequence=244 RECID=353 STAMP=860459023
 channel ORA_DISK_1: starting piece 1 at 09-OCT-14
 channel ORA_DISK_1: finished piece 1 at 09-OCT-14
 piece handle=/u01/rman_backup/ora11gs_bkp_1gpkj40g tag=TAG20141009T002344 comment=NONE
 channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
 channel ORA_DISK_1: deleting archived log(s)
 archived log file name=/u01/app/oracle/oradata/archive/1_243_850299214.arc RECID=352 STAMP=860458582
 archived log file name=/u01/app/oracle/oradata/archive/1_244_850299214.arc RECID=353 STAMP=860459023
 Finished backup at 09-OCT-14

 Starting backup at 09-OCT-14
 using channel ORA_DISK_1
 channel ORA_DISK_1: starting full datafile backup set
 channel ORA_DISK_1: specifying datafile(s) in backup set
 input datafile file number=00001 name=/u01/app/oracle/oradata/ora11gp/system01.dbf
 input datafile file number=00002 name=/u01/app/oracle/oradata/ora11gp/sysaux01.dbf
 input datafile file number=00003 name=/u01/app/oracle/oradata/ora11gp/undotbs01.dbf
 input datafile file number=00004 name=/u01/app/oracle/oradata/ora11gp/users01.dbf
 channel ORA_DISK_1: starting piece 1
 channel ORA_DISK_1: finished piece 1
 piece handle=/u01/rman_backup/ora11gs_bkp_1hpkj40h tag=TAG20141009T002345 comment=NONE
 channel ORA_DISK_1: backup set complete, elapsed time: 00:01:25
 Finished backup

 Starting backup
 current log archived
 using channel ORA_DISK_1
 channel ORA_DISK_1: starting archived log backup set
 channel ORA_DISK_1: specifying archived log(s) in backup set
 input archived log thread=1 sequence=245 RECID=354 STAMP=860459111
 channel ORA_DISK_1: starting piece 1 at 09-OCT-14
 channel ORA_DISK_1: finished piece 1 at 09-OCT-14
 piece handle=/u01/rman_backup/ora11gs_bkp_1ipkj437 tag=TAG20141009T002511 comment=NONE
 channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
 channel ORA_DISK_1: deleting archived log(s)
 archived log file name=/u01/app/oracle/oradata/archive/1_245_850299214.arc RECID=354 STAMP=860459111
 Finished backup

 Starting Control File and SPFILE Autobackup
 piece handle=/u01/rman_backup/bkp_cf_c-3519562480-20141009-01 comment=NONE
 Finished Control File and SPFILE Autobackup

 RMAN> 

How to fix: ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)

Open your terminal and type mysql -u root -p Enter your password. Hopefully your MySQL is logged in now.