12C新特性:repair datafile、repair pluggable database

12C新特性repair datafile、repair pluggable database是从12.2开启的新特性。修复数据库变的简单很多。

备份数据库

RMAN> backup as compressed backupset  incremental level=0  database format '/rmanbackup/rman0_%d_%s_%T' tag='level0' plus archivelog;

一、repair datafile

1、制造坏块:

SQL> alter database datafile '+DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/users.278.1057318927' offline;

Database altered.

SQL>  alter database datafile '+DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/users.278.1057318927' online;
 alter database datafile '+DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/users.278.1057318927' online
*
ERROR at line 1:
ORA-01113: file 14 needs media recovery
ORA-01110: data file 14:
'+DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/users.278.1057318927'

2、修复坏块

[oracle@cat1 ~]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Fri Dec 11 09:01:03 2020
Version 19.3.0.0.0

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

connected to target database: WHS1 (DBID=2406852607)

RMAN> repair datafile 14;  

Starting restore at 11-DEC-20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=408 instance=whs11 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 00014 to +DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/users.278.1057318927
channel ORA_DISK_1: reading from backup piece /rmanbackup/rman0_WHS1_30_20201211
channel ORA_DISK_1: piece handle=/rmanbackup/rman0_WHS1_30_20201211 tag=LEVEL0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 11-DEC-20

Starting recover at 11-DEC-20
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 11-DEC-20

RMAN> 

3、datafile online

SQL> alter database datafile '+DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/users.278.1057318927' online;

Database altered.

SQL> 

二、repair pluggable database

1、删除PDB的数据文件

关闭CDB

srvctl stop database -d whs1

删除PDB的数据文件

ASMCMD> cd +DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/
ASMCMD> rm USERS.278.1057318927

开启cdb

SQL> STARTUP

开启PDB,报错

SQL> alter pluggable database PDB1_WHS open;
alter pluggable database PDB1_WHS open
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 14 - see DBWR trace file
ORA-01110: data file 14:
'+DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/users.278.1057318927'

2、修改数据库

[oracle@cat1 admin]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Fri Dec 11 09:27:30 2020
Version 19.3.0.0.0

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

connected to target database: WHS1 (DBID=2406852607)

RMAN> repair pluggable database PDB1_WHS;

Starting restore at 11-DEC-20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=286 instance=whs11 device type=DISK
Executing: alter database datafile 10 offline
Executing: alter database datafile 11 offline
Executing: alter database datafile 12 offline
Executing: alter database datafile 13 offline
Executing: alter database datafile 14 offline

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 00010 to +DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/system.274.1057318913
channel ORA_DISK_1: restoring datafile 00011 to +DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/sysaux.275.1057318911
channel ORA_DISK_1: restoring datafile 00012 to +DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/undotbs1.273.1057318911
channel ORA_DISK_1: restoring datafile 00013 to +DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/undo_2.277.1057318927
channel ORA_DISK_1: restoring datafile 00014 to +DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/users.278.1057318927
channel ORA_DISK_1: reading from backup piece /rmanbackup/rman0_WHS1_30_20201211
channel ORA_DISK_1: piece handle=/rmanbackup/rman0_WHS1_30_20201211 tag=LEVEL0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 11-DEC-20

Starting recover at 11-DEC-20
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 46 is already on disk as file +DATA1/WHS1/ARCHIVELOG/2020_12_11/thread_1_seq_46.363.1058863555
archived log for thread 1 with sequence 47 is already on disk as file +DATA1/WHS1/ARCHIVELOG/2020_12_11/thread_1_seq_47.362.1058865109
archived log for thread 1 with sequence 48 is already on disk as file +DATA1/WHS1/ARCHIVELOG/2020_12_11/thread_1_seq_48.359.1058865961
archived log for thread 2 with sequence 16 is already on disk as file +DATA1/WHS1/ARCHIVELOG/2020_12_11/thread_2_seq_16.364.1058863557
archived log for thread 2 with sequence 17 is already on disk as file +DATA1/WHS1/ARCHIVELOG/2020_12_11/thread_2_seq_17.278.1058865957
archived log for thread 2 with sequence 18 is already on disk as file +DATA1/WHS1/ARCHIVELOG/2020_12_11/thread_2_seq_18.361.1058865959
archived log for thread 2 with sequence 19 is already on disk as file +DATA1/WHS1/ARCHIVELOG/2020_12_11/thread_2_seq_19.360.1058865959
archived log file name=+DATA1/WHS1/ARCHIVELOG/2020_12_11/thread_1_seq_46.363.1058863555 thread=1 sequence=46
archived log file name=+DATA1/WHS1/ARCHIVELOG/2020_12_11/thread_2_seq_16.364.1058863557 thread=2 sequence=16
archived log file name=+DATA1/WHS1/ARCHIVELOG/2020_12_11/thread_1_seq_47.362.1058865109 thread=1 sequence=47
archived log file name=+DATA1/WHS1/ARCHIVELOG/2020_12_11/thread_2_seq_17.278.1058865957 thread=2 sequence=17
Executing: alter database datafile 10 online
Executing: alter database datafile 11 online
Executing: alter database datafile 12 online
Executing: alter database datafile 13 online
Executing: alter database datafile 14 online
Finished recover at 11-DEC-20

RMAN> 

Related Posts