修复DataGuard备库中的datafile坏块一例

简介: 模拟备库块损坏使用swingbench给主库施加一定的压力

模拟备库块损坏

使用swingbench给主库施加一定的压力

./oewizard -cl -create -scale 1 -cs //192.168.×:1521/guangxi -dbap dingjia -u soe1 -p soe1  -ts soe1  -df /u01/app/oracle/oradata/guangxi/soe1.dbf  -s 
./charbench  -c ../configs/SOE_Server_Side_V2.xml -u soe1 -p soe1 -r hu.xml -stats full -dbap dingjia -dbau "sys as sysdba" -uc 1 -rt 0:01 -cs //192.168.×/guangxil

手工用dd在备库上制作一个坏块。


$ dd of=/u01/app/oracle/oradata/guangxist/system01.dbf bs=8192 conv=notrunc seek=23  <<EOF
> Corrupt block! Corrupt block! Corrupt block! Corrupt block! Corrupt block!
> EOF
0+1 records in
0+1 records out
75 bytes (75 B) copied, 0.00150869 s, 49.7 kB/s


检查备库,发现已经有坏块了:

RMAN>  backup validate check logical tablespace system;
Starting backup at 09-JUN-20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1149 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/guangxist/system01.dbf
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
1    FAILED 0              18740        41600           2616809   
  File Name: /u01/app/oracle/oradata/guangxist/system01.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              14917           
  Index      0              4865            
  Other      1              3078            
validate found one or more corrupt blocks
See trace file /u01/app/oracle/diag/rdbms/guangxi1/guangxist/trace/guangxist_ora_22286.trc for details
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
List of Control File and SPFILE
===============================
File Type    Status Blocks Failing Blocks Examined
------------ ------ -------------- ---------------
SPFILE       OK     0              2               
Control File OK     0              596             
Finished backup at 09-JUN-20
SQL> select * from v$database_block_corruption;
     FILE#     BLOCK#   BLOCKS CORRUPTION_CHANGE# CORRUPTIO
---------- ---------- ---------- ------------------ ---------
  1    23        1    0 CORRUPT
SQL> set linesize 200
select d.DB_UNIQUE_NAME,d.open_mode,d.log_mode,d.DATABASE_ROLE,d.PROTECTION_MODE from v$database d;SQL> 
DB_UNIQUE_NAME         OPEN_MODE     LOG_MODE  DATABASE_ROLE   PROTECTION_MODE
------------------------------ -------------------- ------------ ---------------- --------------------
guangxi1         MOUNTED      ARCHIVELOG  PHYSICAL STANDBY MAXIMUM PERFORMANCE
SQL>



在主库执行被损坏的表空间的备份并传输到备库

RMAN> backup datafile 1 format '/u01/app/oracle/oradata/guangxi/systembk-%U.dbf';
[oracle@oracle11-1 ~]$ scp  /u01/app/oracle/oradata/guangxi/systembk-0* oracle@192.168.×:/u01/app/oracle/oradata
oracle@192.168.×'s password: 
systembk-0rv2api9_1_1.dbf                                                                                                                                                 100%  191MB  10.6MB/s   00:18    
systembk-0sv2apig_1_1.dbf                                                                                                                                                 100% 9632KB   4.7MB/s   00:02

在备库上恢复

停止备库的同步


SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;


使用rman恢复备份集:

RMAN> catalog start with '/u01/app/oracle/oradata/systembk-0rv2api9_1_1.dbf';
RMAN> catalog start with '/u01/app/oracle/oradata/systembk-0sv2apig_1_1.dbf';
RMAN> restore datafile 1;
Starting restore at 09-JUN-20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=13 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/guangxist/system01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/oradata/systembk-0rv2api9_1_1.dbf
channel ORA_DISK_1: piece handle=/u01/app/oracle/oradata/systembk-0rv2api9_1_1.dbf tag=TAG20200609T134648
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 09-JUN-20


恢复完成再检验,发现坏块已经修复:

RMAN> backup validate check logical tablespace system;
Starting backup at 09-JUN-20
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/guangxist/system01.dbf
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
1    OK     0              11572        41601           2693637   
  File Name: /u01/app/oracle/oradata/guangxist/system01.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              14917           
  Index      0              4865            
  Other      0              10246           
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
List of Control File and SPFILE
===============================
File Type    Status Blocks Failing Blocks Examined
------------ ------ -------------- ---------------
SPFILE       OK     0              2               
Control File OK     0              596             
Finished backup at 09-JUN-20
RMAN>




启动主库备库的数据同步


SQL> select * from v$database_block_corruption;
no rows selected
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Database altered.



验证数据同步正常


image.png

image.png

相关文章
|
1天前
|
监控 网络协议 算法
2026年起SSL证书有效期逐年缩短:企业如何避免“续期风暴”!
SSL证书有效期将从2026年起分三阶段逐步缩短至47天,人工续期难以为继。阿里云“WoSign SSL证书+自动化服务”,支持域名监控、自动托管、云产品/服务器一键部署及智能提醒,助力企业高效应对高频续期挑战。
8068 2
|
11天前
|
域名解析 人工智能 Linux
|
21天前
|
Linux Go 开发工具
手机上跑 DeepSeek 智能体:开源安卓客户端 DSH Go 安装与使用指南
DSH Go 是一款开源安卓客户端,将 DeepSeek Harness 智能体引擎装进手机:免 Root、免 Termux,一键安装即用;支持本机运行(内置 Ubuntu+Node.js)或远程接管电脑会话;具备插话打断、过程折叠、屏幕操控、端到端加密分享等特色功能,真正实现智能体“口袋化”。
18490 64
|
19天前
|
人工智能
Google 提示「所在地区不可用」?进不去 Antigravity 或 Gemini,先查账号这个设置
进不去 Antigravity 或 Gemini,提示所在地区不可用?三步查清 Google 账号关联地区、官方更正表单理由选法与改区注意事项。
Google 提示「所在地区不可用」?进不去 Antigravity 或 Gemini,先查账号这个设置
|
5天前
|
人工智能 安全 网络安全
|
9天前
|
Linux API iOS开发
【DSH】DeepSeek Harness新手保姆教程(下载+安装+配置+使用,2026最新实测)
DeepSeek Harness(dsh)是 DeepSeek AI 开源的智能体框架,秉持“一切皆插件”理念,支持读文件、改代码、执行命令、处理表格等自动化任务;免费开源,兼容 Win/macOS,需配 API 密钥使用。(239字)
1501 5
|
8天前
|
云安全 数据采集 人工智能
|
16天前
|
人工智能 开发工具 开发者
2026最新codex下载安装保姆级使用教程(下载+安装+登录+使用,含所有历史版本)
Codex 是 OpenAI 推出的开源 AI 编程智能体,跑在本地终端和桌面客户端里,能读懂整个代码仓库,一句自然语言就能让它改代码、执行命令、跑测试、修 Bug,支持 Windows、macOS、Linux 三大平台。本文把 Codex下载、安装、登录、汉化、基础使用一次讲全,并整理了国内用户最常踩的坑,跟着做 10 分钟就能跑起来。
2642 8
|
8天前
|
Web App开发 缓存 安全
巨魔商店 TrollStore 安装教程(2026):免电脑在线安装与全机型安装器矩阵_iOS巨魔安装
巨魔商店(TrollStore)是iOS 14–17.0(特定版本)的永久签名工具,无需越狱,利用CoreTrust漏洞实现IPA签名长期有效,彻底告别7天重签。支持免电脑在线安装(TrollHelperOTA),适配多机型/系统组合,开源免费,安全可控。(239字)
2125 0