|
发表于 2014-7-15 10:47:49
|
显示全部楼层
9b_当前控制文件损坏_下线user表空间完全恢复_用控制文件脚本_不需备份
文件系统模拟环境:
#!/bin/sh
###
### 1 Main Section Begin
###
# 0 Machine ID Begin
echo ""
echo "---------------------------------------------- LAB 9b ----------------------------------------------"
echo "当前控制文件损坏_下线user表空间完全恢复_用控制文件脚本_不需备份"
echo "---------------------------------------------- LAB 9b ----------------------------------------------"
echo ""
echo ""
echo "******************"
echo "你的主机信息如下:"
echo "******************"
ifconfig eth0 | head -n2 | tail -n1 | cut -f 2 -d : | cut -f 1 -d ' '
echo ""
hostname
echo ""
uname -a
echo ""
echo ""
# 0 Machine ID End
# 1 Oracle Open Test Begin
su - oracle -c "sqlplus /nolog" << EOF
conn / as sysdba
set echo off
set feedback off
@/home/oracle/ptable.sql;
quit
EOF
echo " "
# 1 Oracle Open Test End
# 2 Create Table Begin
su - oracle -c "sqlplus /nolog" << EOF
conn / as sysdba
set echo off
set feedback off
@/home/oracle/ctable.sql;
quit
EOF
echo ""
# 2 Create Table End
# 3 PreDelete Shutdown Yes/No Begin
su - oracle -c "rman target /" << EOF
delete noprompt backup of controlfile;
delete noprompt copy of controlfile;
EOF
echo ""
echo "***BEFORE TABLESPACE OFFLINE***"
echo "Next moment control script is going to be create ......"
echo "Display the spid number of session here: "
su - oracle -c "sqlplus /nolog" << EOF
conn / as sysdba
select spid from v\$process p , v\$session s , v\$mystat m where p.addr=s.paddr and m.sid=s.sid and rownum=1;
alter database backup controlfile to trace;
quit
EOF
echo ""
su - oracle -c "sqlplus /nolog" << EOF
conn / as sysdba
alter tablespace users offline;
quit
EOF
echo ""
echo "***AFTER TABLESPACE OFFLINE***"
echo "Next moment control script is going to be create ......"
echo "Display the spid number of session here: "
su - oracle -c "sqlplus /nolog" << EOF
conn / as sysdba
select spid from v\$process p , v\$session s , v\$mystat m where p.addr=s.paddr and m.sid=s.sid and rownum=1;
alter database backup controlfile to trace;
quit
EOF
echo ""
# 3 PreDelete Shutdown Yes/No End
# 4 Delete Files Begin
find /u01/app/oracle/oradata -not -wholename "*rman*" -not -wholename "*emrep*" -a -name "*.ctl" -exec rm -f {} \;
find /u01/app/oracle/flash_recovery_area -name "*.ctl" -exec rm -f {} \;
#find /u01/app/oracle/flash_recovery_area -name "*XXX*.dbf" -exec rm -f {} \;
#find /u01/app/oracle/admin -name "*XXX*" -exec rm -f {} \;
#find /u01/app/oracle/product/10.2.0/db_1/dbs -name "*XXX*" -exec rm -f {} \;
echo ""
#su - oracle -c " export ORACLE_SID=+ASM; asmcmd "<<EOF
#EOF
#echo ""
# 4 Delete Files End
# 5 AfterDelete Test Begin
su - oracle -c "sqlplus /nolog" << EOF
conn / as sysdba
set echo off
set feedback off
@/home/oracle/ttable.sql;
quit
EOF
echo " "
# 5 AfterDelete Test End
# 6 AfterDelete Shutdown Yes/No Begin
su - oracle -c "sqlplus /nolog" << EOF
conn / as sysdba
set echo off
set feedback off
shutdown abort
quit
EOF
echo ""
# 6 AfterDelete Shutdown Yes/No End
# 7 Get Clear Begin
rm -f /home/oracle/ptable.sql
rm -f /home/oracle/ctable.sql
rm -f /home/oracle/ttable.sql
rm -f /usr/bin/bclcustom.sh
# 7 Get Clear End
echo "THE END"
###
### 1 Main Section End
###
sql 文件: ctable.sql
--drop table hr.edu234;
--
set echo off
set feedback off
select * from sys.tname;
create table hr.edu234 ( a number ) tablespace users;
alter system switch logfile;
insert into hr.edu234 values(1);
alter system switch logfile;
commit;
alter system switch logfile;
insert into hr.edu234 values(2);
alter system switch logfile;
commit;
insert into hr.edu234 values(3);
alter system switch logfile;
commit;
insert into hr.edu234 values(4);
alter system switch logfile;
commit;
insert into hr.edu234 values(5);
commit;
--
set serveroutput on
exec dbms_output.put_line(' ');
exec dbms_output.put_line('************************** ');
exec dbms_output.put_line('Table successfully created.');
exec dbms_output.put_line('************************** ');
exec dbms_output.put_line(' ');
~
环境模拟得有偏差,是下线不是删除
|
|