为什么更换存储之后一切正常但RAC集群启动不了?

存储 存储软件
这是一次来自生产实践的真实案例,某客户核心生产库由于进行新老存储替换变更操作后,Oracle RAC 两个节点均无法打开,数据库遭遇严重故障。

这是一次来自生产实践的真实案例,某客户核心生产库由于进行新老存储替换变更操作后,Oracle RAC 两个节点均无法打开,数据库遭遇严重故障。

先来看看告警日志中记录的错误信息,我们注意到数据库能够正常Mount,但是在Open阶段遇到错误,提示某个数据文件不能被锁定:

  1. ALTER DATABASE MOUNT  
  2. This instance was first to mount 
  3. Fri Dec 16 03:20:34 2016 
  4. Successful mount of redo thread 2, with mount id 3052566649 
  5. Fri Dec 16 03:20:40 2016 
  6. Database mounted in Shared Mode (CLUSTER_DATABASE=TRUE
  7. Lost write protection disabled 
  8. Completed: ALTER DATABASE MOUNT  
  9. ALTER DATABASE OPEN  
  10. This instance was first to open 
  11. Fri Dec 16 03:00:53 2016 
  12. Errors in file /diag/ojtdb/ojtdb2/trace/ojtdb2_ora_1569.trc: 
  13. ORA-01157: cannot identify/lock data file 1311 - see DBWR trace file 
  14. ORA-01110: data file 1311: '/dev/vx/rdsk/ora_ojt10/ora_dev1311' 
  15. ORA-1157 signalled during: ALTER DATABASE OPEN 

通常遇到这个错误,最常见的原因是存储未正常挂载,或者数据文件损坏丢失。

[[234038]]

通过dd检测发现I/O读正常,dbv检测数据文件也正常,这说明存储和数据文件的基本表现都属正常,而且不存在权限问题:

  1. oracle$  time dd if=/dev/vx/rdsk/ora_ojt10/ora_dev1311 of=/dev/null bs=1024k count=1000 
  2. 1000+0 records in 
  3. 1000+0 records out 
  4.  
  5. real    0m1.654s 
  6. user    0m0.006s 
  7. sys     0m0.316s 
  8.  
  9. oracle$  dbv file=/dev/vx/rdsk/ora_ojt10/ora_dev1311 blocksize=8192 

那么显然,这个问题跳出了传统的故障原因。

我们再回顾一下错误信息,数据库启动失败源自DBWR报错,可以通过进程跟踪来分析进程的工作状态。

在此我们通过v$session,分析DBW0进程当前的等待事件,排查dbwr进程迟迟不向其他进程发送相关ipc message的原因:

  1. SQL> select event from v$session where paddr in  
  2. (select addr from v$process where pid=<13>); 
  3. EVENT 
  4. ------------------------ 
  5. Disk file operations I/O 

DBWR 始终在执行磁盘 I/O 操作,Disk file operations I/O等待事件的官方解释如下:

This event is used to wait for disk file operations (for example, open, close, seek, and resize). It is also used for miscellaneous I/O operations such as block dumps and password file accesses.

此事件用于等待磁盘文件操作(例如,打开,关闭,搜索和调整大小)。 它也用于一些其他I / O操作,例如块转储和密码文件访问。

这个等待事件的三个参数p1,p2,p3 含义如下:

持续观察DBWR该事件的参数值,发现 p1=2,意思是 file open,在进行文件打开操作;p3=2,意思是操作数据文件。

而 p2 一直在递增变化,其含义是文件号,不断顺序的打开不同的数据文件。

说明DBW0正在逐个检查并打开数据文件,查询得知该库数据文件有1560个,在逐个检查进行到900秒后,后台alert日志中出现了如下错误,这一次出现问题的是另外一个文件:

  1. ORA-01157: cannot identify/lock data file 1401 - see DBWR trace file 
  2. ORA-01110: data file 1401: '/dev/vx/rdsk/ora_ojt10/ora_dev1401' 
  3. ORA-1157 signalled during: ALTER DATABASE OPEN  

在启动过程中,我们发现从mount到open阶段,报出 ORA-01157 和 ORA-01110 花费的时间很长,需要十几分钟,然后报错,使得启动过程强制终止;

最终是后台dbw进程在输出日志,为了进一步分析该过程中具体流程,于是开启10046事件跟踪dbw0进程:

  1. *** 2016-12-16 12:03:30.798--这里时间是12点03,开始执行open操作 
  2. WAIT #0: nam='SQL*Net message from client' ela= 7344875 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=8068132685065 
  3. XCTEND rlbk=0, rd_only=1, tim=8068132685665 
  4. ===================== 
  5. PARSING IN CURSOR #18446744071440810672 len=19 dep=0 uid=0 oct=35 lid=0 tim=8068132686043 hv=1907384048 ad='176ffabd68' sqlid='a01hp0psv0rrh' 
  6. alter database open 
  7.  
  8. *** 2016-12-16 12:18:49.122 
  9. WAIT #18446744071440810672: nam='rdbms ipc reply' ela= 2010056 from_process=23 timeout=2 p3=0 obj#=-1 tim=8069051099141 
  10. *** 2016-12-16 12:18:51.038--之前都是空闲等待,从这个时间点开始,当前进程等待超时 ,发送超时消息给dbw0进程。而这个时间点18分。 
  11. WAIT #18446744071440810672: nam='ksdxexeotherwait' ela= 1915544 p1=0 p2=0 p3=0 obj#=-1 tim=8069053014980 
  12. WAIT #18446744071440810672: nam='control file sequential read' ela= 818 file#=0 block#=1 blocks=1 obj#=-1 tim=8069053016115 
  13. WAIT #18446744071440810672: nam='control file sequential read' ela= 496 file#=0 block#=39 blocks=1 obj#=-1 tim=8069053016665 
  14. WAIT #18446744071440810672: nam='control file sequential read' ela= 393 file#=0 block#=41 blocks=1 obj#=-1 tim=8069053017100 
  15. WAIT #18446744071440810672: nam='control file sequential read' ela= 8212 file#=0 block#=2300 blocks=1 obj#=-1 tim=8069053025356 
  16. WAIT #18446744071440810672: nam='CSS initialization' ela= 20622 p1=0 p2=0 p3=0 obj#=-1 tim=8069053046642 
  17. WAIT #18446744071440810672: nam='CSS operation: action' ela= 2656 function_id=65 p2=0 p3=0 obj#=-1 tim=8069053049357 

从dbw0进程的跟踪日志来看,发现进程等待超时,然后发送超时消息给dbw0进程。从12:03分发起open操作,到12:18分出现超时消息,(18-3)*60 s = 900 s,即900秒后,后台发送超时消息给dbw0进程,而这个时间点正是后台报错而启动终止的时间。

这个信息给出了很好的分析线索,随即继续分析跟踪文件,详细分析每一次I/O的状态:

  1. waited for 'Disk file operations I/O', seq_num: 617 
  2.       p1: 'FileOperation'=0x2 
  3.       p2: 'fileno'=0x1a9 
  4.       p3: 'filetype'=0x2 
  5.       time_waited: 0.696732 sec (sample interval: 0 sec) 
  6.   [1 sample,                                                          07:57:37] 
  7.     waited for 'Disk file operations I/O', seq_num: 614 
  8.       p1: 'FileOperation'=0x2 
  9.       p2: 'fileno'=0x1a7 
  10.       p3: 'filetype'=0x2 
  11.       time_waited: 0.699569 sec (sample interval: 0 sec) 
  12.   [1 sample,                                                          07:57:36] 
  13.     waited for 'Disk file operations I/O', seq_num: 613 
  14.       p1: 'FileOperation'=0x2 
  15.       p2: 'fileno'=0x1a6 
  16.       p3: 'filetype'=0x2 
  17.       time_waited: 0.682626 sec (sample interval: 0 sec) 
  18.   [1 sample,                                                          07:57:35] 
  19.     waited for 'Disk file operations I/O', seq_num: 611 
  20.       p1: 'FileOperation'=0x2 
  21.       p2: 'fileno'=0x1a4 
  22.       p3: 'filetype'=0x2 
  23.       time_waited: 0.695486 sec (sample interval: 0 sec) 
  24.   [1 sample,                                                          07:57:34] 
  25.     waited for 'Disk file operations I/O', seq_num: 610 
  26.       p1: 'FileOperation'=0x2 
  27.       p2: 'fileno'=0x1a3 
  28.       p3: 'filetype'=0x2 
  29.       time_waited: 0.700244 sec (sample interval: 0 sec) 
  30.   [1 sample,                                                          07:57:33] 
  31.     waited for 'Disk file operations I/O', seq_num: 608 
  32.       p1: 'FileOperation'=0x2 
  33.       p2: 'fileno'=0x1a1 
  34.       p3: 'filetype'=0x2 
  35.       time_waited: 0.682131 sec (sample interval: 0 sec) 
  36. --------------------------------------------------- 
  37. Sampled Session History Summary: 
  38.   longest_non_idle_wait: 'Disk file operations I/O' 
  39.   [1 sample, 07:57:51 ] 
  40.       time_waited: 0.910736 sec (sample interval: 0 sec) 

注意以上日志,可以发现平均打开一个数据文件的Disk file operations I/O操作大概需要0.7s左右,该库共有 1560个 数据文件,照此计算,打开所有数据文件大约需要1092秒,这个时间超出了之前得出的从发起open到报错终止的900秒的。

那么我们接下来要想办法,让数据库在报错之前等待更久。

怎么办呢?让我们思考1秒钟。。。

数据库中有一个隐藏参数 _controlfile_enqueue_timeout 默认为900s,该参数的意思是在数据库的 Open 阶段,锁定控制文件读取相关的数据文件并打开的允许超时时间,如果超过了900s阈值则认为数据库超时,会抛出异常,中断操作。

在此之前,我们估算了打开所有数据文件需要至少1092秒,这里在参数文件将该参数修改为9000s后,重新执行启动流程,最终成功打开了数据库的第二节点。

  1. Fri Dec 16 12:52:22 2016 
  2. ALTER SYSTEM SET _controlfile_enqueue_timeout=9000 SCOPE=SPFILE; 
  3. Fri Dec 16 12:52:22 2016 
  4. Shutting down instance (abort) 
  5. License high water mark = 5 
  6. USER (ospid: 18936): terminating the instance 
  7. Instance terminated by USER, pid = 18936 
  8. Fri Dec 16 12:52:30 2016 
  9. Instance shutdown complete 
  10. Fri Dec 16 12:52:34 2016 
  11. Starting ORACLE instance (normal) 
  12. Fri Dec 16 12:52:47 2016 
  13. … 
  14. Fri Dec 16 12:56:39 2016 
  15. Database mounted in Shared Mode (CLUSTER_DATABASE=TRUE
  16. Lost write protection disabled 
  17. Completed: ALTER DATABASE   MOUNT 
  18. Fri Dec 16 12:57:19 2016 
  19. alter database open 
  20. Fri Dec 16 13:15:42 2016 
  21. GTX0 started with pid=92, OS id=26326  
  22. replication_dependency_tracking turned off (no async multimaster replication found) 
  23. Starting background process QMNC 
  24. Fri Dec 16 13:15:43 2016 
  25. QMNC started with pid=93, OS id=26332  
  26. Completed: alter database open 

从日志中,也清晰的看到,从12:57发起 alter database open 到***完成open,耗时18分钟后,数据库成功open,数据库恢复正常。

这个案例给我们的警示是:

在可能的情况下,任何变更都应该进行 1:1 真实测试,***可能发现隐患;

事关存储的变更,必须做好存储的读写I/O基准测试;

这个案例的后续是,分析新存储的I/O性能为何出现衰减,导致启动超时。这和存储的规划、磁盘划分、缓存配置等有关,数据库的案例到此就处理完成了。

责任编辑:武晓燕 来源: 数据和云
相关推荐

2011-03-18 19:38:05

趋势科技业务运营支持服务

2017-03-08 14:35:22

存储云计算华云网际

2019-11-12 08:48:46

容器KubernetesDevOps

2017-09-04 11:03:04

数据中心服务

2019-08-20 09:24:54

Python编程语言Java

2010-02-22 14:53:49

Ubuntu ngin

2020-09-11 10:55:10

useState组件前端

2016-08-31 17:24:05

大数据分析

2012-12-31 11:22:58

开源开放

2023-11-27 07:53:44

2022-08-31 16:29:09

数字孪生物联网

2018-11-23 11:17:24

负载均衡分布式系统架构

2021-02-19 23:08:27

软件测试软件开发

2021-09-01 07:21:39

Exporter指标监控

2012-11-05 15:22:59

康普光缆DCD

2021-02-28 09:47:54

软件架构软件开发软件设计

2020-09-11 09:43:18

移动网络测试网络速度网络通信

2014-10-20 12:22:17

2019-12-22 13:05:35

云计算边缘计算Gartner

2013-01-08 11:12:24

众筹Kickstarter移动游戏
点赞
收藏

51CTO技术栈公众号