czwartek, 11 czerwca 2015

Procedura RMAN

Ustawienie ścieżki kopi
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
2> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'c:\bck\backup\%F';
3> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT 'c:\bck\backup\ORA_DF%t_s%s_s%p';
4> exit;

using target database control file instead of recovery catalog
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'c:\bck\backup\%F';
new RMAN configuration parameters are successfully stored

new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   'c:\bck\backup\ORA_DF%t_s%s_s%p';
new RMAN configuration parameters are successfully stored

Recovery Manager complete.


--------------------------------------------Jeśli mamy wyłączony tryb noarchivelog

RMAN> backup database;
2> exit;

Starting backup at 15/06/08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=25 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 06/08/2015 13:50:26
ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode

Recovery Manager complete.



----------------------------------Dla przypomnienia włączyć tryb archivelog można

SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
SQL "ALTER DATABASE ARCHIVELOG";
ALTER DATABASE OPEN;


-----------------------------------Wykonamy Backup typu FULL


RMAN> backup database;
2> exit;

Starting backup at 15/06/08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=33 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=C:\ORACLEXE\APP\ORACLE\ORADATA\XE\UNDOTBS1.DBF
input datafile file number=00001 name=C:\ORACLEXE\APP\ORACLE\ORADATA\XE\SYSTEM.DBF
input datafile file number=00004 name=C:\ORACLEXE\APP\ORACLE\ORADATA\XE\USERS.DBF
input datafile file number=00003 name=C:\ORACLEXE\APP\ORACLE\ORADATA\XE\SYSAUX.DBF
channel ORA_DISK_1: starting piece 1 at 15/06/08
channel ORA_DISK_1: finished piece 1 at 15/06/08
piece handle=C:\BCK\BACKUP\ORA_DF881848488_S2_S1 tag=TAG20150608T135448 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:45
Finished backup at 15/06/08

Starting Control File and SPFILE Autobackup at 15/06/08
piece handle=C:\BCK\BACKUP\C-2762965997-20150608-00 comment=NONE
Finished Control File and SPFILE Autobackup at 15/06/08

Recovery Manager complete.


----------------------------Sprawdźmy czy backup został wykonany poleceniem List BACKUP

RMAN> list backup;
2> exit;

using target database control file instead of recovery catalog

List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1       Full    755.95M    DISK        00:01:37     15/06/08      
        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20150608T135448
        Piece Name: C:\BCK\BACKUP\ORA_DF881848488_S2_S1
  List of Datafiles in backup set 1
  File LV Type Ckp SCN    Ckp Time Name
  ---- -- ---- ---------- -------- ----
  1       Full 379267     15/06/08 C:\ORACLEXE\APP\ORACLE\ORADATA\XE\SYSTEM.DBF
  2       Full 379267     15/06/08 C:\ORACLEXE\APP\ORACLE\ORADATA\XE\UNDOTBS1.DBF
  3       Full 379267     15/06/08 C:\ORACLEXE\APP\ORACLE\ORADATA\XE\SYSAUX.DBF
  4       Full 379267     15/06/08 C:\ORACLEXE\APP\ORACLE\ORADATA\XE\USERS.DBF

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2       Full    9.36M      DISK        00:00:03     15/06/08      
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20150608T135634
        Piece Name: C:\BCK\BACKUP\C-2762965997-20150608-00
  SPFILE Included: Modification time: 15/06/08
  SPFILE db_unique_name: XE
  Control File Included: Ckp SCN: 379313       Ckp time: 15/06/08

Recovery Manager complete.

---------------------------------------------------------Konfiguracja RMAN


RMAN> show all;
2> exit;

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name XE are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'c:\bck\backup\%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   'c:\bck\backup\ORA_DF%t_s%s_s%p';
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 'C:\ORACLEXE\APP\ORACLE\PRODUCT\11.2.0\SERVER\DATABASE\SNCFXE.ORA'; # default

Recovery Manager complete.



-----------------------------------------Odtworzenie bazy Restore FULL + rozw. problemów

PROBLEM

RMAN> run {
2> shutdown immediate;startup mount;
3> restore database;recover database;}
4> exit;

using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 06/08/2015 14:06:21
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

Recovery Manager complete.


ROZWIĄZANIE


RMAN> shutdown immediate;
using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down


RMAN> startup nomount pfile="C:\ORACLEXE\APP\ORACLE\PRODUCT\11.2.0\SERVER\DATABA
SE\
2> SPFILE2INIT.ORA";

connected to target database (not started)
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 06/08/2015 14:12:15
RMAN-04014: startup failed: ORA-01078: failure in processing system parameters
RMAN-04017: startup error description: LRM-00109: could not open parameter file
'C:\ORACLEXE\APP\ORACLE\PRODUCT\11.2.0\SERVER\DATABASE\SPFILE2INIT.ORA'


RMAN> startup nomount;

Oracle instance started

Total System Global Area     552402944 bytes

Fixed Size                     1384872 bytes
Variable Size                171970136 bytes
Database Buffers             373293056 bytes
Redo Buffers                   5754880 bytes


RMAN> startup mount force;

Oracle instance started
database mounted

Total System Global Area     552402944 bytes

Fixed Size                     1384872 bytes
Variable Size                171970136 bytes
Database Buffers             373293056 bytes
Redo Buffers                   5754880 bytes

RMAN> restore database;

Starting restore at 15/06/08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to C:\ORACLEXE\APP\ORACLE\ORADATA\X
E\SYSTEM.DBF
channel ORA_DISK_1: restoring datafile 00002 to C:\ORACLEXE\APP\ORACLE\ORADATA\X
E\UNDOTBS1.DBF
channel ORA_DISK_1: restoring datafile 00003 to C:\ORACLEXE\APP\ORACLE\ORADATA\X
E\SYSAUX.DBF
channel ORA_DISK_1: restoring datafile 00004 to C:\ORACLEXE\APP\ORACLE\ORADATA\X
E\USERS.DBF
channel ORA_DISK_1: reading from backup piece C:\BCK\BACKUP\ORA_DF881848488_S2_S
1
channel ORA_DISK_1: piece handle=C:\BCK\BACKUP\ORA_DF881848488_S2_S1 tag=TAG2015
0608T135448
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:16
Finished restore at 15/06/08


RMAN> recover database;

Starting recover at 15/06/08
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:02

Finished recover at 15/06/08

RMAN>


-----------------------------------------Usunięcie starych backupów

RMAN> delete noprompt obsolete;
2> exit;

using target database control file instead of recovery catalog
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=22 device type=DISK
no obsolete backups found

Recovery Manager complete.



----------------------------------------Przywrócenie starych ustawień RESET


RMAN> CONFIGURE CONTROLFILE AUTOBACKUP OFF;
2> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK CLEAR;
3> CONFIGURE CHANNEL DEVICE TYPE DISK CLEAR;
4> exit;

using target database control file instead of recovery catalog
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
new RMAN configuration parameters are successfully stored

old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'c:\bck\backup\%F';
RMAN configuration parameters are successfully reset to default value

old RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   'c:\bck\backup\ORA_DF%t_s%s_s%p';
old RMAN configuration parameters are successfully deleted

Recovery Manager complete.


Po przywróceniu starych ustawień backup będzie wykonywany w domyślnej lokalizacji
C:\oraclexe\app\oracle\fast_recovery_area\XE\BACKUPSET\2015_08_03
np pliki
O1_MF_NCSNF_TAG20150608T210236_BQCSSSN8_.BKP -plik kontrolny
O1_MF_NNNDF_TAG20150608T210236_BQCSPF63_.BKP -kopia bazy