0
点赞
收藏
分享

微信扫一扫

运用主库数据文件rman备份对备库单个坏块的恢复—blockrecover

文档课题:运用主库数据文件rman备份对备库单个坏块的恢复—blockrecover.
数据库:oracle 11.2.0.4
环境:rac(2节点)+dg
系统:rhel 7.9
应用场景:备库存在单个索引块损坏,此时数据库管理员希望只对坏的数据块进行修复,此文章将对该场景进行测试.
1、建测试数据
1.1、建表空间
SYS@orcl1> create tablespace tbs_tst_idx datafile '+data' size 10m autoextend on;

Tablespace created.

SYS@orcl1> select name,bytes/1024/1024 "size(M)" from v$datafile;

NAME                                                            size(M)
------------------------------------------------------------ ----------
+DATA/orcl/datafile/system.259.1132745549                          1060
+DATA/orcl/datafile/sysaux.260.1132745551                           600
+DATA/orcl/datafile/undotbs1.261.1132745553                         840
+DATA/orcl/datafile/undotbs2.263.1132745567                         200
+DATA/orcl/datafile/users.264.1132745567                              5
+DATA/orcl/datafile/users.285.1133862437                             50
+DATA/orcl/datafile/users.284.1133862457                             50
+DATA/orcl/datafile/users.283.1133862473                             50
+DATA/orcl/datafile/users.282.1133862489                             50
+DATA/orcl/datafile/users.281.1133862509                             50
+DATA/orcl/datafile/users.280.1133862525                             50

NAME                                                            size(M)
------------------------------------------------------------ ----------
+DATA/orcl/datafile/users.279.1133862553                             50
+DATA/orcl/datafile/users.278.1133862571                             50
+DATA/orcl/datafile/users.277.1133862585                             50
+DATA/orcl/datafile/users.276.1133862603                             50
+DATA/orcl/datafile/users.275.1133862625                             50
+DATA/orcl/datafile/users.274.1133862645                             50
+DATA/orcl/datafile/tbs_tst_idx.286.1134752063                       10

18 rows selected.

1.2、建测试用户
SYS@orcl1> create user leo identified by leo;

User created.

SYS@orcl1> grant select on dba_objects to leo;

Grant succeeded.

SYS@orcl1> grant connect,resource,unlimited tablespace to leo;

Grant succeeded.

SYS@orcl1> grant create any index to leo;

Grant succeeded.

1.3、建测试表
SYS@orcl1> conn leo/leo;
Connected.
LEO@orcl1> create table tb_obj tablespace users as select * from dba_objects;

Table created.

LEO@orcl1> insert into tb_obj select * from tb_obj;

86291 rows created.

LEO@orcl1> insert into tb_obj select * from tb_obj;

172582 rows created.

LEO@orcl1> insert into tb_obj select * from tb_obj;

345164 rows created.

LEO@orcl1> commit;

Commit complete.

LEO@orcl1> select count(*) from tb_obj;

  COUNT(*)
----------
    690328

--查表大小
SYS@orcl1> select blocks,bytes from dba_segments where owner='LEO' and segment_name='TB_OBJ';

    BLOCKS      BYTES
---------- ----------
     10240   83886080
	 
1.4、建测试索引
LEO@orcl1> create index IDX_OBJ_NAME on TB_OBJ(OBJECT_NAME) tablespace tbs_tst_idx;

Index created.

LEO@orcl1> col column_name for a15
LEO@orcl1> select index_name,table_name,column_name from user_ind_columns;

INDEX_NAME                     TABLE_NAME                     COLUMN_NAME
------------------------------ ------------------------------ ---------------
IDX_OBJ_NAME                   TB_OBJ                         OBJECT_NAME

LEO@orcl1> col index_name for a15
LEO@orcl1> col index_type for a15
LEO@orcl1> col table_owner for a15
LEO@orcl1> col table_name for a15
LEO@orcl1> select index_name,index_type,table_owner,table_name,table_type from user_indexes where table_name='TB_OBJ';

INDEX_NAME      INDEX_TYPE      TABLE_OWNER     TABLE_NAME      TABLE_TYPE
--------------- --------------- --------------- --------------- -----------
IDX_OBJ_NAME    NORMAL          LEO             TB_OBJ          TABLE

--查索引大小
SYS@orcl1> select blocks,bytes from dba_segments where owner='LEO' and segment_name='IDX_OBJ_NAME';

    BLOCKS      BYTES
---------- ----------
      3584   29360128

1.5、表和索引相关信息
--如下查询可知有3449个叶子节点块.
LEO@orcl1> select table_name,index_name,blevel,leaf_blocks,num_rows,last_analyzed,degree,status from user_indexes where table_name='TB_OBJ';

TABLE_NAME      INDEX_NAME          BLEVEL LEAF_BLOCKS   NUM_ROWS LAST_ANALYZED      DEGREE                                   STATUS
--------------- --------------- ---------- ----------- ---------- ------------------ ---------------------------------------- --------
TB_OBJ          IDX_OBJ_NAME             2        3449     690328 21-APR-23          1                                        VALID

--查索引及表的object_id
LEO@orcl1> select object_id from user_objects where object_name='IDX_OBJ_NAME';

 OBJECT_ID
----------
     87191
	 
SYS@orcl1> select object_id,object_name from dba_objects where owner='LEO';

 OBJECT_ID OBJECT_NAME
---------- ---------------
     87190 TB_OBJ
     87191 IDX_OBJ_NAME

2、模拟索引坏块
2.1、查索引所在块
SYS@orcldg> select open_mode from v$database;

OPEN_MODE
--------------------
READ ONLY WITH APPLY

SYS@orcldg> col name for a60
SYS@orcldg> set line 200
SYS@orcldg> select file#,name,bytes/1024/1024 "size(M)" from v$datafile;

     FILE# NAME                                                            size(M)
---------- ------------------------------------------------------------ ----------
         1 /u01/app/oracle/oradata/system.259.1132745549                      1060
         2 /u01/app/oracle/oradata/sysaux.260.1132745551                       600
         3 /u01/app/oracle/oradata/undotbs1.261.1132745553                     840
         4 /u01/app/oracle/oradata/undotbs2.263.1132745567                     200
         5 /u01/app/oracle/oradata/users.264.1132745567                          5
         6 /u01/app/oracle/oradata/users.285.1133862437                         50
         7 /u01/app/oracle/oradata/users.284.1133862457                         50
         8 /u01/app/oracle/oradata/users.283.1133862473                         50
         9 /u01/app/oracle/oradata/users.282.1133862489                         50
        10 /u01/app/oracle/oradata/users.281.1133862509                         50
        11 /u01/app/oracle/oradata/users.280.1133862525                         50

     FILE# NAME                                                            size(M)
---------- ------------------------------------------------------------ ----------
        12 /u01/app/oracle/oradata/users.279.1133862553                         50
        13 /u01/app/oracle/oradata/users.278.1133862571                         50
        14 /u01/app/oracle/oradata/users.277.1133862585                         50
        15 /u01/app/oracle/oradata/users.276.1133862603                         50
        16 /u01/app/oracle/oradata/users.275.1133862625                         50
        17 /u01/app/oracle/oradata/users.274.1133862645                         50
        18 /u01/app/oracle/oradata/tbs_tst_idx.286.1134752063                   40

18 rows selected.

--以下查索引所在数据块
SYS@orcldg> select extent_id,file_id,block_id,blocks from dba_extents where owner='LEO' and segment_name='IDX_OBJ_NAME' order by 1;

 EXTENT_ID    FILE_ID   BLOCK_ID     BLOCKS
---------- ---------- ---------- ----------
         0         18       3720          8
         1         18       3728          8
         2         18       3736          8
         3         18       3744          8
         4         18       3752          8
         5         18       3760          8
         6         18       3768          8
         7         18       3776          8
         8         18       3784          8
         9         18       3792          8
        10         18       3800          8

 EXTENT_ID    FILE_ID   BLOCK_ID     BLOCKS
---------- ---------- ---------- ----------
        11         18       3808          8
        12         18       3816          8
        13         18       3824          8
        14         18       3832          8
        15         18       3840          8
        16         18       3968        128
        17         18       4096        128
        18         18       4224        128
        19         18       4352        128
        20         18       4480        128
        21         18       4608        128

 EXTENT_ID    FILE_ID   BLOCK_ID     BLOCKS
---------- ---------- ---------- ----------
        22         18       4736        128
        23         18       4864        128
        24         18       4992        128
        25         18       5120        128
        26         18       5248        128
        27         18       5376        128
        28         18       5504        128
        29         18       5632        128
        30         18       5760        128
        31         18       5888        128
        32         18       6016        128

 EXTENT_ID    FILE_ID   BLOCK_ID     BLOCKS
---------- ---------- ---------- ----------
        33         18       6144        128
        34         18       6272        128
        35         18       6400        128
        36         18       6528        128
        37         18       6656        128
        38         18       6784        128
        39         18       6912        128
        40         18       7040        128
        41         18       7168        128
        42         18       7296        128

43 rows selected.

2.2、损坏索引块
--运用dd损坏索引块.
[oracle@hisdbdg backup]$ dd of=/u01/app/oracle/oradata/tbs_tst_idx.286.1134752063 bs=8192 conv=notrunc seek=3809 <<EOF
> Corrupted block!
> EOF
0+1 records in
0+1 records out
17 bytes (17 B) copied, 7.5222e-05 s, 226 kB/s

2.3、验证索引块损坏
[oracle@hisdbdg backup]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Sat Apr 22 17:14:00 2023

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1660526279)

RMAN> backup check logical validate datafile 18;

Starting backup at 22-APR-23
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=72 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=00018 name=/u01/app/oracle/oradata/tbs_tst_idx.286.1134752063
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
18   FAILED 0              115          7683            1346340   
  File Name: /u01/app/oracle/oradata/tbs_tst_idx.286.1134752063
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              0               
  Index      0              3466            
  Other      1              4099            

validate found one or more corrupt blocks
See trace file /u01/app/oracle/diag/rdbms/orcldg/orcldg/trace/orcldg_ora_16034.trc for details
Finished backup at 22-APR-23

RMAN> exit


Recovery Manager complete.
[oracle@hisdbdg backup]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sat Apr 22 17:14:29 2023

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SYS@orcldg> select * from v$database_block_corruption; 

     FILE#     BLOCK#     BLOCKS CORRUPTION_CHANGE# CORRUPTIO
---------- ---------- ---------- ------------------ ---------
        18       3809          1                  0 CORRUPT

SYS@orcldg> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

说明:如上所示,成功模拟出生产环境备库索引块的损坏.

3、恢复
3.1、备份数据文件
--主库先备份损坏的数据文件.
[oracle@hisdb1 backup]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Sat Apr 22 17:15:13 2023

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1660526279)

RMAN> backup as compressed backupset datafile 18 format '/home/oracle/backup/ForStandby18_%U' tag 'FORSTANDBY';

Starting backup at 22-APR-23
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 instance=orcl1 device type=DISK
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00018 name=+DATA/orcl/datafile/tbs_tst_idx.286.1134752063
channel ORA_DISK_1: starting piece 1 at 22-APR-23
channel ORA_DISK_1: finished piece 1 at 22-APR-23
piece handle=/home/oracle/backup/ForStandby18_1a1q8ht4_1_1 tag=FORSTANDBY comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 22-APR-23

RMAN> exit


Recovery Manager complete.

3.2、传输数据文件的备份集
[oracle@hisdb1 backup]$ ll
total 5416
-rw-r----- 1 oracle asmadmin 5545984 Apr 22 17:15 ForStandby18_1a1q8ht4_1_1
[oracle@hisdb1 backup]$ scp ForStandby18_1a1q8ht4_1_1 oracle@192.168.133.215:/home/oracle/backup

3.3、备库第一次恢复
[oracle@hisdbdg backup]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Sat Apr 22 17:17:03 2023

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1660526279)

RMAN> shutdown immediate;

using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down

RMAN> startup mount;

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area    2455228416 bytes

Fixed Size                     2255712 bytes
Variable Size                620758176 bytes
Database Buffers            1811939328 bytes
Redo Buffers                  20275200 bytes

--注册数据文件.
RMAN> catalog start with '/home/oracle/backup/ForStandby18_1a1q8ht4_1_1';

searching for all files that match the pattern /home/oracle/backup/ForStandby18_1a1q8ht4_1_1

List of Files Unknown to the Database
=====================================
File Name: /home/oracle/backup/ForStandby18_1a1q8ht4_1_1

Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /home/oracle/backup/ForStandby18_1a1q8ht4_1_1

RMAN> recover datafile 18 block 3809;

Starting recover at 22-APR-23
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=196 device type=DISK

channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00018
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/ForStandby18_1a1q8ht4_1_1
channel ORA_DISK_1: piece handle=/home/oracle/backup/ForStandby18_1a1q8ht4_1_1 tag=FORSTANDBY
channel ORA_DISK_1: restored block(s) from backup piece 1
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:01

starting media recovery
media recovery failed
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 04/22/2023 17:21:01
ORA-00283: recovery session canceled due to errors
ORA-01122: database file 18 failed verification check
ORA-01110: data file 18: '/u01/app/oracle/oradata/tbs_tst_idx.286.1134752063'
ORA-01207: file is more recent than control file - old control file

说明:如上所示,备库第一次恢复报错ORA-01207.

3.4、备份控制文件
--主库备份控制文件.
RMAN> backup current controlfile for standby format '/home/oracle/backup/ForStandbyCTRL18.bck';

Starting backup at 22-APR-23
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 instance=orcl1 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including standby control file in backup set
channel ORA_DISK_1: starting piece 1 at 22-APR-23
channel ORA_DISK_1: finished piece 1 at 22-APR-23
piece handle=/home/oracle/backup/ForStandbyCTRL18.bck tag=TAG20230422T172131 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 22-APR-23

RMAN> exit


Recovery Manager complete.

3.5、传输控制文件的备份集
[oracle@hisdb1 backup]$ ll
total 23816
-rw-r----- 1 oracle asmadmin  5545984 Apr 22 17:15 ForStandby18_1a1q8ht4_1_1
-rw-r----- 1 oracle asmadmin 18841600 Apr 22 17:21 ForStandbyCTRL18.bck
[oracle@hisdb1 backup]$ scp ForStandbyCTRL18.bck oracle@192.168.133.215:/home/oracle/backup   

3.6、备库第二次恢复
--备库再次进行恢复.
RMAN> shutdown immediate;

database dismounted
Oracle instance shut down

RMAN> startup nomount;

connected to target database (not started)
Oracle instance started

Total System Global Area    2455228416 bytes

Fixed Size                     2255712 bytes
Variable Size                620758176 bytes
Database Buffers            1811939328 bytes
Redo Buffers                  20275200 bytes

RMAN> restore standby controlfile from '/home/oracle/backup/ForStandbyCTRL18.bck';

Starting restore at 22-APR-23
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=63 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/control01.ctl
Finished restore at 22-APR-23

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> blockrecover datafile 18 block 3809;

Starting recover at 22-APR-23
Starting implicit crosscheck backup at 22-APR-23
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=69 device type=DISK
Crosschecked 1 objects
Finished implicit crosscheck backup at 22-APR-23

Starting implicit crosscheck copy at 22-APR-23
using channel ORA_DISK_1
Crosschecked 2 objects
Finished implicit crosscheck copy at 22-APR-23

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_1_145_l46yfwvb_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_2_39_l46yfz8k_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_2_40_l470vcr4_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_1_146_l470vf38_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_1_146_l473sp2p_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_2_40_l473sp42_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_1_147_l473sq0p_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_2_41_l473ss6b_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_2_42_l474n28w_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_1_148_l474n3ws_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_1_149_l474r7z3_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_2_43_l474r9sd_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_2_44_l477ff61_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_1_150_l477fgw5_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_2_44_l477j3h0_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_1_150_l477j3h7_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_1_151_l477j5lv_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_2_45_l477j7lr_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_2_46_l477odms_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_1_152_l477og64_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_2_47_l4798b3j_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_1_153_l4798ckg_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_2_48_l479n4xr_.arc
File Name: /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_1_154_l479n66k_.arc

using channel ORA_DISK_1

channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00018
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/ForStandby18_1a1q8ht4_1_1
channel ORA_DISK_1: piece handle=/home/oracle/backup/ForStandby18_1a1q8ht4_1_1 tag=FORSTANDBY
channel ORA_DISK_1: restored block(s) from backup piece 1
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:01

starting media recovery

archived log for thread 1 with sequence 154 is already on disk as file /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_1_154_l479n66k_.arc
archived log for thread 1 with sequence 155 is already on disk as file /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_1_155_l479v4qk_.arc
archived log for thread 2 with sequence 48 is already on disk as file /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_2_48_l479n4xr_.arc
archived log for thread 2 with sequence 49 is already on disk as file /u01/app/oracle/fast_recovery_area/ORCLDG/archivelog/2023_04_22/o1_mf_2_49_l479v392_.arc
media recovery complete, elapsed time: 00:00:02
Finished recover at 22-APR-23

说明:如上所示,备库第二次恢复无异常发生.

SYS@orcldg> alter database open;

Database altered.

SYS@orcldg> alter database recover managed standby database using current logfile disconnect from session;

Database altered.

4、备库验证
RMAN> backup datafile 18;

Starting backup at 22-APR-23
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=00018 name=/u01/app/oracle/oradata/tbs_tst_idx.286.1134752063
channel ORA_DISK_1: starting piece 1 at 22-APR-23
channel ORA_DISK_1: finished piece 1 at 22-APR-23
piece handle=/u01/app/oracle/fast_recovery_area/ORCLDG/backupset/2023_04_22/o1_mf_nnndf_TAG20230422T172614_l47b1pjc_.bkp tag=TAG20230422T172614 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 22-APR-23
RMAN> backup as compressed backupset database format '/home/oracle/backup/ForStandby_%U' tag 'FORSTANDBY';

Starting backup at 22-APR-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/system.259.1132745549
input datafile file number=00003 name=/u01/app/oracle/oradata/undotbs1.261.1132745553
input datafile file number=00002 name=/u01/app/oracle/oradata/sysaux.260.1132745551
input datafile file number=00004 name=/u01/app/oracle/oradata/undotbs2.263.1132745567
input datafile file number=00018 name=/u01/app/oracle/oradata/tbs_tst_idx.286.1134752063
input datafile file number=00006 name=/u01/app/oracle/oradata/users.285.1133862437
input datafile file number=00007 name=/u01/app/oracle/oradata/users.284.1133862457
input datafile file number=00008 name=/u01/app/oracle/oradata/users.283.1133862473
input datafile file number=00009 name=/u01/app/oracle/oradata/users.282.1133862489
input datafile file number=00010 name=/u01/app/oracle/oradata/users.281.1133862509
input datafile file number=00011 name=/u01/app/oracle/oradata/users.280.1133862525
input datafile file number=00012 name=/u01/app/oracle/oradata/users.279.1133862553
input datafile file number=00013 name=/u01/app/oracle/oradata/users.278.1133862571
input datafile file number=00014 name=/u01/app/oracle/oradata/users.277.1133862585
input datafile file number=00015 name=/u01/app/oracle/oradata/users.276.1133862603
input datafile file number=00016 name=/u01/app/oracle/oradata/users.275.1133862625
input datafile file number=00017 name=/u01/app/oracle/oradata/users.274.1133862645
input datafile file number=00005 name=/u01/app/oracle/oradata/users.264.1132745567
channel ORA_DISK_1: starting piece 1 at 22-APR-23
channel ORA_DISK_1: finished piece 1 at 22-APR-23
piece handle=/home/oracle/backup/ForStandby_1e1q8ijo_1_1 tag=FORSTANDBY comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting compressed 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: starting piece 1 at 22-APR-23
channel ORA_DISK_1: finished piece 1 at 22-APR-23
piece handle=/home/oracle/backup/ForStandby_1f1q8il5_1_1 tag=FORSTANDBY comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 22-APR-23

RMAN> backup check logical validate datafile 18;

Starting backup at 22-APR-23
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=00018 name=/u01/app/oracle/oradata/tbs_tst_idx.286.1134752063
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
18   OK     0              115          7683            1346340   
  File Name: /u01/app/oracle/oradata/tbs_tst_idx.286.1134752063
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              0               
  Index      0              3467            
  Other      0              4098            

Finished backup at 22-APR-23

SYS@orcldg> select * from v$database_block_corruption;

no rows selected

说明:如上所示,成功运用主库的数据文件rman备份集对备库的单个坏块恢复.

5、特别说明
若在主库同时将18号数据文件及控制文件进行备份并传递到备库,恢复时需执行如下指令:
restore datafile 18;
若执行指令:blockrecover datafile 18 block 3809;

会报如下告警:
channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00018
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/ForStandby18_1e1q8q2h_1_1
channel ORA_DISK_1: piece handle=/home/oracle/backup/ForStandby18_1e1q8q2h_1_1 tag=FORSTANDBY
channel ORA_DISK_1: restored block(s) from backup piece 1
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:01

starting media recovery
media recovery failed
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 04/22/2023 19:38:05
ORA-00283: recovery session canceled due to errors
ORA-10547: Cannot perform block media recovery; standby database is not caught up with primary.

6、数据文件
SYS@orcldg> col name for a60
SYS@orcldg> set line 200
SYS@orcldg> select file#,name,bytes/1024/1024 "size(M)" from v$datafile;

     FILE# NAME                                                            size(M)
---------- ------------------------------------------------------------ ----------
         1 /u01/app/oracle/oradata/system.259.1132745549                      1060
         2 /u01/app/oracle/oradata/sysaux.260.1132745551                       600
         3 /u01/app/oracle/oradata/undotbs1.261.1132745553                     840
         4 /u01/app/oracle/oradata/undotbs2.263.1132745567                     200
         5 /u01/app/oracle/oradata/users.264.1132745567                          5
         6 /u01/app/oracle/oradata/users.285.1133862437                         50
         7 /u01/app/oracle/oradata/users.284.1133862457                         50
         8 /u01/app/oracle/oradata/users.283.1133862473                         50
         9 /u01/app/oracle/oradata/users.282.1133862489                         50
        10 /u01/app/oracle/oradata/users.281.1133862509                         50
        11 /u01/app/oracle/oradata/users.280.1133862525                         50

     FILE# NAME                                                            size(M)
---------- ------------------------------------------------------------ ----------
        12 /u01/app/oracle/oradata/users.279.1133862553                         50
        13 /u01/app/oracle/oradata/users.278.1133862571                         50
        14 /u01/app/oracle/oradata/users.277.1133862585                         50
        15 /u01/app/oracle/oradata/users.276.1133862603                         50
        16 /u01/app/oracle/oradata/users.275.1133862625                         50
        17 /u01/app/oracle/oradata/users.274.1133862645                         50
        18 /u01/app/oracle/oradata/tbs_tst_idx.286.1134752063                   60

18 rows selected.

举报

相关推荐

0 条评论