Download the script to check the Database Block Corruption from HERE.
[oracle@node1 script]$ more logical_corruption.sh
#!/bin/bash
clear scr
echo "******************************************************"
echo "************ Checking Logical Corruption *************"
echo "******************************************************"
sqlplus -S / as sysdba@$1<<EOF
Prompt Checking the database for Block corruption;
spool /tmp/p1.txt
select * from v\$database_block_corruption;
exit;
spool off
EOF
output=`cat /tmp/p1.txt`
if [ -z "$output" ]; then
echo "Please Perform Validate Check for Logical Database"
exit;
fi
rm -f /tmp/p1.txt
echo "Checking For Physical and Logical Corruption in Database"
rman target=/ <<EOF
validate check logical database;
EOF
sqlplus -S / as sysdba@$1<<EOF
prompt Again Checking the database for Block corruption;
select * from v\$database_block_corruption;
exit;
EOF
echo "Do you wish to Recover the Corrupted Database Blocks"
read answer
if [[ "$answer" =~ Y|y ]]; then
echo "Recovering Corrupted Data Blocks"
rman target=/ <<EOF
recover corruption list;
exit;
EOF
fi
[oracle@node1 script]$ more logical_corruption.sh
#!/bin/bash
clear scr
echo "******************************************************"
echo "************ Checking Logical Corruption *************"
echo "******************************************************"
sqlplus -S / as sysdba@$1<<EOF
Prompt Checking the database for Block corruption;
spool /tmp/p1.txt
select * from v\$database_block_corruption;
exit;
spool off
EOF
output=`cat /tmp/p1.txt`
if [ -z "$output" ]; then
echo "Please Perform Validate Check for Logical Database"
exit;
fi
rm -f /tmp/p1.txt
echo "Checking For Physical and Logical Corruption in Database"
rman target=/ <<EOF
validate check logical database;
EOF
sqlplus -S / as sysdba@$1<<EOF
prompt Again Checking the database for Block corruption;
select * from v\$database_block_corruption;
exit;
EOF
echo "Do you wish to Recover the Corrupted Database Blocks"
read answer
if [[ "$answer" =~ Y|y ]]; then
echo "Recovering Corrupted Data Blocks"
rman target=/ <<EOF
recover corruption list;
exit;
EOF
fi
OUTPUT.
[oracle@node1 script]$ sh logical_corruption.sh node1
******************************************************
************ Checking Logical Corruption *************
******************************************************
Checking the database for Block corruption
no rows selected
Checking For Physical and Logical Corruption in Database
Recovery Manager: Release 11.2.0.3.0 - Production on Fri Nov 29 00:54:39 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: NODE (DBID=873107756)
RMAN>
RMAN>
Starting validate at 29-NOV-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=68 instance=node1 device type=DISK
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
user interrupt received
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of validate command on ORA_DISK_1 channel at 11/29/2013 00:54:42
ORA-01013: user requested cancel of current operation
RMAN>
RMAN>
Recovery Manager complete.
Again Checking the database for Block corruption
no rows selected
Do you wish to Recover the Corrupted Database Blocks
Yes
Recovering Corrupted Data Blocks
Recovery Manager: Release 11.2.0.3.0 - Production on Fri Nov 29 00:54:48 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: NODE (DBID=873107756)
RMAN>
RMAN>
Starting recover at 29-NOV-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=69 instance=node1 device type=DISK
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 29-NOV-13
RMAN>
RMAN>
Recovery Manager complete.
No comments:
Post a Comment