Sunteți pe pagina 1din 13

Datafile delete at logseq 10 and backup taken at this time

============================================================
SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

[oracle@rman orcl]$ rman target /


Recovery Manager: Release 11.2.0.1.0 - Production on Sat Sep 26 06:54:05 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN> startup mount
Oracle instance started
database mounted
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
RMAN> backup database format '/home/BKPCASES/db_%t_%s_p%p';
Starting backup at 26-SEP-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 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=00001 name=/home/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00002 name=/home/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00003 name=/home/app/oracle/oradata/orcl/undotbs01.db
f
input datafile file number=00005 name=/home/app/oracle/oradata/orcl/bak0.dbf
input datafile file number=00004 name=/home/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 26-SEP-15
channel ORA_DISK_1: finished piece 1 at 26-SEP-15
piece handle=/home/BKPCASES/db_891413942_1_p1 tag=TAG20150926T065901 comment=NON
E
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:15
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 26-SEP-15
channel ORA_DISK_1: finished piece 1 at 26-SEP-15
piece handle=/home/BKPCASES/db_891414018_2_p1 tag=TAG20150926T065901 comment=NON
E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 26-SEP-15
SQL> alter database open;
Database altered.
SQL> select name,open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
ORCL READ WRITE
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
alter system switch logfile;
alter system switch logfile;
System altered.
SQL>
System altered.
SQL>
System altered.
SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 13
Current log sequence 15
SQL>

SQL> shut immediate


Database closed.
Database dismounted.
ORACLE instance shut down.
Datafile deleted at OS level

SQL> startup
ORACLE instance started.
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01110: data file 5: '/home/app/oracle/oradata/orcl/bak0.dbf'

SQL> shut immediate


ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
Database mounted.

[oracle@rman orcl]$ rman target /


Recovery Manager: Release 11.2.0.1.0 - Production on Sat Sep 26 07:06:20 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1419165592, not open)
RMAN> restore database;
Starting restore at 26-SEP-15
using target database control file instead of recovery catalog
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 /home/app/oracle/oradata/orcl/sy
stem01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /home/app/oracle/oradata/orcl/sy
saux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /home/app/oracle/oradata/orcl/un
dotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /home/app/oracle/oradata/orcl/us
ers01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /home/app/oracle/oradata/orcl/ba
k0.dbf
channel ORA_DISK_1: reading from backup piece /home/BKPCASES/db_891413942_1_p1
channel ORA_DISK_1: piece handle=/home/BKPCASES/db_891413942_1_p1 tag=TAG2015092
6T065901
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:15
Finished restore at 26-SEP-15
RMAN> recover database;
Starting recover at 26-SEP-15
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 13 is already on disk as file /home/app/
oracle/oradata/orcl/redo01.log
archived log for thread 1 with sequence 14 is already on disk as file /home/app/
oracle/oradata/orcl/redo02.log
archived log for thread 1 with sequence 15 is already on disk as file /home/app/
oracle/oradata/orcl/redo03.log
RMAN-08187: WARNING: media recovery until SCN 825213 complete
Finished recover at 26-SEP-15
RMAN> exit

Recovery Manager complete.


[oracle@rman orcl]$
[oracle@rman orcl]$ sqlplus "/as sysdba"
SQL*Plus: Release 11.2.0.1.0 Production on Sat Sep 26 07:08:55 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> alter database open resetlogs;
Database altered.
SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Current log sequence 1
SQL>

Note:
Now the case is if the db is in noarchve mode and u dont take the backup of redo
logs, now if any of the datafile deleted u can restore and recover the database
because ur redologs has not been deleted.no backup taken for redo as well
Case B)
Now what i have done , taken backup at log sequence 19 with OS command that mean
s backup contains everything and log19 also. Now i have just deleted log seq19
that is redlog current no 2 from OS level.
Mount the Database restore all files from OS command only , no resetlogs require
d. Db started from log19 only.

CASE C)
========
Nice control file scenario with Inconsitent version.
-----------------------------------------------------
Scenario is suppose u want to multiplex ur control files now what you have done
you have you have already two control files :
[oracle@rman home]$ cd /home/app/oracle/oradata/orcl/
-rw-r----- 1 oracle oracle 9748480 Sep 26 22:52 control03.ctl
-rw-r----- 1 oracle oracle 9748480 Sep 26 22:52 control01.ctl
[oracle@rman orcl]$

Now you want to multiplex this in /home/ directory , now what u have done u just
copy the control01.ctl file without shutting down the database to /home/ direct
ory and u just nomount ur database and start in restrict mode :
SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup
ORACLE instance started.
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
ORA-00214: control file '/home/control03.ctl' version 1099 inconsistent with
file '/home/app/oracle/oradata/orcl/control01.ctl' version 1086
Opps u got the inconsitent Ora-00214 error . Now what u want to do is just ollow
the below steps :
Shutdown ur database
copy the file from oradata location to home location and rename it
startup nomount
SQL> alter system set control_files='/home/app/oracle/oradata/orcl/control03.ctl
','/home/app/oracle/oradata/orcl/control01.ctl','/home/control02.ctl' scope=spfi
le;
System altered.

SQL> startup restrict


ORACLE instance started.
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
Database mounted.
Database opened.

SQL> show parameter control_files


NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /home/app/oracle/oradata/orcl/
control03.ctl, /home/app/oracl
e/oradata/orcl/control01.ctl,
/home/control02.ctl

CASE D
=======
How to restore a NOARCHIVELOG database (ORA-01139: RESETLOGS option only valid a
fter an incomplete database recovery) using current control file

Backuped my database using RMAN :


RMAN> backup database format '/home/BKPCASES/db_%t_%s_p%p';
Starting backup at 26-SEP-15
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=/home/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00002 name=/home/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00003 name=/home/app/oracle/oradata/orcl/undotbs01.db
f
input datafile file number=00005 name=/home/app/oracle/oradata/orcl/bak0.dbf
input datafile file number=00004 name=/home/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 26-SEP-15
channel ORA_DISK_1: finished piece 1 at 26-SEP-15
piece handle=/home/BKPCASES/db_891471810_8_p1 tag=TAG20150926T230330 comment=NON
E
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:25
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 26-SEP-15
channel ORA_DISK_1: finished piece 1 at 26-SEP-15
piece handle=/home/BKPCASES/db_891471896_9_p1 tag=TAG20150926T230330 comment=NON
E
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 26-SEP-15

created one dir old in orcl location only ,Now what i have done i just moved all
the log,ctl,dbf file to old dir :
/home/app/oracle/oradata/orcl/old/
Instance is still running here.
SQL> !ps -ef|grep smon
oracle 7898 1 0 23:01 ? 00:00:00 ora_smon_orcl
oracle 8316 8110 0 23:12 pts/1 00:00:00 /bin/bash -c ps -ef|grep smon
oracle 8318 8316 0 23:12 pts/1 00:00:00 grep smon

Now i try to shut DB


======================
SQL> shutdown immediate;
Database closed.
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/home/app/oracle/oradata/orcl/control03.ctl'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3

SQL>

SQL> shutdown abort;


ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
ORA-00205: error in identifying control file, check alert log for more info

Now what i have done just restore the control files from old dir to original loc
ation , now ur original location contains only control files:
[oracle@rman orcl]$ ls -lrt
total 1269644
drwxrwxr-x 2 oracle oracle 4096 Sep 26 23:24 old
-rw-rw---- 1 oracle oracle 10493952 Sep 26 23:26 bak0.dbf
-rw-rw---- 1 oracle oracle 5251072 Sep 26 23:26 users01.dbf
-rw-rw---- 1 oracle oracle 47194112 Sep 26 23:26 undotbs01.dbf
-rw-rw---- 1 oracle oracle 503324672 Sep 26 23:28 sysaux01.dbf
-rw-rw---- 1 oracle oracle 713039872 Sep 26 23:28 system01.dbf
-rw-r----- 1 oracle oracle 9748480 Sep 26 23:28 control03.ctl
-rw-r----- 1 oracle oracle 9748480 Sep 26 23:28 control01.ctl

Now restore ur database:

RMAN> restore database;


Starting restore at 26-SEP-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 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 /home/app/oracle/oradata/orcl/sy
stem01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /home/app/oracle/oradata/orcl/sy
saux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /home/app/oracle/oradata/orcl/un
dotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /home/app/oracle/oradata/orcl/us
ers01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /home/app/oracle/oradata/orcl/ba
k0.dbf
channel ORA_DISK_1: reading from backup piece /home/BKPCASES/db_891471810_8_p1
channel ORA_DISK_1: piece handle=/home/BKPCASES/db_891471810_8_p1 tag=TAG2015092
6T230330
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:36
Finished restore at 26-SEP-15
RMAN> exit

[oracle@rman ~]$ sqlplus "/as sysdba"


SQL*Plus: Release 11.2.0.1.0 Production on Sat Sep 26 23:29:22 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01139: RESETLOGS option only valid after an incomplete database recovery

SQL> recover database until cancel;


ORA-00279: change 877712 generated at 09/26/2015 23:00:56 needed for thread 1
ORA-00289: suggestion :
/home/app/oracle/flash_recovery_area/ORCL/archivelog/2015_09_26/o1_mf_1_17_%u_.a
rc
ORA-00280: change 877712 for thread 1 is in sequence #17

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}


CANCEL
Media recovery cancelled.
SQL> alter database open resetlogs;
Database altered.
SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Current log sequence 1
SQL> select name,open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
ORCL READ WRITE
SQL>

CASE E
=======
How to restore a NOARCHIVELOG database using a backup controlfile

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

SQL> shut immediate


Database closed.
Database dismounted.
ORACLE instance shut down.

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;


using target database control file instead of recovery catalog
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
RMAN> backup database format '/home/BKPCASES/db_%t_%s_p%p';
Starting backup at 26-SEP-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 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=00001 name=/home/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00002 name=/home/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00003 name=/home/app/oracle/oradata/orcl/undotbs01.db
f
input datafile file number=00005 name=/home/app/oracle/oradata/orcl/bak0.dbf
input datafile file number=00004 name=/home/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 26-SEP-15
channel ORA_DISK_1: finished piece 1 at 26-SEP-15
piece handle=/home/BKPCASES/db_891474737_10_p1 tag=TAG20150926T235216 comment=NO
NE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:15
Finished backup at 26-SEP-15
Starting Control File and SPFILE Autobackup at 26-SEP-15
piece handle=/home/app/oracle/flash_recovery_area/ORCL/autobackup/2015_09_26/o1_
mf_s_891474657_c0h4mhcl_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 26-SEP-15

Now delete all the files from original location

RMAN> startup nomount


connected to target database (not started)
Oracle instance started
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
RMAN> restore controlfile from autobackup;
Starting restore at 26-SEP-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
recovery area destination: /home/app/oracle/flash_recovery_area
database name (or database unique name) used for search: ORCL
channel ORA_DISK_1: AUTOBACKUP /home/app/oracle/flash_recovery_area/ORCL/autobac
kup/2015_09_26/o1_mf_s_891474657_c0h4mhcl_.bkp found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20150926
channel ORA_DISK_1: restoring control file from AUTOBACKUP /home/app/oracle/flas
h_recovery_area/ORCL/autobackup/2015_09_26/o1_mf_s_891474657_c0h4mhcl_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/home/app/oracle/oradata/orcl/control03.ctl
output file name=/home/app/oracle/oradata/orcl/control01.ctl
output file name=/home/control02.ctl
output file name=/home/control04.ctl
Finished restore at 26-SEP-15
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> exit

Recovery Manager complete.


[oracle@rman ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Sat Sep 26 23:56:21 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select controlfile_type from V$DATABASE; 4
2
SQL> select controlfile_type from V$DATABASE;
CONTROL
-------
BACKUP
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Pr
oduction
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@rman ~]$
[oracle@rman ~]$ rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Sat Sep 26 23:56:50 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1419165592, not open)
RMAN> restore database;
Starting restore at 26-SEP-15
Starting implicit crosscheck backup at 26-SEP-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
Crosschecked 3 objects
Finished implicit crosscheck backup at 26-SEP-15
Starting implicit crosscheck copy at 26-SEP-15
using channel ORA_DISK_1
Finished implicit crosscheck copy at 26-SEP-15
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /home/app/oracle/flash_recovery_area/ORCL/autobackup/2015_09_26/o1_mf
_s_891474657_c0h4mhcl_.bkp
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 /home/app/oracle/oradata/orcl/sy
stem01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /home/app/oracle/oradata/orcl/sy
saux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /home/app/oracle/oradata/orcl/un
dotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /home/app/oracle/oradata/orcl/us
ers01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /home/app/oracle/oradata/orcl/ba
k0.dbf
channel ORA_DISK_1: reading from backup piece /home/BKPCASES/db_891474737_10_p1
channel ORA_DISK_1: piece handle=/home/BKPCASES/db_891474737_10_p1 tag=TAG201509
26T235216
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:05
Finished restore at 26-SEP-15
RMAN> alter database open resetlogs;
database opened
RMAN> exit

Recovery Manager complete.


[oracle@rman ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 11.2.0.1.0 Production on Sat Sep 26 23:59:55 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select name,open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
ORCL READ WRITE

S-ar putea să vă placă și