Showing posts with label backup and recovery. Show all posts
Showing posts with label backup and recovery. Show all posts

Tuesday, 16 September 2014

Restore standby database using incremental backup

   1)      Find the current scn of Standby database

select  current_scn from v$database;

CURRENT_SCN
-----------
    750098

    2)      Take incremental backup  on primary database  start from the scn  shown in step 1

BACKUP DEVICE TYPE DISK INCREMENTAL FROM SCN 750098 DATABASE
     FORMAT '/tmp/incr_standby/backup_%U';

   3)      Create control file backup  for standby

ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/home/oracle/standby_control.ctl';

   4)      Copy the incremental backup and control file backup from primary to secondary database

   5)      Check the status of standby and controlfile location

select open_mode , database_role ,name from v$database;

OPEN_MODE  DATABASE_ROLE    NAME
---------- ---------------- ---------
MOUNTED    PHYSICAL STANDBY ORCL

Select name , value from  v$parameter where name=’control_file’;

NAME            VALUE
--------------- --------------------------------------------------
control_files   /u01/app/oracle/oradata/orcl/control01.ctl, /u01/a
pp/oracle/flash_recovery_area/orcl/control02.ctl


    6)      Cancel recovery on standby  stop  standby database

 Alter database recover managed standby database cancel;
Database altered.

SQL>  shu immediate ;
    
     7)      Recover control file


rman target /

Restore  controlfile from ‘/tmp/incr_standby/stby.ctl';
startup mount


    8)      Catalog the backup  on standby database


catalog start with  '/tmp/incr_standby/';


    9)      Restore database

RMAN>  recover database noredo;


     10)   Start recover y on standby database

alter database recover managed standby database disconnect from session ;




Wednesday, 27 August 2014

Block corruption

     1)     Create a  tablespace

SQL> create tablespace abc datafile 'C:\APP\USER\ORADATA\MYDATABASE\abc.dbf' size 200k;


2) Connect the user create a table in above tablespaces

SQL> conn scott/tiger
Connected.
SQL> create table abc (name varchar(10)) tablespace abc;
Table created.
SQL> insert into abc values('currpt blk');
1 row created.
SQL> commit;
commit complete.

3) Take tablespace offline

SQL> conn / as sysdba
Connected.
SQL> alter tablespace abc offline;
Tablespace altered.

4) Open the datafile belongs to above tablespace and edit the file change 'currpt blk' to block

5)Change status of tablespace  online

SQL> alter tablespace abc online;
Tablespace altered.

6) Now  access the data from the table

SQL> conn scott/tiger
Connected.
SQL> select * from abc;
select * from abc
              *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 5, block # 11)
ORA-01110: data file 5: 'C:\APP\USER\ORADATA\MYDATABASE\ABC.DBF'




7)  Run the DBV utility find the corrupted block

\BIN>dbv   file =C:\APP\USER\ORADATA\MYDATABASE\abc.dbf

DBVERIFY: Release 11.2.0.1.0 - Production on Wed Aug 10 17:41:13 2011

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

DBVERIFY - Verification starting : FILE = C:\APP\USER\ORADATA\MYDATABASE\ABC.DBF
Page 11 is marked corrupt
Corrupt block relative dba: 0x0140000b (file 5, block 11)
Bad check value found during dbv:
Data in bad block:
 type: 6 format: 2 rdba: 0x0140000b
 last change scn: 0x0000.001096fc seq: 0x1 flg: 0x06
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x96fc0601
 check value in block header: 0xe8f3
 computed block checksum: 0x1a00

DBVERIFY - Verification complete

Total Pages Examined         : 25
Total Pages Processed (Data) : 4
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 10
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 10
Total Pages Marked Corrupt   : 1
Total Pages Influx           : 0
Total Pages Encrypted        : 0
Highest block SCN            : 1087227 (0.1087227)


8) Connect the Rman and recover the block using clockrecover command

C:\app\user\product\11.2.0\dbhome_1\BIN>rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Wed Aug 10 17:41:50 2011

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

connected to target database: MYDATABA (DBID=1269509988)

RMAN> blockrecover datafile 5 block 11;

Starting recover at 10-AUG-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=142 device type=DISK

channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00005
channel ORA_DISK_1: reading from backup piece C:\APP\USER\FLASH_RECOVERY_AREA\MYDATABASE\BACKUPSET\2
011_08_10\O1_MF_NNNDF_TAG20110810T173411_744WXXQG_.BKP
channel ORA_DISK_1: piece handle=C:\APP\USER\FLASH_RECOVERY_AREA\MYDATABASE\BACKUPSET\2011_08_10\O1_
MF_NNNDF_TAG20110810T173411_744WXXQG_.BKP tag=TAG20110810T173411
channel ORA_DISK_1: restored block(s) from backup piece 1
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:02

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

Finished recover at 10-AUG-11

RMAN>


You can find the  corrupt block for particular  object as given below

select tablespace_id,HEADER_FILE,header_block,segment_type from  SYS_dba_SEGS where segment_na
me like 'ABC'
SQL> /

TABLESPACE_ID HEADER_FILE HEADER_BLOCK SEGMENT_TYPE
------------- ----------- ------------ ------------------
            6                  1547 TABLE


C:\oracle\product\10.2.0\db_1\BIN>dbv userid=scott/tiger segment_id=6.5.1547














Thursday, 23 May 2013

ORA-16038: log 1 sequence# 35 cannot be archived ORA-19809: limit exceeded for recovery files

ORA-16038: log 1 sequence# 35 cannot be archived
ORA-19809: limit exceeded for recovery files

This error comes if there is no space  in  flash_recovery_area

  • Delete expired  archive log
  • Increase size of  flash_recovery_area


SQL> startup
ORACLE instance started.

Total System Global Area  910163968 bytes
Fixed Size                  2024976 bytes
Variable Size             281020912 bytes
Database Buffers          620756992 bytes
Redo Buffers                6361088 bytes
Database mounted.
ORA-16038: log 1 sequence# 35 cannot be archived
ORA-19809: limit exceeded for recovery files
ORA-00312: online log 1 thread 1:
'/home/oracle/10.2.0/product/oradata/MYDB/redo01.log'


You can check the total and used size using below query

SQL> select name
,floor(space_limit / 1024 / 1024) "Size MB"
,ceil(space_used / 1024 / 1024) "Used MB"
from v$recovery_file_dest
order by name  2    3    4    5
  6  /

NAME
--------------------------------------------------------------------------------
   Size MB    Used MB
---------- ----------
/home/oracle/10.2.0/product/flash_recovery_area
      2048       2034

Now you can increase the size of    flash_recovery_area

SQL> alter system set db_recovery_file_dest_size = 5G scope=both;

System altered.

SQL>  alter database open;

Database altered.


You can also  delete the  expired archive logs

 RMAN> crosscheck archivelog all;
 RMAN> delete expired archivelog all;

Thursday, 9 May 2013

Recove datafile without backup

IF you newly created datafile has gone and you didn’t get change to take backup after creation if your database in archive mode then you will be recover the datafile just you need to create the datafile before recovery.   


SQL> startup
ORACLE instance started.

Total System Global Area  910163968 bytes
Fixed Size                  2024976 bytes
Variable Size             268438000 bytes
Database Buffers          633339904 bytes
Redo Buffers                6361088 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01110: data file 5: '/home/oracle/10.2.0/product/oradata/MYDB/users02.dbf'

You cant restore the datafile as you don’t have backup .hence you have to create a datafile as reference of old datafile. And recover datafile

SQL>  alter database create datafile '/home/oracle/10.2.0/product/oradata/MYDB/users02.dbf' AS '/home/oracle/10.2.0/product/oradata/MYDB/users02.dbf'  ;

Database altered.

SQL> reocver datafile 5;
SP2-0734: unknown command beginning "reocver da..." - rest of line ignored.
SQL> recover datafile 5;
ORA-00279: change 578628 generated at 05/08/2013 09:17:47 needed for thread 1
ORA-00289: suggestion :
/home/oracle/10.2.0/product/flash_recovery_area/MYDB/archivelog/2013_05_09/o1_mf
_1_5_%u_.arc
ORA-00280: change 578628 for thread 1 is in sequence #5


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
ORA-00279: change 623425 generated at 05/08/2013 10:26:43 needed for thread 1
ORA-00289: suggestion :
/home/oracle/10.2.0/product/flash_recovery_area/MYDB/archivelog/2013_05_09/o1_mf
_1_6_%u_.arc
ORA-00280: change 623425 for thread 1 is in sequence #6
ORA-00278: log file
'/home/oracle/10.2.0/product/flash_recovery_area/MYDB/archivelog/2013_05_08/o1_m
f_1_5_8rmprcx7_.arc' no longer needed for this recovery


ORA-00279: change 727053 generated at 05/08/2013 11:11:46 needed for thread 1
ORA-00289: suggestion :
/home/oracle/10.2.0/product/flash_recovery_area/MYDB/archivelog/2013_05_09/o1_mf
_1_7_%u_.arc
ORA-00280: change 727053 for thread 1 is in sequence #7
ORA-00278: log file
'/home/oracle/10.2.0/product/flash_recovery_area/MYDB/archivelog/2013_05_08/o1_m
f_1_6_8rmsdtrz_.arc' no longer needed for this recovery


ORA-00279: change 727988 generated at 05/08/2013 11:12:26 needed for thread 1
ORA-00289: suggestion :
/home/oracle/10.2.0/product/flash_recovery_area/MYDB/archivelog/2013_05_09/o1_mf
_1_8_%u_.arc
ORA-00280: change 727988 for thread 1 is in sequence #8
ORA-00278: log file
'/home/oracle/10.2.0/product/flash_recovery_area/MYDB/archivelog/2013_05_08/o1_m
f_1_7_8rmsg2lw_.arc' no longer needed for this recovery


Log applied.
Media recovery complete.

SQL>  alter database open;

Database altered.



After open the database you can check the status of  datafile


SQL>  select file_name,status from v$datafile;
 select file_name,status from v$datafile
        *
ERROR at line 1:
ORA-00904: "FILE_NAME": invalid identifier


SQL> select name ,status from v$datafile;

NAME
--------------------------------------------------------------------------------
STATUS
-------
/home/oracle/10.2.0/product/oradata/MYDB/system01.dbf
SYSTEM

/home/oracle/10.2.0/product/oradata/MYDB/undotbs01.dbf
ONLINE

/home/oracle/10.2.0/product/oradata/MYDB/sysaux01.dbf
ONLINE


NAME
--------------------------------------------------------------------------------
STATUS
-------
/home/oracle/10.2.0/product/oradata/MYDB/users01.dbf
ONLINE

/home/oracle/10.2.0/product/oradata/MYDB/users02.dbf
ONLINE