ORACLE 19c ADG ,访问部分表报错如下:

1
2
3
ORA-01578: ORACLE data block corrupted (file # 11, block # 84)
ORA-01110: data file 4: '/<path>/<datafilename>.dbf'
ORA-26040: Data block was loaded using the NOLOGGING option

最开始检查的是 V$DATABASE_BLOCK_CORRUPTION; 视图,但是没有结果,后来查询资料发现需要注意的是:在12c及以后版本中,RMAN validate的结果不在视图v$database_block_corruption中,而是在视图v$nonlogged_block:

1
2
3
4
5
SQL> select * from V$DATABASE_BLOCK_CORRUPTION;

no rows selected

SQL>

“VALIDATE” RMAN 命令用来检测NOLOGGING数据块,检查结果记录在 view v$database_block_corruption (versions lower than 12c) 和 v$nonlogged_block (12c and greater). 下面的例子中检查出datafile 4 有 933 坏块,查询 v$database_block_corruption 或者 v$nonlogged_block。

在12.2 版本, 可以使用新的命令:”validate .. nonlogged block” 去验证nologging的block。 在以下的例子中,数据文件5,6有 nologged的block:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
RMAN> validate database nonlogged block;
Starting validate at ...
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=133 device type=DISK
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: validation complete, elapsed time: 00:00:35
List of Datafiles
=================
File Status Nonlogged Blocks Blocks Examined Blocks Skipped
---- ------ ---------------- --------------- --------------
1 OK 0 106363 0
2 OK 0 78919 0
3 OK 0 96639 0
4 OK 0 4991 0
5 OK 400 2559 0
6 OK 569 2559 0
Details of nonlogged blocks can be queried from v$nonlogged_block view

本次解决参照mos 文档:ORA-1578 / ORA-26040 Corrupt blocks by NOLOGGING - Error explanation and solution (文档 ID 794505.1) 中文翻译文档:ORA-1578 / ORA-26040 - NOLOGGING 操作引起的坏块 - 错误解释和解决方案 (文档 ID 1623284.1)

纪录下本次的解决方法:

由于刚开始查询 V$DATABASE_BLOCK_CORRUPTION;,没有任何输出,使用的是 validate check logical database;命令来检查数据文件,但是检测完之后这个视图仍然没有结果,后来发现12c之后要通过 v$nonlogged_block 进行查询。

查询 v$nonlogged_block 视图确实有结果。单同时也发现12c修复 引入了以下命令

以下RMAN命令被引入:
RMAN> validate [database / datafile] nonlogged block;

RMAN> recover [database / datafile] nonlogged block; -> 对 于 Standby 数据库

所以通过又重新使用了validate database nonlogged block;进行检测,需要注意的是,我使用了如下分配了 16个通道,数据文件有18t左右,仍然使用了 10个多小时

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

RMAN> run {
2> allocate channel d1 type disk;
3> allocate channel d2 type disk;
4> allocate channel d3 type disk;
5> allocate channel d4 type disk;
6> allocate channel d5 type disk;
7> allocate channel d6 type disk;
8> allocate channel d7 type disk;
9> allocate channel d8 type disk;
10> allocate channel d11 type disk;
11> allocate channel d12 type disk;
12> allocate channel d13 type disk;
13> allocate channel d14 type disk;
14> allocate channel d15 type disk;
15> allocate channel d16 type disk;
16> allocate channel d17 type disk;
17> allocate channel d18 type disk;
18> validate database nonlogged block;
19> release channel d1;
20> release channel d2;
21> release channel d3;
22> release channel d4;
23> release channel d5;
24> release channel d6;
25> release channel d7;
26> release channel d8;
27> release channel d11;
28> release channel d12;
29> release channel d13;
30> release channel d14;
31> release channel d15;
32> release channel d16;
33> release channel d17;
34> release channel d18;
35> }

不知道是不是这样并行不起作用,亦或者这写通道是串行运行的。

具体的运行时间如下:

1
2
3
validate database  nonlogged block; #--10:52:07
RECOVER DATABASE NONLOGGED BLOCK;#--00:00:12
validate datafile 220 nonlogged block;#-- 00:01:05

在经过10个小时的检测之后,执行 RECOVER DATABASE NONLOGGED BLOCK; ,然后查看v$nonlogged_block 视图,仍然有一个数据文件

1
2
3
4
5
SQL> select distinct FILE# from v$nonlogged_block;

FILE#
----------
220

然后再次手动 validate datafile 220 耗时 1分钟,再检查视图已无数据

1
validate  datafile 220 nonlogged block;#-- 00:01:05

实际上这是个 12.2 之后的库,可以通过

1
2
validate database  nonlogged block; 
RECOVER DATABASE NONLOGGED BLOCK;

轻松解决,如果是11g,解决方法可能比较麻烦:比如增量备份,rman 单独恢复有坏块的文件等。具体参考:

https://www.anbob.com/archives/4534.html

https://www.anbob.com/archives/5778.html

原文作者: liups.com

原文链接: http://liups.com/posts/91f6e9c0/

许可协议: 知识共享署名-非商业性使用 4.0 国际许可协议