块损坏模拟+恢复

来源:互联网 发布:窗帘销售软件 编辑:程序博客网 时间:2024/05/16 16:46
SQL> create tablespace test datafile '/u01/app/oracle/oradata/orcldg/test.dbf' size 1m;Tablespace created.SQL> create user test identified by test default tablespace test;User created.SQL> grant dba to test;Grant succeeded.SQL> conn test/testConnected.SQL> create table test1(id number,name varchar2(100));Table created.SQL> declare  2  begin  3  for i in 1..100 loop  4  insert into test1 values(i,'liming'||i);  5  end loop;  6  commit;  7  end;  8   /PL/SQL procedure successfully completed.一直搞到ERROR at line 1:ORA-01653: unable to extend table TEST.TEST2 by 8 in tablespace TESTORA-06512: at line 4SQL> select count(1) from test1;  COUNT(1)----------     40002关掉数据库,破坏数据文件。[oracle@lmsingledg orcldg]$ cd /u01/app/oracle/oradata/orcldg/[oracle@lmsingledg orcldg]$ vi test.dbf眼花,随便找一个不是数据的乱码,删掉。ORACLE instance shut down.SQL> startupORACLE instance started.Total System Global Area 1603411968 bytesFixed Size                  2253664 bytesVariable Size             989858976 bytesDatabase Buffers          603979776 bytesRedo Buffers                7319552 bytesDatabase mounted.Database opened.SQL> conn test/testselect * from test1;ERROR:ORA-01578: ORACLE data block corrupted (file # 5, block # 13)ORA-01110: data file 5: '/u01/app/oracle/oradata/orcldg/test.dbf'750 rows selected.SQL> SELECT tablespace_name, segment_type, owner, segment_name FROM dba_extents WHERE file_id = 5 and 13 between block_id AND block_id + blocks - 1 ;TABLESPACE_NAME                SEGMENT_TYPE       OWNER------------------------------ ------------------ ------------------------------SEGMENT_NAME--------------------------------------------------------------------------------TEST                           TABLE              TESTTEST1果断看备份。RMAN> list backup of datafile 5;using target database control file instead of recovery catalogspecification does not match any backup in the repository这时候导出数据:[oracle@lmsingledg ~]$ exp test/test tables=test1 file=/home/oracle/test3.dmpExport: Release 11.2.0.4.0 - Production on Thu Oct 22 22:34:17 2015Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsExport done in US7ASCII character set and AL16UTF16 NCHAR character setserver uses ZHS16GBK character set (possible charset conversion)About to export specified tables via Conventional Path .... . exporting table                          TEST1EXP-00056: ORACLE error 1578 encounteredORA-01578: ORACLE data block corrupted (file # 5, block # 13)ORA-01110: data file 5: '/u01/app/oracle/oradata/orcldg/test.dbf'Export terminated successfully with warnings.[oracle@lmsingledg ~]$设置内部事件,导出的时候跳出这些块。SQL> ALTER SYSTEM SET EVENTS='10231 trace name context forever,level 10' ;System altered.[oracle@lmsingledg ~]$ exp test/test tables=test1 file=/home/oracle/test2.dmpExport: Release 11.2.0.4.0 - Production on Thu Oct 22 22:35:44 2015Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsExport done in US7ASCII character set and AL16UTF16 NCHAR character setserver uses ZHS16GBK character set (possible charset conversion)About to export specified tables via Conventional Path .... . exporting table                          TEST1        756 rows exportedEXP-00091: Exporting questionable statistics.Export terminated successfully with warnings.就导出了756条数据。最后,取消设置alter system set events='10231 trace name context off';损失了40002-756条数据。把表drop了,重新建表,插数。所以说,备份是必须的,多么痛的领悟呀。






0 0