Friday, June 21, 2019

Rman Backup and restore

Microsoft Windows [Version 10.0.17763.504]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Windows\system32>set ORACLE_SID=ABCD

C:\Windows\system32>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Tue Jun 18 19:19:46 2019

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to an idle instance.

SQL>
SQL>
SQL> exit
Disconnected

C:\Windows\system32>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Tue Jun 18 20:00:49 2019

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to an idle instance.

SQL>
SQL>
SQL>
SQL> exit
Disconnected

C:\Windows\system32>mkdir D:\app\saif.p\oradata\ABCD\

C:\Windows\system32>cd D:\app\saif.p\oradata\ABCD\

C:\Windows\system32>
C:\Windows\system32>d:

D:\app\saif.p\oradata\ABCD>mkdir D:\app\saif.p\flash_recovery_area\ABCD

D:\app\saif.p\oradata\ABCD>mkdir D:\app\saif.p\admin\ABCD\

D:\app\saif.p\oradata\ABCD>cd D:\app\saif.p

D:\app\saif.p>
D:\app\saif.p>
D:\app\saif.p>set ORACLE_SID=ABCD

D:\app\saif.p>
D:\app\saif.p>
D:\app\saif.p>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Tue Jun 18 20:03:21 2019

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup pfile='D:\app\saif.p\product\11.2.0\dbhome_1\database\initABCD.ora' NOMOUNT;
ORA-00119: invalid specification for system parameter LOCAL_LISTENER
ORA-00132: syntax error or unresolved network name 'LISTENER_ABCD'
SQL> startup pfile='D:\app\saif.p\product\11.2.0\dbhome_1\database\initABCD.ora' NOMOUNT;
ORACLE instance started.

Total System Global Area 3390558208 bytes
Fixed Size                  2180464 bytes
Variable Size            1862273680 bytes
Database Buffers         1509949440 bytes
Redo Buffers               16154624 bytes
SQL> create spfile from pfile;

File created.

SQL> startup force nomount;
ORACLE instance started.

Total System Global Area 3390558208 bytes
Fixed Size                  2180464 bytes
Variable Size            1862273680 bytes
Database Buffers         1509949440 bytes
Redo Buffers               16154624 bytes
SQL>
SQL>
SQL>
SQL> host rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Jun 18 20:12:42 2019

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ABCD (not mounted)

RMAN> restore controlfile from 'D:\app\saif.p\product\11.2.0\dbhome_1\database\ABCDCTL.CTL';

Starting restore at 18-JUN-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=189 device type=DISK

channel ORA_DISK_1: copied control file copy
output file name=D:\APP\SAIF.P\ORADATA\ABCD\CONTROL01.CTL
output file name=D:\APP\SAIF.P\FLASH_RECOVERY_AREA\ABCD\CONTROL02.CTL
Finished restore at 18-JUN-19

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN>

RMAN> exit


Recovery Manager complete.

SQL> alter database rename file 'C:\APP\SAIF.P\ORADATA\ABCD\REDO03.LOG' to 'D:\APP\SAIF.P\ORADATA\ABCD\REDO03.LOG';

Database altered.

SQL> alter database rename file 'C:\APP\SAIF.P\ORADATA\ABCD\REDO02.LOG' to 'D:\APP\SAIF.P\ORADATA\ABCD\REDO02.LOG';

Database altered.

SQL> alter database rename file 'C:\APP\SAIF.P\ORADATA\ABCD\REDO01.LOG' to 'D:\APP\SAIF.P\ORADATA\ABCD\REDO01.LOG';

Database altered.

SQL>
SQL>
SQL> host rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Jun 18 21:10:48 2019

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ABCD (DBID=294027228, not open)

RMAN> catalog start with 'D:\TEST';

Starting implicit crosscheck backup at 18-JUN-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=189 device type=DISK
Finished implicit crosscheck backup at 18-JUN-19

Starting implicit crosscheck copy at 18-JUN-19
using channel ORA_DISK_1
Finished implicit crosscheck copy at 18-JUN-19

searching for all files in the recovery area
cataloging files...
no files cataloged

searching for all files that match the pattern D:\TEST

List of Files Unknown to the Database
=====================================
File Name: D:\TEST\ABCD_04U4ECV3_1_1.BAK
File Name: D:\TEST\ABCD_05U4ECV7_1_1.BAK
File Name: D:\TEST\ABCD_06U4ED0K_1_1.BAK
File Name: D:\TEST\ABCD_07U4ED0O_1_1.BAK

Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: D:\TEST\ABCD_04U4ECV3_1_1.BAK
File Name: D:\TEST\ABCD_05U4ECV7_1_1.BAK
File Name: D:\TEST\ABCD_06U4ED0K_1_1.BAK
File Name: D:\TEST\ABCD_07U4ED0O_1_1.BAK

RMAN> restore database;

Starting restore at 18-JUN-19
using channel ORA_DISK_1

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:\APP\SAIF.P\ORADATA\ABCD\SYSTEM01.DBF
channel ORA_DISK_1: restoring datafile 00002 to C:\APP\SAIF.P\ORADATA\ABCD\SYSAUX01.DBF
channel ORA_DISK_1: restoring datafile 00003 to C:\APP\SAIF.P\ORADATA\ABCD\UNDOTBS01.DBF
channel ORA_DISK_1: restoring datafile 00004 to C:\APP\SAIF.P\ORADATA\ABCD\USERS01.DBF
channel ORA_DISK_1: restoring datafile 00005 to C:\APP\SAIF.P\ORADATA\ABCD\EXAMPLE01.DBF
channel ORA_DISK_1: reading from backup piece D:\TEST\ABCD_05U4ECV7_1_1.BAK
channel ORA_DISK_1: ORA-19870: error while restoring backup piece D:\TEST\ABCD_05U4ECV7_1_1.BAK
ORA-19504: failed to create file "C:\APP\SAIF.P\ORADATA\ABCD\SYSTEM01.DBF"
ORA-27040: file create error, unable to create file
OSD-04002: unable to open file
O/S-Error: (OS 3) The system cannot find the path specified.

failover to previous backup

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 06/18/2019 21:11:11
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 5 found to restore
RMAN-06023: no backup or copy of datafile 4 found to restore
RMAN-06023: no backup or copy of datafile 3 found to restore
RMAN-06023: no backup or copy of datafile 2 found to restore
RMAN-06023: no backup or copy of datafile 1 found to restore

RMAN> run
2> {
3> allocate channel c1 device type disk;
4> SET NEWNAME FOR DATAFILE 1 TO 'D:\APP\SAIF.P\ORADATA\ABCD\SYSTEM01.DBF';
5> SET NEWNAME FOR DATAFILE 2 TO 'D:\APP\SAIF.P\ORADATA\ABCD\SYSAUX01.DBF';
6> SET NEWNAME FOR DATAFILE 3 TO 'D:\APP\SAIF.P\ORADATA\ABCD\UNDOTBS01.DBF';
7> SET NEWNAME FOR DATAFILE 4 TO 'D:\APP\SAIF.P\ORADATA\ABCD\USERS01.DBF';
8> SET NEWNAME FOR DATAFILE 5 TO 'D:\APP\SAIF.P\ORADATA\ABCD\EXAMPLE01.DBF';
9> RESTORE DATABASE;
10> SWITCH DATAFILE ALL;
11> RECOVER DATABASE;
12> }

released channel: ORA_DISK_1
allocated channel: c1
channel c1: SID=189 device type=DISK

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 18-JUN-19

channel c1: starting datafile backup set restore
channel c1: specifying datafile(s) to restore from backup set
channel c1: restoring datafile 00001 to D:\APP\SAIF.P\ORADATA\ABCD\SYSTEM01.DBF
channel c1: restoring datafile 00002 to D:\APP\SAIF.P\ORADATA\ABCD\SYSAUX01.DBF
channel c1: restoring datafile 00003 to D:\APP\SAIF.P\ORADATA\ABCD\UNDOTBS01.DBF
channel c1: restoring datafile 00004 to D:\APP\SAIF.P\ORADATA\ABCD\USERS01.DBF
channel c1: restoring datafile 00005 to D:\APP\SAIF.P\ORADATA\ABCD\EXAMPLE01.DBF
channel c1: reading from backup piece D:\TEST\ABCD_05U4ECV7_1_1.BAK
channel c1: piece handle=D:\TEST\ABCD_05U4ECV7_1_1.BAK tag=TAG20190618T202823
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:00:07
Finished restore at 18-JUN-19

datafile 1 switched to datafile copy
input datafile copy RECID=7 STAMP=1011302099 file name=D:\APP\SAIF.P\ORADATA\ABCD\SYSTEM01.DBF
datafile 2 switched to datafile copy
input datafile copy RECID=8 STAMP=1011302099 file name=D:\APP\SAIF.P\ORADATA\ABCD\SYSAUX01.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=9 STAMP=1011302099 file name=D:\APP\SAIF.P\ORADATA\ABCD\UNDOTBS01.DBF
datafile 4 switched to datafile copy
input datafile copy RECID=10 STAMP=1011302099 file name=D:\APP\SAIF.P\ORADATA\ABCD\USERS01.DBF
datafile 5 switched to datafile copy
input datafile copy RECID=11 STAMP=1011302099 file name=D:\APP\SAIF.P\ORADATA\ABCD\EXAMPLE01.DBF

Starting recover at 18-JUN-19

starting media recovery

channel c1: starting archived log restore to default destination
channel c1: restoring archived log
archived log thread=1 sequence=21
channel c1: restoring archived log
archived log thread=1 sequence=22
channel c1: restoring archived log
archived log thread=1 sequence=23
channel c1: reading from backup piece D:\TEST\ABCD_04U4ECV3_1_1.BAK
channel c1: piece handle=D:\TEST\ABCD_04U4ECV3_1_1.BAK tag=TAG20190618T202819
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:00:01
archived log file name=D:\APP\SAIF.P\FLASH_RECOVERY_AREA\ABCD\ARCHIVELOG\2019_06_18\O1_MF_1_21_GJL1QVXW_.ARC thread=1 sequence=21
channel default: deleting archived log(s)
archived log file name=D:\APP\SAIF.P\FLASH_RECOVERY_AREA\ABCD\ARCHIVELOG\2019_06_18\O1_MF_1_21_GJL1QVXW_.ARC RECID=21 STAMP=1011302100
archived log file name=D:\APP\SAIF.P\FLASH_RECOVERY_AREA\ABCD\ARCHIVELOG\2019_06_18\O1_MF_1_22_GJL1QVYQ_.ARC thread=1 sequence=22
channel default: deleting archived log(s)
archived log file name=D:\APP\SAIF.P\FLASH_RECOVERY_AREA\ABCD\ARCHIVELOG\2019_06_18\O1_MF_1_22_GJL1QVYQ_.ARC RECID=20 STAMP=1011302099
archived log file name=D:\APP\SAIF.P\FLASH_RECOVERY_AREA\ABCD\ARCHIVELOG\2019_06_18\O1_MF_1_23_GJL1QVY3_.ARC thread=1 sequence=23
channel default: deleting archived log(s)
archived log file name=D:\APP\SAIF.P\FLASH_RECOVERY_AREA\ABCD\ARCHIVELOG\2019_06_18\O1_MF_1_23_GJL1QVY3_.ARC RECID=19 STAMP=1011302099
channel c1: starting archived log restore to default destination
channel c1: restoring archived log
archived log thread=1 sequence=24
channel c1: reading from backup piece D:\TEST\ABCD_07U4ED0O_1_1.BAK
channel c1: piece handle=D:\TEST\ABCD_07U4ED0O_1_1.BAK tag=TAG20190618T202912
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:00:01
archived log file name=D:\APP\SAIF.P\FLASH_RECOVERY_AREA\ABCD\ARCHIVELOG\2019_06_18\O1_MF_1_24_GJL1QXF2_.ARC thread=1 sequence=24
channel default: deleting archived log(s)
archived log file name=D:\APP\SAIF.P\FLASH_RECOVERY_AREA\ABCD\ARCHIVELOG\2019_06_18\O1_MF_1_24_GJL1QXF2_.ARC RECID=22 STAMP=1011302101
unable to find archived log
archived log thread=1 sequence=25
released channel: c1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 06/18/2019 21:15:02
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 25 and starting SCN of 1010207

RMAN>  run{
2>  set until sequence 25 thread 1;
3> recover database;
4> }

executing command: SET until clause

Starting recover at 18-JUN-19
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=189 device type=DISK

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

Finished recover at 18-JUN-19

RMAN> alter database open resetlogs;

database opened

RMAN>

RMAN>

RMAN>

RMAN> exit


Recovery Manager complete.

SQL>
SQL>
SQL>
SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
ABCD      READ WRITE           PRIMARY

SQL>

***********************SAMPLE ERRORS SCENARIOUS *****************************
-----------------------------------------------------------
RMAN>

RMAN> run{
2> set until sequence 97400 thread 1;
3> recover database;
4> }

executing command: SET until clause

Starting recover at 19-JUN-19
using channel ORA_DISK_1
using channel ORA_DISK_2
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 06/19/2019 07:25:19
RMAN-06556: datafile 1 must be restored from backup older than SCN 329317396

****************************************Solution******************************************************

RMAN> exit


Recovery Manager complete.

SQL>
SQL>
SQL>
SQL> select open_mode from v$database;

OPEN_MODE
--------------------
MOUNTED

SQL>
SQL>
SQL>
SQL> select count(*) from v$recover_file group by error;

no rows selected

SQL>
SQL>
SQL>
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 329321994 generated at 06/19/2019 04:00:05 needed for thread
1
ORA-00289: suggestion : F:\ORACLE_ARCH\ARC0000097400_0917714104.0001
ORA-00280: change 329321994 for thread 1 is in sequence #97400


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
CANCEL
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: 'F:\APP\ORCLUSER\ORADATA\ORCL\SYSTEM01.DBF'


ORA-01112: media recovery not started


SQL> select max(sequence#) from v$log;

MAX(SEQUENCE#)
--------------
         97400

SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

C:\Users\rkona>rman target /

Recovery Manager: Release 12.1.0.2.0 - Production on Wed Jun 19 08:24:55 2019

Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1445494837, not open)

RMAN> restore archivelog from logseq 97400 until logseq 97401 thread=1;

Starting restore at 19-JUN-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=122 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=178 device type=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 06/19/2019 08:26:21
RMAN-20242: specification does not match any archived log in the repository

RMAN> exit


Recovery Manager complete.

C:\Users\rkona>sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Wed Jun 19 08:28:43 2019

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> recover database using backup controlfile until cancel;
ORA-00279: change 329321994 generated at 06/19/2019 04:00:05 needed for thread
1
ORA-00289: suggestion : F:\ORACLE_ARCH\ARC0000097400_0917714104.0001
ORA-00280: change 329321994 for thread 1 is in sequence #97400


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
AUTO
ORA-00279: change 329322393 generated at 06/19/2019 06:11:10 needed for thread
1
ORA-00289: suggestion : F:\ORACLE_ARCH\ARC0000097401_0917714104.0001
ORA-00280: change 329322393 for thread 1 is in sequence #97401
ORA-00278: log file 'F:\ORACLE_ARCH\ARC0000097400_0917714104.0001' no longer
needed for this recovery


ORA-00279: change 329322396 generated at 06/19/2019 06:11:11 needed for thread
1
ORA-00289: suggestion : F:\ORACLE_ARCH\ARC0000097402_0917714104.0001
ORA-00280: change 329322396 for thread 1 is in sequence #97402
ORA-00278: log file 'F:\ORACLE_ARCH\ARC0000097401_0917714104.0001' no longer
needed for this recovery


ORA-00279: change 329322399 generated at 06/19/2019 06:11:13 needed for thread
1
ORA-00289: suggestion : F:\ORACLE_ARCH\ARC0000097403_0917714104.0001
ORA-00280: change 329322399 for thread 1 is in sequence #97403
ORA-00278: log file 'F:\ORACLE_ARCH\ARC0000097402_0917714104.0001' no longer
needed for this recovery


ORA-00279: change 329322402 generated at 06/19/2019 06:11:13 needed for thread
1
ORA-00289: suggestion : F:\ORACLE_ARCH\ARC0000097404_0917714104.0001
ORA-00280: change 329322402 for thread 1 is in sequence #97404
ORA-00278: log file 'F:\ORACLE_ARCH\ARC0000097403_0917714104.0001' no longer
needed for this recovery


ORA-00279: change 329322507 generated at 06/19/2019 06:14:39 needed for thread
1
ORA-00289: suggestion : F:\ORACLE_ARCH\ARC0000097405_0917714104.0001
ORA-00280: change 329322507 for thread 1 is in sequence #97405
ORA-00278: log file 'F:\ORACLE_ARCH\ARC0000097404_0917714104.0001' no longer
needed for this recovery


ORA-00279: change 329322659 generated at 06/19/2019 06:19:33 needed for thread
1
ORA-00289: suggestion : F:\ORACLE_ARCH\ARC0000097406_0917714104.0001
ORA-00280: change 329322659 for thread 1 is in sequence #97406
ORA-00278: log file 'F:\ORACLE_ARCH\ARC0000097405_0917714104.0001' no longer
needed for this recovery


ORA-00279: change 329323039 generated at 06/19/2019 06:29:30 needed for thread
1
ORA-00289: suggestion : F:\ORACLE_ARCH\ARC0000097407_0917714104.0001
ORA-00280: change 329323039 for thread 1 is in sequence #97407
ORA-00278: log file 'F:\ORACLE_ARCH\ARC0000097406_0917714104.0001' no longer
needed for this recovery


ORA-00308: cannot open archived log
'F:\ORACLE_ARCH\ARC0000097407_0917714104.0001'
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 2) The system cannot find the file specified.


SQL> alter database open resetlogs;

Database altered.

SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

=====================================================================================================================

No comments:

Post a Comment