ORACLE本地磁碟備份恢復

star的DBA手记發表於2024-12-07

1.部署新備份磁碟(源和目標)

[oracle@cmxdb /ora_bak]$ mkdir -p /oracle/rmanback
[oracle@cmxdb /ora_bak]$ chown -R oracle:oinstall /oracle/rmanback
[oracle@cmxdb /ora_bak]$ ls -ld /oracle/rmanback/
drwxr-xr-x 2 oracle oinstall 6 Dec  1 15:37 /oracle/rmanback/


[oracle@cmxbak ~]$ mkdir -p /oracle/rmanback
[oracle@cmxbak ~]$ chown -R oracle:oinstall /oracle/rmanback
[oracle@cmxbak ~]$ ls -ld /oracle/rmanback/
drwxr-xr-x 2 oracle oinstall 6 Dec  1 15:58 /oracle/rmanback/

2.源端備份

2.1備份資料檔案

[oracle@cmxdb /ora_bak]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Sun Dec 1 15:39:30 2024

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

connected to target database: CMXDB (DBID=3000047776)

RMAN> backup database format '/oracle/rmanback/data_%U.dbf';

Starting backup at 2024-12-01 15:39:51
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1714 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=/oradata/cmxdb/system01.dbf
input datafile file number=00002 name=/oradata/cmxdb/sysaux01.dbf
input datafile file number=00005 name=/oradata/cmxdb/example01.dbf
input datafile file number=00003 name=/oradata/cmxdb/undotbs01.dbf
input datafile file number=00004 name=/oradata/cmxdb/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2024-12-01 15:39:51
channel ORA_DISK_1: finished piece 1 at 2024-12-01 15:40:26
piece handle=/oracle/rmanback/data_0l3bjou7_1_1.dbf tag=TAG20241201T153951 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
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: starting piece 1 at 2024-12-01 15:40:27
channel ORA_DISK_1: finished piece 1 at 2024-12-01 15:40:28
piece handle=/oracle/rmanback/data_0m3bjova_1_1.dbf tag=TAG20241201T153951 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2024-12-01 15:40:28


RMAN>


[oracle@cmxdb /oracle/rmanback]$ ls -l
total 1210592
-rw-r----- 1 oracle oinstall 1229717504 Dec  1 15:40 data_0l3bjou7_1_1.dbf
-rw-r----- 1 oracle oinstall    9928704 Dec  1 15:40 data_0m3bjova_1_1.dbf


ps:當資料量較大時,使用如下方式

run {
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup database format '/oracle/rmanback/data_%U.dbf';
release channel c1;
release channel c2;
release channel c3;
}

2.2備份控制檔案

RMAN> backup current controlfile format '/oracle/rmanback/control_01.dbf';

Starting backup at 2024-12-01 15:43:04
using channel ORA_DISK_1
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
channel ORA_DISK_1: starting piece 1 at 2024-12-01 15:43:05
channel ORA_DISK_1: finished piece 1 at 2024-12-01 15:43:06
piece handle=/oracle/rmanback/control_01.dbf tag=TAG20241201T154304 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2024-12-01 15:43:06

RMAN>

[oracle@cmxdb /oracle/rmanback]$ ls -l
total 2430848
-rw-r----- 1 oracle oinstall    9895936 Dec  1 15:43 control_01.dbf
-rw-r----- 1 oracle oinstall 1229717504 Dec  1 15:40 data_0l3bjou7_1_1.dbf
-rw-r----- 1 oracle oinstall    9928704 Dec  1 15:40 data_0m3bjova_1_1.dbf


主庫
alter database backup controlfile to '/oracle/rmanback/control01.ctl';
主庫生成文字檔案的備份控制檔案
alter database backup controlfile to trace as '/home/oracle/tmp/b.ctl';

當需要建立備庫時,可以使用如下方式:
alter database create standby controlfile as '/oracle/rmanback/control01.ctl';

2.3備份引數檔案

SQL> show parameter spfile;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /oracle/dbsoft/product/ora11g/
                                                 dbs/spfilecmxdb.ora
SQL> create pfile='/oracle/rmanback/init31.ora' from spfile;

File created.

SQL> host ls -l /oracle/rmanback/
total 2430852
-rw-r----- 1 oracle oinstall    9895936 Dec  1 15:43 control_01.dbf
-rw-r----- 1 oracle oinstall 1229717504 Dec  1 15:40 data_0l3bjou7_1_1.dbf
-rw-r----- 1 oracle oinstall    9928704 Dec  1 15:40 data_0m3bjova_1_1.dbf
-rw-r----- 1 oracle oinstall 1229717504 Dec  1 15:42 data_0n3bjp2q_1_1.dbf
-rw-r----- 1 oracle oinstall    9928704 Dec  1 15:42 data_0o3bjp2t_1_1.dbf
-rw-r--r-- 1 oracle oinstall       1183 Dec  1 15:46 init31.ora

3.傳輸備份

[oracle@cmxdb /oracle/rmanback]$ scp /oracle/rmanback/* 10.0.0.33:/oracle/rmanback/

[oracle@cmxbak ~]$ ll /oracle/rmanback/
total 2430852
-rw-r----- 1 oracle oinstall    9895936 Dec  1 15:59 control_01.dbf
-rw-r----- 1 oracle oinstall 1229717504 Dec  1 16:00 data_0l3bjou7_1_1.dbf
-rw-r----- 1 oracle oinstall    9928704 Dec  1 16:00 data_0m3bjova_1_1.dbf
-rw-r----- 1 oracle oinstall 1229717504 Dec  1 16:00 data_0n3bjp2q_1_1.dbf
-rw-r----- 1 oracle oinstall    9928704 Dec  1 16:00 data_0o3bjp2t_1_1.dbf
-rw-r--r-- 1 oracle oinstall       1183 Dec  1 16:00 init31.ora

4.傳輸歸檔日誌

1.獲取歸檔存放路徑
[oracle@cmxdb /oracle/rmanback]$ sqlplus / as sysdba

SQL> select name from v$archived_log order by 1;

NAME
--------------------------------------------------------------------------------
/archlog/1_10_1185485602.dbf
/archlog/1_11_1185485602.dbf

2.目標端配置相同路徑
[oracle@cmxbak ~]$ ll /archlog/
ps:若有舊資料的歸檔,直接刪除

3.傳輸歸檔日誌
[oracle@cmxdb /oracle/rmanback]$ scp   /archlog/* 10.0.0.33:/archlog
oracle@10.0.0.33's password:
1_10_1185485602.dbf                                                                      100%   31MB 103.3MB/s   00:00
1_11_1185485602.dbf                                                                      100%   36MB  79.3MB/s   00:00
1_12_1185485602.dbf                                                                      100%   29MB  90.4MB/s   00:00

4.目標端檢視
[oracle@cmxbak ~]$ ll /archlog/
total 569756
-rw-r----- 1 oracle oinstall 32854528 Dec  1 16:10 1_10_1185485602.dbf
-rw-r----- 1 oracle oinstall 37998080 Dec  1 16:10 1_11_1185485602.dbf

5.目標端配置環境變數

[oracle@cmxbak ~]$ cd

調整目標端的ORACLE_SID
[oracle@cmxbak ~]$ cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
# User specific environment and startup program
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_BASE=/oracle/dbsoft
export ORACLE_HOME=/oracle/dbsoft/product/ora11g
export ORACLE_SID=cmxdb
export ORACLE_TERM=xterm
export BASE_PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$BASE_PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS";
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
PATH=$PATH:$HOME/bin
export PATH

[oracle@cmxbak ~]$ source .bash_profile

5.恢復

5.1 恢復到nomount狀態

1.檢視引數檔案中的路徑並進行建立
[oracle@cmxbak ~]$ cat /oracle/rmanback/init31.ora
cmxdb.__db_cache_size=2516582400
cmxdb.__java_pool_size=16777216
cmxdb.__large_pool_size=33554432
cmxdb.__oracle_base='/oracle/dbsoft'#ORACLE_BASE set from environment
cmxdb.__pga_aggregate_target=1056964608
cmxdb.__sga_target=3154116608
cmxdb.__shared_io_pool_size=0
cmxdb.__shared_pool_size=553648128
cmxdb.__streams_pool_size=0
*.audit_file_dest='/oracle/dbsoft/admin/cmxdb/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/oradata/cmxdb/control01.ctl','/oracle/dbsoft/fast_recovery_area/cmxdb/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='cmxdb'
*.db_recovery_file_dest='/oracle/dbsoft/fast_recovery_area'
*.db_recovery_file_dest_size=1462763520
*.diagnostic_dest='/oracle/dbsoft'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=cmxdbXDB)'
*.fal_client='cmxdb'
*.fal_server='drcmxdb'
*.log_archive_dest_1='LOCATION=/archlog'
*.log_archive_dest_2='SERVICE=drcmxdbdg LGWR ASYNC VALID_FOR=(ONLINE_LOGFILE,PRIMARY_ROLE) DB_UNIQUE_NAME=drcmxdb'
*.open_cursors=300
*.pga_aggregate_target=1049624576
*.processes=1500
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=1655
*.sga_target=3148873728
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'

[oracle@cmxbak ~]$ mkdir -p /oracle/dbsoft
[oracle@cmxbak ~]$ mkdir -p /oracle/dbsoft/admin/cmxdb/adump
[oracle@cmxbak ~]$ mkdir -p /oradata/cmxdb/
[oracle@cmxbak ~]$ mkdir -p /oracle/dbsoft/fast_recovery_area/cmxdb/

2.使用新引數檔案啟動到nomount狀態
startup nomount pfile='/oracle/rmanback/init31.ora';
show parameter instance_name --複核例項名配置是否正常
create spfile from pfile='/oracle/rmanback/init31.ora';
shutdown immediate;
startup nomount;


show parameter ARCH
show parameter fal_server
show parameter fal_client
show parameter standby_file_management
show parameter name

3.檢查啟動的例項
[oracle@cmxbak ~]$  ps -ef |grep pmon
oracle    23399      1  0 16:16 ?        00:00:00 ora_pmon_cmxdb
oracle    23440  23065  0 16:17 pts/0    00:00:00 grep --color=auto pmon

5.2 恢復到mount狀態

1.恢復控制檔案
方式一:使用rman恢復指定控制檔案
[oracle@cmxbak /oracle/rmanback]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Sun Dec 1 16:19:54 2024

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

connected to target database: CMXDB (not mounted)

RMAN> restore controlfile from '/oracle/rmanback/control_01.dbf';

Starting restore at 2024-12-01 16:20:03
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=572 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/oradata/cmxdb/control01.ctl
output file name=/oracle/dbsoft/fast_recovery_area/cmxdb/control02.ctl
Finished restore at 2024-12-01 16:20:04

方式二:檢視引數檔案中控制檔案的位置,將控制檔案cp到指定的位置
此種方法需要手動生成的控制檔案,並非備份的控制檔案
[oracle@cmxbak /oracle/rmanback]$ cat init31.ora  |grep control_files
*.control_files='/oradata/cmxdb/control01.ctl','/oracle/dbsoft/fast_recovery_area/cmxdb/control02.ctl'

[oracle@cmxbak /oracle/rmanback]$ cp /oracle/rmanback/control01.ctl  /oradata/cmxdb/control01.ctl
[oracle@cmxbak /oracle/rmanback]$ cp /oracle/rmanback/control01.ctl  /oracle/dbsoft/fast_recovery_area/cmxdb/control02.ctl

[oracle@cmxbak /oracle/rmanback]$ ll /oradata/cmxdb/control01.ctl
-rw-r----- 1 oracle oinstall 9895936 Dec  5 17:00 /oradata/cmxdb/control01.ctl
[oracle@cmxbak /oracle/rmanback]$ ll /oracle/dbsoft/fast_recovery_area/cmxdb/control02.ctl
-rw-r----- 1 oracle oinstall 9895936 Dec  5 17:00 /oracle/dbsoft/fast_recovery_area/cmxdb/control02.ctl


2.啟動到mount狀態
RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

3.資料庫中檢視資料庫的狀態
SQL> select OPEN_MODE,database_role from v$database;

OPEN_MODE            DATABASE_ROLE
-------------------- ----------------
MOUNTED              PRIMARY

5.3 檢查備份和備份片

RMAN> LIST BACKUP OF DATABASE;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
3       Full    1.11G      DISK        00:00:02     2024-11-27 17:00:21
        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20241127T170019
        Piece Name: /ora_bak/db_0a3b6np3_1_1
  List of Datafiles in backup set 3
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1       Full 1148808    2024-11-27 17:00:19 /oradata/cmxdb/system01.dbf
  2       Full 1148808    2024-11-27 17:00:19 /oradata/cmxdb/sysaux01.dbf
  3       Full 1148808    2024-11-27 17:00:19 /oradata/cmxdb/undotbs01.dbf
  4       Full 1148808    2024-11-27 17:00:19 /oradata/cmxdb/users01.dbf
  5       Full 1148808    2024-11-27 17:00:19 /oradata/cmxdb/example01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
7       Full    1.11G      DISK        00:00:02     2024-11-27 17:03:37
        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20241127T170335
        Piece Name: /ora_bak/db_0f3b6nv7_1_1
  List of Datafiles in backup set 7
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1       Full 1149047    2024-11-27 17:03:35 /oradata/cmxdb/system01.dbf
  2       Full 1149047    2024-11-27 17:03:35 /oradata/cmxdb/sysaux01.dbf
  3       Full 1149047    2024-11-27 17:03:35 /oradata/cmxdb/undotbs01.dbf
  4       Full 1149047    2024-11-27 17:03:35 /oradata/cmxdb/users01.dbf
  5       Full 1149047    2024-11-27 17:03:35 /oradata/cmxdb/example01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
9       Full    1.11G      DISK        00:00:01     2024-11-27 17:04:42
        BP Key: 9   Status: AVAILABLE  Compressed: NO  Tag: TAG20241127T170441
        Piece Name: /ora_bak/db_0i3b6o19_1_1
  List of Datafiles in backup set 9
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1       Full 1149136    2024-11-27 17:04:41 /oradata/cmxdb/system01.dbf
  2       Full 1149136    2024-11-27 17:04:41 /oradata/cmxdb/sysaux01.dbf
  3       Full 1149136    2024-11-27 17:04:41 /oradata/cmxdb/undotbs01.dbf
  4       Full 1149136    2024-11-27 17:04:41 /oradata/cmxdb/users01.dbf
  5       Full 1149136    2024-11-27 17:04:41 /oradata/cmxdb/example01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
12      Full    1.15G      DISK        00:00:27     2024-12-01 15:40:18
        BP Key: 12   Status: AVAILABLE  Compressed: NO  Tag: TAG20241201T153951
        Piece Name: /oracle/rmanback/data_0l3bjou7_1_1.dbf
  List of Datafiles in backup set 12
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1       Full 1391030    2024-12-01 15:39:51 /oradata/cmxdb/system01.dbf
  2       Full 1391030    2024-12-01 15:39:51 /oradata/cmxdb/sysaux01.dbf
  3       Full 1391030    2024-12-01 15:39:51 /oradata/cmxdb/undotbs01.dbf
  4       Full 1391030    2024-12-01 15:39:51 /oradata/cmxdb/users01.dbf
  5       Full 1391030    2024-12-01 15:39:51 /oradata/cmxdb/example01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
14      Full    1.15G      DISK        00:00:02     2024-12-01 15:42:20
        BP Key: 14   Status: AVAILABLE  Compressed: NO  Tag: TAG20241201T154218
        Piece Name: /oracle/rmanback/data_0n3bjp2q_1_1.dbf
  List of Datafiles in backup set 14
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1       Full 1391195    2024-12-01 15:42:18 /oradata/cmxdb/system01.dbf
  2       Full 1391195    2024-12-01 15:42:18 /oradata/cmxdb/sysaux01.dbf
  3       Full 1391195    2024-12-01 15:42:18 /oradata/cmxdb/undotbs01.dbf
  4       Full 1391195    2024-12-01 15:42:18 /oradata/cmxdb/users01.dbf
  5       Full 1391195    2024-12-01 15:42:18 /oradata/cmxdb/example01.dbf

RMAN>


檢視備份片是否存在
[oracle@cmxbak ~]$ ll /oracle/rmanback/data_0l3bjou7_1_1.dbf
-rw-r----- 1 oracle oinstall 1229717504 Dec  1 16:00 /oracle/rmanback/data_0l3bjou7_1_1.dbf

5.4 恢復到open狀態

恢復資料檔案

1.恢復資料檔案
RMAN> restore database;

Starting restore at 2024-12-01 16:47:50
Starting implicit crosscheck backup at 2024-12-01 16:47:50
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1141 device type=DISK
Crosschecked 14 objects
Finished implicit crosscheck backup at 2024-12-01 16:47:50

Starting implicit crosscheck copy at 2024-12-01 16:47:50
using channel ORA_DISK_1
Crosschecked 4 objects
Finished implicit crosscheck copy at 2024-12-01 16:47:50

searching for all files in the recovery area
cataloging files...
no files cataloged

using channel ORA_DISK_1

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 /oradata/cmxdb/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /oradata/cmxdb/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /oradata/cmxdb/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /oradata/cmxdb/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /oradata/cmxdb/example01.dbf
channel ORA_DISK_1: reading from backup piece /oracle/rmanback/data_0n3bjp2q_1_1.dbf
channel ORA_DISK_1: piece handle=/oracle/rmanback/data_0n3bjp2q_1_1.dbf tag=TAG20241201T154218
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 2024-12-01 16:47:53


2.檢查
[oracle@cmxbak ~]$ ll /oradata/
total 0
drwxr-xr-x 2 oracle oinstall 128 Nov 27 18:01 cmxdb
[oracle@cmxbak ~]$ ll /oradata/cmxdb/
total 1828544
-rw-r----- 1 oracle oinstall   9846784 Dec  1 16:48 control01.ctl
-rw-r----- 1 oracle oinstall 347348992 Dec  1 16:47 example01.dbf
-rw-r----- 1 oracle oinstall 629153792 Dec  1 16:47 sysaux01.dbf
-rw-r----- 1 oracle oinstall 786440192 Dec  1 16:47 system01.dbf
-rw-r----- 1 oracle oinstall  94380032 Dec  1 16:47 undotbs01.dbf
-rw-r----- 1 oracle oinstall   5251072 Dec  1 16:47 users01.dbf

檢查控制檔案中的歸檔日誌是否存在

[oracle@cmxbak /oracle/rmanback]$ rman target /

1.檢查當前資料庫的備份
list backup;


2.將備份註冊到資料庫中
RMAN> catalog start with '/oracle/rmanback/';

searching for all files that match the pattern /oracle/rmanback/

List of Files Unknown to the Database
=====================================
File Name: /oracle/rmanback/data_0v3buej4_1_1.dbf
File Name: /oracle/rmanback/data_103buej4_1_1.dbf
File Name: /oracle/rmanback/data_113buej4_1_1.dbf
File Name: /oracle/rmanback/data_123buej5_1_1.dbf
File Name: /oracle/rmanback/data_133buej6_1_1.dbf

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

List of Cataloged Files
=======================
File Name: /oracle/rmanback/data_0v3buej4_1_1.dbf
File Name: /oracle/rmanback/data_103buej4_1_1.dbf
File Name: /oracle/rmanback/data_113buej4_1_1.dbf
File Name: /oracle/rmanback/data_123buej5_1_1.dbf
File Name: /oracle/rmanback/data_133buej6_1_1.dbf

3.檢視全備
RMAN> crosscheck backup;

using channel ORA_DISK_1
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/oracle/rmanback/data_0v3buej4_1_1.dbf RECID=31 STAMP=1186943917
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/oracle/rmanback/data_103buej4_1_1.dbf RECID=32 STAMP=1186943917
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/oracle/rmanback/data_113buej4_1_1.dbf RECID=33 STAMP=1186943917
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/oracle/rmanback/data_123buej5_1_1.dbf RECID=34 STAMP=1186943917
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/oracle/rmanback/data_133buej6_1_1.dbf RECID=35 STAMP=1186943917
Crosschecked 5 objects


4.檢視歸檔
RMAN> crosscheck archivelog all;

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1141 device type=DISK
validation succeeded for archived log
archived log file name=/archlog/1_58_1185485602.dbf RECID=97 STAMP=1186870463
validation succeeded for archived log
archived log file name=/archlog/1_59_1185485602.dbf RECID=99 STAMP=1186937393
Crosschecked 2 objects

恢復資料庫

RMAN> recover database;

Starting recover at 2024-12-01 16:50:24
using channel ORA_DISK_1

starting media recovery

unable to find archived log
archived log thread=1 sequence=54
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 12/01/2024 16:50:25
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 54 and starting SCN of 1391195

報錯:執行如下命令,恢復到執行的scn位置
RMAN> recover database until scn 1391195;

Starting recover at 2024-12-01 16:54:17
using channel ORA_DISK_1

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

Finished recover at 2024-12-01 16:54:17

啟動資料庫open狀態

RMAN> alter database open resetlogs;

database opened

SQL> select OPEN_MODE,database_role from v$database;

OPEN_MODE            DATABASE_ROLE
-------------------- ----------------
READ WRITE           PRIMARY

相關文章