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

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

73

积分

0

好友

0

主题
1#
发表于 2012-2-2 22:01:52 | 查看: 9582| 回复: 10
DB:
SQL> select * from v$version
  2  /
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE    10.2.0.1.0      Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

OS :win2003

在DG 中 我模拟主库当机(停掉所有服务)


我把备库切换为主库
备库操作:
alter database commit to switchover to primary with session shutdown

在这里HANG在这里

看了告警日志
Switchover: Media recovery is still active
If media recovery active, switchover will wait 900 seconds
Thu Feb 02 21:36:04 2012
Switchover: Media recovery is still active
If media recovery active, switchover will wait 900 seconds
2#
发表于 2012-2-2 22:06:01
跑一下这个脚本
  1. SELECT DECODE(os_backup.backup + rman_backup.backup, 0, 'FALSE', 'TRUE') backup
  2.   FROM (SELECT COUNT(*) backup FROM gv$backup WHERE status = 'ACTIVE') os_backup,
  3.        (SELECT COUNT(*) backup
  4.           FROM gv$session
  5.          WHERE status = 'ACTIVE'
  6.            AND client_info like '%rman%') rman_backup
  7. /
复制代码

回复 只看该作者 道具 举报

3#
发表于 2012-2-2 22:07:28

回复 2# 的帖子

SQL> SELECT DECODE(os_backup.backup + rman_backup.backup, 0, 'FALSE', 'TRUE') ba
ckup
  2  FROM (SELECT COUNT(*) backup FROM gv$backup WHERE status = 'ACTIVE') os_bac
kup,
  3  (SELECT COUNT(*) backup          FROM gv$session         WHERE status = 'AC
TIVE'           AND client_info like '%rman%') rman_backup
  4  /

BACKU
-----
FALSE

回复 只看该作者 道具 举报

4#
发表于 2012-2-2 22:11:44
跑一下 physical standby 上
  1. - - - - - - - - - - - - - - - - Script begins here - - - - - - - - - - - - - - - -

  2. -- NAME: DG_phy_stby_diag.sql
  3. -- ------------------------------------------------------------------------
  4. -- AUTHOR:
  5. --    Michael Smith - Oracle Support Services - DataServer Group
  6. --    Copyright 2002, Oracle Corporation
  7. -- ------------------------------------------------------------------------
  8. -- PURPOSE:
  9. --    This script is to be used to assist in collection information to help
  10. --    troubeshoot Data Guard issues.
  11. -- ------------------------------------------------------------------------
  12. -- DISCLAIMER:
  13. --    This script is provided for educational purposes only. It is NOT
  14. --    supported by Oracle World Wide Technical Support.
  15. --    The script has been tested and appears to work as intended.
  16. --    You should always run new scripts on a test instance initially.
  17. -- ------------------------------------------------------------------------
  18. -- Script output is as follows:

  19. set echo off
  20. set feedback off
  21. column timecol new_value timestamp
  22. column spool_extension new_value suffix
  23. select to_char(sysdate,'Mondd_hhmi') timecol,
  24. '.out' spool_extension from sys.dual;
  25. column output new_value dbname
  26. select value || '_' output
  27. from v$parameter where name = 'db_name';
  28. spool dgdiag_phystby_&&dbname&&timestamp&&suffix
  29. set lines 200
  30. set pagesize 35
  31. set trim on
  32. set trims on
  33. alter session set nls_date_format = 'MON-DD-YYYY HH24:MI:SS';
  34. set feedback on
  35. select to_char(sysdate) time from dual;

  36. set echo on

  37. --
  38. -- ARCHIVER can be  (STOPPED | STARTED | FAILED) FAILED means that the archiver failed
  39. -- to archive a -- log last time, but will try again within 5 minutes. LOG_SWITCH_WAIT
  40. -- The ARCHIVE LOG/CLEAR LOG/CHECKPOINT event log switching is waiting for. Note that
  41. -- if ALTER SYSTEM SWITCH LOGFILE is hung, but there is room in the current online
  42. -- redo log, then value is NULL

  43. column host_name format a20 tru
  44. column version format a9 tru
  45. select instance_name,host_name,version,archiver,log_switch_wait from v$instance;

  46. -- The following select will give us the generic information about how this standby is
  47. -- setup.  The database_role should be standby as that is what this script is intended
  48. -- to be ran on.  If protection_level is different than protection_mode then for some
  49. -- reason the mode listed in protection_mode experienced a need to downgrade.  Once the
  50. -- error condition has been corrected the protection_level should match the protection_mode
  51. -- after the next log switch.

  52. column ROLE format a7 tru
  53. select name,database_role,log_mode,controlfile_type,protection_mode,protection_level
  54. from v$database;

  55. -- Force logging is not mandatory but is recommended.  Supplemental logging should be enabled
  56. -- on the standby if a logical standby is in the configuration. During normal
  57. -- operations it is acceptable for SWITCHOVER_STATUS to be SESSIONS ACTIVE or NOT ALLOWED.

  58. column force_logging format a13 tru
  59. column remote_archive format a14 tru
  60. column dataguard_broker format a16 tru
  61. select force_logging,remote_archive,supplemental_log_data_pk,supplemental_log_data_ui,
  62. switchover_status,dataguard_broker from v$database;

  63. -- This query produces a list of all archive destinations and shows if they are enabled,
  64. -- what process is servicing that destination, if the destination is local or remote,
  65. -- and if remote what the current mount ID is. For a physical standby we should have at
  66. -- least one remote destination that points the primary set but it should be deferred.

  67. COLUMN destination FORMAT A35 WRAP
  68. column process format a7
  69. column archiver format a8
  70. column ID format 99

  71. select dest_id "ID",destination,status,target,
  72. archiver,schedule,process,mountid
  73. from v$archive_dest;

  74. -- If the protection mode of the standby is set to anything higher than max performance
  75. -- then we need to make sure the remote destination that points to the primary is set
  76. -- with the correct options else we will have issues during switchover.

  77. select dest_id,process,transmit_mode,async_blocks,
  78. net_timeout,delay_mins,reopen_secs,register,binding
  79. from v$archive_dest;

  80. -- The following select will show any errors that occured the last time an attempt to
  81. -- archive to the destination was attempted.  If ERROR is blank and status is VALID then
  82. -- the archive completed correctly.

  83. column error format a55 tru
  84. select dest_id,status,error from v$archive_dest;

  85. -- Determine if any error conditions have been reached by querying thev$dataguard_status
  86. -- view (view only available in 9.2.0 and above):

  87. column message format a80
  88. select message, timestamp
  89. from v$dataguard_status
  90. where severity in ('Error','Fatal')
  91. order by timestamp;

  92. -- The following query is ran to get the status of the SRL's on the standby.  If the
  93. -- primary is archiving with the LGWR process and SRL's are present (in the correct
  94. -- number and size) then we should see a group# active.

  95. select group#,sequence#,bytes,used,archived,status from v$standby_log;

  96. -- The above SRL's should match in number and in size with the ORL's returned below:

  97. select group#,thread#,sequence#,bytes,archived,status from v$log;

  98. -- Query v$managed_standby to see the status of processes involved in the
  99. -- configuration.

  100. select process,status,client_process,sequence#,block#,active_agents,known_agents
  101. from v$managed_standby;

  102. -- Verify that the last sequence# received and the last sequence# applied to standby
  103. -- database.

  104. select al.thrd "Thread", almax "Last Seq Received", lhmax "Last Seq Applied"
  105. from (select thread# thrd, max(sequence#) almax
  106. from v$archived_log
  107. where resetlogs_change#=(select resetlogs_change# from v$database)
  108. group by thread#) al,
  109. (select thread# thrd, max(sequence#) lhmax
  110. from v$log_history
  111. where first_time=(select max(first_time) from v$log_history)
  112. group by thread#) lh
  113. where al.thrd = lh.thrd;

  114. -- The V$ARCHIVE_GAP fixed view on a physical standby database only returns the next
  115. -- gap that is currently blocking redo apply from continuing. After resolving the
  116. -- identified gap and starting redo apply, query the V$ARCHIVE_GAP fixed view again
  117. -- on the physical standby database to determine the next gap sequence, if there is
  118. -- one.

  119. select * from v$archive_gap;

  120. -- Non-default init parameters.

  121. set numwidth 5
  122. column name format a30 tru
  123. column value format a50 wra
  124. select name, value
  125. from v$parameter
  126. where isdefault = 'FALSE';

  127. spool off

  128. - - - - - - - - - - - - - - - -  Script ends here  - - - - - - - - - - - - - - - -
复制代码
tail -5000 alert*.log

把 mrp 进程的 trace 也上传

回复 只看该作者 道具 举报

5#
发表于 2012-2-2 22:38:12
告警信息

Thu Feb 02 21:04:35 2012
alter database recover managed standby database disconnect from session
MRP0 started with pid=18, OS id=3480
Managed Standby Recovery not using Real Time Apply
Media Recovery Log D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\ORCL\LOG1_65_771764791.ARC
Thu Feb 02 21:04:41 2012
Completed: alter database recover managed standby database disconnect from session
Thu Feb 02 21:04:45 2012
Media Recovery Log D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\ORCL\ORCL02_ARCHIVE\LOG1_66_771764791.ARC
Media Recovery Waiting for thread 1 sequence 67
Thu Feb 02 21:06:04 2012
alter database commit to switchover to primary with session shutdown
Thu Feb 02 21:06:04 2012
If media recovery active, switchover will wait 900 seconds
Thu Feb 02 21:18:25 2012
db_recovery_file_dest_size of 2048 MB is 0.00% used. This is a
user-specified limit on the amount of space that will be used by this
database for recovery-related files, and does not reflect the amount of
space available in the underlying filesystem or ASM diskgroup.
Thu Feb 02 21:21:04 2012
Switchover: Media recovery is still active
If media recovery active, switchover will wait 900 seconds
Thu Feb 02 21:36:04 2012
Switchover: Media recovery is still active
If media recovery active, switchover will wait 900 seconds
Thu Feb 02 21:51:04 2012
Switchover: Media recovery is still active
If media recovery active, switchover will wait 900 seconds
Thu Feb 02 22:06:04 2012

db_orcl.rar

3.88 KB, 下载次数: 1371

回复 只看该作者 道具 举报

6#
发表于 2012-2-2 22:49:34
ODM FIND:
  1. SQL> select process,status,client_process,sequence#,block#,active_agents,known_agents
  2.   2  from v$managed_standby;

  3. PROCESS STATUS       CLIENT_P SEQUENCE# BLOCK# ACTIVE_AGENTS KNOWN_AGENTS
  4. ------- ------------ -------- --------- ------ ------------- ------------
  5. ARCH    CONNECTED    ARCH             0      0             0            0
  6. ARCH    CONNECTED    ARCH             0      0             0            0
  7. MRP0    WAIT_FOR_LOG N/A             67      0             0            0


  8. MRP 在等日志 67

  9. SQL> -- The V$ARCHIVE_GAP fixed view on a physical standby database only returns the next
  10. SQL> -- gap that is currently blocking redo apply from continuing. After resolving the
  11. SQL> -- identified gap and starting redo apply, query the V$ARCHIVE_GAP fixed view again
  12. SQL> -- on the physical standby database to determine the next gap sequence, if there is
  13. SQL> -- one.
  14. SQL>
  15. SQL> select * from v$archive_gap;

  16. 未选定行


  17. 没有archive gap

  18. SQL> select group#,sequence#,bytes,used,archived,status from v$standby_log;

  19. GROUP# SEQUENCE# BYTES  USED ARC STATUS
  20. ------ --------- ----- ----- --- ----------
  21.      5         0 #####   512 NO  UNASSIGNED
  22.      6         0 #####   512 NO  UNASSIGNED
  23.      7         0 #####   512 NO  UNASSIGNED
  24.      8         0 #####   512 YES UNASSIGNED


  25. Standby Redo log 都是 UNASSIGNED ,而你用的是LGWR模式 这点很奇怪


  26. db_file_name_convert           D:\oracle\product\10.2.0\oradata\orcl,
  27.                                                     D:\oracle\product\10.2.0\oradata\orcl

  28. log_file_name_convert          D:\oracle\product\10.2.0\oradata\orcl,
  29.                                                     D:\oracle\product\10.2.0\oradata\orcl

  30. LOG_FILE_NAME_CONVERT为啥要这样设置?
复制代码
给我的感觉是 primary上 online redo中的信息没传过来, 且你的 standby redo log从未被用过 这点很可疑

回复 只看该作者 道具 举报

7#
发表于 2012-2-2 22:53:50

回复 6# 的帖子

db_file_name_convert           D:\oracle\product\10.2.0\oradata\orcl,
                                                    D:\oracle\product\10.2.0\oradata\orcl

log_file_name_convert          D:\oracle\product\10.2.0\oradata\orcl,
                                                    D:\oracle\product\10.2.0\oradata\orcl

LOG_FILE_NAME_CONVERT为啥要这样设置?


这个我明白是多余


有什么解决方法

回复 只看该作者 道具 举报

8#
发表于 2012-2-2 23:01:29
SQL> set linesize 200 pagesize 1400


SQL>  select fnnam,fnonm from x$kccfn where fntyp=3;

回复 只看该作者 道具 举报

9#
发表于 2012-2-2 23:18:44
SQL> select fnnam,fnonm from x$kccfn where fntyp=3;

FNNAM
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
----------------------------------------
FNONM
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
----------------------------------------
D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO03.LOG
D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO03.LOG

D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO02.LOG
D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO02.LOG

D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO01.LOG
D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO01.LOG

D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\STANDREDO_7.LOG
D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\STANDREDO_7.LOG

D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\STANDREDO_6.LOG
D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\STANDREDO_6.LOG

D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\STANDREDO_5.LOG
D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\STANDREDO_5.LOG

D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\STANDREDO_8.LOG
D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\STANDREDO_8.LOG


已选择7行。

回复 只看该作者 道具 举报

10#
发表于 2012-2-2 23:28:52
action plan:

1. 取消 switch over

2.  测试你的standby 日志是否被正常使用,

SQL> select group#,sequence#,bytes,used,archived,status from v$standby_log;

3. 确认 standby redo log位置正确

回复 只看该作者 道具 举报

11#
发表于 2012-2-2 23:30:18

回复 10# 的帖子

SQL> select group#,sequence#,bytes,used,archived,status from v$standby_log;

GROUP# SEQUENCE# BYTES  USED ARC STATUS
------ --------- ----- ----- --- ----------
     5         0 #####   512 NO  UNASSIGNED
     6         0 #####   512 NO  UNASSIGNED
     7         0 #####   512 NO  UNASSIGNED
     8         0 #####   512 YES UNASSIGNED

已选择4行。

回复 只看该作者 道具 举报

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

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

GMT+8, 2024-11-15 01:50 , Processed in 0.062155 second(s), 24 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

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