文档课题:通过dbv对oracle数据库中数据文件做批量检测.
数据库:oracle 19.16
以下演示通过dbv对全库数据文件进行检测的测试:
--生成批量检测语句.
SYS@simdb> set feedback off head off echo off linesize 200 pagesize 1000
SYS@simdb> spool /tmp/dbvchk.sh
SYS@simdb> select 'dbv file=' || name || ' blocksize=' || block_size ||
2 ' USERID=sys/x’x’x’x logfile=' ||
3 substr(name, instr(name, '/', -1, 1) + 1) || '.' || file# || '.log'
4 from v$datafile;
[oracle@leo-19c-ogg tmp]$ cat dbvchk.sh
SYS@simdb> select 'dbv file=' || name || ' blocksize=' || block_size ||
2 ' USERID=sys/x’x’x’x logfile=' ||
3 substr(name, instr(name, '/', -1, 1) + 1) || '.' || file# || '.log'
4 from v$datafile;
dbv file=/u01/app/oracle/oradata/SIMDB/system01.dbf blocksize=8192 USERID=sys/x’x’x’x logfile=system01.dbf.1.log
dbv file=/u01/app/oracle/oradata/SIMDB/sysaux01.dbf blocksize=8192 USERID=sys/x’x’x’x logfile=sysaux01.dbf.3.log
dbv file=/u01/app/oracle/oradata/SIMDB/undotbs01.dbf blocksize=8192 USERID=sys/x’x’x’x logfile=undotbs01.dbf.4.log
dbv file=/u01/app/oracle/oradata/SIMDB/ogg_tbs01.dbf blocksize=8192 USERID=sys/x’x’x’x logfile=ogg_tbs01.dbf.5.log
dbv file=/u01/app/oracle/oradata/SIMDB/users01.dbf blocksize=8192 USERID=sys/x’x’x’x logfile=users01.dbf.7.log
SYS@simdb> spool off;
--编辑dbvchk.sh文件,使其达到如下效果.
[oracle@leo-19c-ogg tmp]$ cat dbvchk.sh
dbv file=/u01/app/oracle/oradata/SIMDB/system01.dbf blocksize=8192 USERID=sys/x’x’x’x logfile=system01.dbf.1.log
dbv file=/u01/app/oracle/oradata/SIMDB/sysaux01.dbf blocksize=8192 USERID=sys/x’x’x’x logfile=sysaux01.dbf.3.log
dbv file=/u01/app/oracle/oradata/SIMDB/undotbs01.dbf blocksize=8192 USERID=sys/x’x’x’x logfile=undotbs01.dbf.4.log
dbv file=/u01/app/oracle/oradata/SIMDB/ogg_tbs01.dbf blocksize=8192 USERID=sys/x’x’x’x logfile=ogg_tbs01.dbf.5.log
dbv file=/u01/app/oracle/oradata/SIMDB/users01.dbf blocksize=8192 USERID=sys/x’x’x’x logfile=users01.dbf.7.log
--赋予权限.
[oracle@leo-19c-ogg tmp]$ chmod +x dbvchk.sh
--执行检测.
[oracle@leo-19c-ogg tmp]$ ./dbvchk.sh
DBVERIFY: Release 19.0.0.0.0 - Production on Wed Jan 11 21:32:10 2023
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
DBVERIFY: Release 19.0.0.0.0 - Production on Wed Jan 11 21:32:13 2023
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
DBVERIFY: Release 19.0.0.0.0 - Production on Wed Jan 11 21:32:15 2023
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
DBVERIFY: Release 19.0.0.0.0 - Production on Wed Jan 11 21:32:17 2023
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
DBVERIFY: Release 19.0.0.0.0 - Production on Wed Jan 11 21:32:19 2023
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
--查看log文件.
[oracle@leo-19c-ogg tmp]$ ll | grep .log
-rw-r--r-- 1 oracle oinstall 736 Jan 11 21:32 ogg_tbs01.dbf.5.log
-rw-r--r-- 1 oracle oinstall 813 Jan 11 21:32 sysaux01.dbf.3.log
-rw-r--r-- 1 oracle oinstall 744 Jan 11 21:32 system01.dbf.1.log
-rw-r--r-- 1 oracle oinstall 731 Jan 11 21:32 undotbs01.dbf.4.log
-rw-r--r-- 1 oracle oinstall 793 Jan 11 21:32 users01.dbf.7.log
--查看log文件是否有坏块记录.
[oracle@leo-19c-ogg tmp]$ cat *.log | grep -i "Total Pages Marked Corrupt"
Total Pages Marked Corrupt : 0
Total Pages Marked Corrupt : 0
Total Pages Marked Corrupt : 0
Total Pages Marked Corrupt : 0
Total Pages Marked Corrupt : 0
参考网址:https://www.modb.pro/db/42626