Oracle数据库数据恢复、性能优化

找回密码
注册
搜索
热搜: 活动 交友 discuz
发新帖

133

积分

0

好友

17

主题
1#
发表于 2014-5-26 11:26:19 | 查看: 5039| 回复: 3
本帖最后由 saup007 于 2014-5-26 11:53 编辑

内部使用的数据库,之前断电了,undo坏块了,尝试使用隐藏参数,库启来了。(虽然有备份)但,最后还是用备份恢复一次。

今天早上来公司,alter还是有坏块!
  1. Fri May 23 22:00:05 2014
  2. GATHER_STATS_JOB encountered errors.  Check the trace file.
  3. Fri May 23 22:00:05 2014
  4. Errors in file /u01/app/oracle/admin/MYSID/bdump/MYSID_j001_16658.trc:
  5. ORA-01578: ORACLE data block corrupted (file # 3, block # 50481)
  6. ORA-01110: data file 3: '/u01/oradata/MYSID/sysaux.dbf'         


  7. Sat May 24 06:00:05 2014
  8. Errors in file /u01/app/oracle/admin/MYSID/bdump/MYSID_j001_12393.trc:
  9. ORA-01578: ORACLE data block corrupted (file # 3, block # 50481)
  10. ORA-01110: data file 3: '/u01/oradata/MYSID/sysaux.dbf'
复制代码
从trace文件可知,是收集统计信息是,报的错:
  1. $ vim /u01/app/oracle/admin/MYSID/bdump/MYSID_j001_12393.trc
  2. /u01/app/oracle/admin/MYSID/bdump/MYSID_j001_12393.trc
  3. Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
  4. With the Partitioning, OLAP, Data Mining and Real Application Testing options
  5. ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1
  6. System name:    Linux
  7. Node name:      MYSID1
  8. Release:        2.6.9-55.ELsmp
  9. Version:        #1 SMP Fri Apr 20 17:03:35 EDT 2007
  10. Machine:        i686
  11. Instance name: MYSID
  12. Redo thread mounted by this instance: 1
  13. Oracle process number: 31
  14. Unix process pid: 12393, image: oracle@MYSID1 (J001)

  15. *** ACTION NAME:(GATHER_STATS_JOB) 2014-05-24 06:00:05.678
  16. *** MODULE NAME:(DBMS_SCHEDULER) 2014-05-24 06:00:05.678
  17. *** SERVICE NAME:(SYS$USERS) 2014-05-24 06:00:05.678
  18. *** SESSION ID:(1090.6978) 2014-05-24 06:00:05.678
  19. ORA-01578: ORACLE data block corrupted (file # 3, block # 50481)
  20. ORA-01110: data file 3: '/u01/oradata/MYSID/sysaux.dbf'
  21. *** 2014-05-24 06:00:05.679
  22. GATHER_STATS_JOB: GATHER_TABLE_STATS('"SYS"','"WRH$_COMP_IOSTAT"','""', ...)
  23. ORA-01578: ORACLE data block corrupted (file # 3, block # 50481)
  24. ORA-01110: data file 3: '/u01/oradata/MYSID/sysaux.dbf'
复制代码
查看坏块:
  1. SQL> select * from v$database_block_corruption;

  2.      FILE#     BLOCK#     BLOCKS CORRUPTION_CHANGE# CORRUPTION_TYPE
  3. ---------- ---------- ---------- ------------------ ---------------
  4.          2          2          1                  0 CORRUPT
  5.          3      50481          1                  0 CORRUPT

  6. SQL>
  7. SQL>
  8. SQL>
  9. SQL> SELECT tablespace_name, segment_type, owner, segment_name
  10.   2    FROM dba_extents
  11.   3   WHERE file_id = 3
  12.   4     and 50481 between block_id AND block_id + blocks - 1;
  13.   

  14. TABLESPACE_NAME                SEGMENT_TYPE       OWNER                          SEGMENT_NAME
  15. ------------------------------ ------------------ ------------------------------ ------------------------------------
  16. SYSAUX                         TABLE              SYS                            WRH$_COMP_IOSTAT
  17. SQL> SELECT tablespace_name, segment_type, owner, segment_name
  18.   2    FROM dba_extents
  19.   3   WHERE file_id = 2
  20.   4     and 2 between block_id AND block_id + blocks - 1;

  21. TABLESPACE_NAME                SEGMENT_TYPE       OWNER                          SEGMENT_NAME
  22. ------------------------------ ------------------ ------------------------------ ---------------------------------------------------------------------------
复制代码
file_id =2 应该是原来undo上的坏块,但现在已经没有对应的数据库对象了,只有sysaux有一条记录...
  1. $ dbv file=/u01/oradata/MYSID/sysaux.dbf blocksize=8192

  2. DBVERIFY: Release 10.2.0.4.0 - Production on Mon May 26 11:52:27 2014

  3. Copyright (c) 1982, 2007, Oracle.  All rights reserved.

  4. DBVERIFY - Verification starting : FILE = /u01/oradata/MYSID/sysaux.dbf

  5. DBV-00200: Block, DBA 12633393, already marked corrupt


  6. DBVERIFY - Verification complete

  7. Total Pages Examined         : 86016
  8. Total Pages Processed (Data) : 38261
  9. Total Pages Failing   (Data) : 0
  10. Total Pages Processed (Index): 24716
  11. Total Pages Failing   (Index): 0
  12. Total Pages Processed (Other): 14080
  13. Total Pages Processed (Seg)  : 0
  14. Total Pages Failing   (Seg)  : 0
  15. Total Pages Empty            : 8959
  16. Total Pages Marked Corrupt   : 1
  17. Total Pages Influx           : 0
  18. Highest block SCN            : 1608730663 (0.1608730663)
复制代码
2#
发表于 2014-5-26 11:30:41
本帖最后由 saup007 于 2014-5-26 11:46 编辑
  1. sys@MYSID> select count(1) from sys.WRH$_COMP_IOSTAT; --走索引,所以能count

  2.   COUNT(1)
  3. ----------
  4.       1542

  5. sys@MYSID> select * from sys.WRH$_COMP_IOSTAT;  -- 这种走全表了

  6. ...........
  7. ...........
  8. ERROR:
  9. ORA-01578: ORACLE data block corrupted (file # 3, block # 50481)
  10. ORA-01110: data file 3: '/u01/oradata/EUIS/sysaux.dbf'
  11. 600 rows selected.

复制代码
我需要按PO主的文章:http://www.askmaclean.com/archives/how-rebuild-create-sysaux-tablespace.html

重建SYSAUX上的对象吗?

或许有其他方法吗?

非常感谢。

回复 只看该作者 道具 举报

3#
发表于 2014-5-26 11:44:07
RMAN 好象不能恢复!
  1. RMAN> blockrecover datafile 3 block 50481;

  2. Starting blockrecover at 26-MAY-14
  3. using target database control file instead of recovery catalog
  4. allocated channel: ORA_DISK_1
  5. channel ORA_DISK_1: sid=1094 devtype=DISK
  6. allocated channel: ORA_DISK_2
  7. channel ORA_DISK_2: sid=1080 devtype=DISK

  8. channel ORA_DISK_1: restoring block(s)
  9. channel ORA_DISK_1: specifying block(s) to restore from backup set
  10. restoring blocks of datafile 00003
  11. channel ORA_DISK_1: reading from backup piece /u01/backup/rmanbak/bak_level0/data_level0_20140525_MYSID_16568_1_1.bak1
  12. channel ORA_DISK_1: restored block(s) from backup piece 1
  13. piece handle=/u01/backup/rmanbak/bak_level0/data_level0_20140525_MYSID_16568_1_1.bak1 tag=LEVEL0_DATA
  14. channel ORA_DISK_1: block restore complete, elapsed time: 00:00:26
  15. failover to previous backup

  16. channel ORA_DISK_1: restoring block(s)
  17. channel ORA_DISK_1: specifying block(s) to restore from backup set
  18. restoring blocks of datafile 00003
  19. channel ORA_DISK_1: reading from backup piece /u01/saup/rman_standby/orcl_3tp8ri6c_1_1_20140521.dbf
  20. channel ORA_DISK_1: restored block(s) from backup piece 1
  21. piece handle=/u01/saup/rman_standby/orcl_3tp8ri6c_1_1_20140521.dbf tag=TAG20140521T135940
  22. channel ORA_DISK_1: block restore complete, elapsed time: 00:00:35
  23. failover to previous backup

  24. RMAN-00571: ===========================================================
  25. RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
  26. RMAN-00571: ===========================================================
  27. RMAN-03002: failure of blockrecover command at 05/26/2014 10:34:41
  28. RMAN-06026: some targets not found - aborting restore
  29. RMAN-06023: no backup or copy of datafile 3 found to restore

  30. RMAN> exit
复制代码

回复 只看该作者 道具 举报

4#
发表于 2014-5-27 16:08:00
  1. 操作步骤:

  2. show parameter cluster_database
  3. show parameter statistics_level
  4. show parameter sga_target

  5. create pfile='?/dbs/init@.ora.20140527' from spfile;

  6. alter system set shared_pool_size = 200m scope = spfile;
  7. alter system set db_cache_size = 300m scope = spfile;
  8. alter system set java_pool_size = 100 scope = spfile;
  9. alter system set large_pool_size = 50 scope = spfile;
  10. --alter system reset sga_target scope= spfile;        --这二个在10g不能执行,memory_target是11g参数!改为设置sga_target为0
  11. --alter system reset memory_target scope= spfile;  
  12. alter system set statistics_level=basic scope=spfile;

  13. alter system set sga_target=0 scope=spfile;

  14. shutdown immediate
  15. startup restrict

  16. @?/rdbms/admin/catnoawr.sql

  17. alter system flush shared_pool;

  18. @?/rdbms/admin/catawrtb.sql     「@?/rdbms/admin/catsvrm.sql –in the script had calls catawrtb.sql,我看了下,11g中catsvrm.sql不包含catawrtb.sql」


  19. 此处报二个type已经存在,此时我忽略了

  20. create type AWRSQRPT_TEXT_TYPE
  21.             *
  22. ERROR at line 1:
  23. ORA-00955: name is already used by an existing object


  24. create type AWRSQRPT_TEXT_TYPE_TABLE
  25.             *
  26. ERROR at line 1:
  27. ORA-00955: name is already used by an existing object


  28. 编译

  29. start ?/rdbms/admin/utlrp.sql

  30. select owner,object_name from dba_objects where status='INVALID';

  31. 参考(文档 ID 782974.1) 检查下

  32. shutdown immediate

  33. create spfile from pfile='?/dbs/init@.ora.20140527' ;

  34. startup

  35. 测试

  36. exec dbms_workload_repository.create_snapshot;

  37. 隔几分钟

  38. exec dbms_workload_repository.create_snapshot;

  39. @?/rdbms/admin/awrrpt.sql



  40.                                                         Snap
  41. Instance     DB Name        Snap Id    Snap Started    Level
  42. ------------ ------------ --------- ------------------ -----
  43. MYSID         MYSID                 1 27 May 2014 15:39      1
  44.                                   2 27 May 2014 15:42      1



  45. rman检查下:

  46. RMAN> backup validate check logical datafile 3;

  47. 记录依然存在,这个可能是BUG

  48. sys@MYSID> select * from v$database_block_corruption;

  49.      FILE#     BLOCK#       BLOCKS CORRUPTION_CHANGE# CORRUPTIO
  50. ---------- ---------- ---------- ------------------ ---------
  51.      2         2            1            0 CORRUPT
  52.      3     50481            1            0 CORRUPT

  53. 收集此表统计信息没有问题了

  54. begin
  55.   dbms_stats.gather_table_stats(ownname => 'SYS',tabname => 'WRH$_COMP_IOSTAT' ,estimate_percent => 5  ,cascade => true);
  56. end;
  57. /
复制代码

回复 只看该作者 道具 举报

您需要登录后才可以回帖 登录 | 注册

QQ|手机版|Archiver|Oracle数据库数据恢复、性能优化

GMT+8, 2024-12-21 04:00 , Processed in 0.046286 second(s), 20 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部
TEL/電話+86 13764045638
Email service@parnassusdata.com
QQ 47079569