暂无图片
暂无图片
4
暂无图片
暂无图片
1
暂无图片

Oracle--RMAN异机恢复

原创 胡振兴 2023-03-28
1970

--异机恢复所需要的文件包括:参数文件、归档日志、控制文件和数据文件

1.源库用rman进行全备并定义文件格式

backup database format '/soft/database_fullbak_%d_%T_%s.bak‘;

RMAN> backup database format '/soft/database_fullbak_%d_%T_%s.bak';

Starting backup at 2023-03-28 14:45:30

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=/oracle/app/oracle/oradata/CDB19C/system01.dbf

input datafile file number=00003 name=/oracle/app/oracle/oradata/CDB19C/sysaux01.dbf

input datafile file number=00004 name=/oracle/app/oracle/oradata/CDB19C/undotbs01.dbf

input datafile file number=00014 name=/oracle/app/oracle/oradata/text02.dbf

input datafile file number=00013 name=/oracle/app/oracle/oradata/text01.dbf

input datafile file number=00007 name=/oracle/app/oracle/oradata/CDB19C/users01.dbf

channel ORA_DISK_1: starting piece 1 at 2023-03-28 14:45:30

channel ORA_DISK_1: finished piece 1 at 2023-03-28 14:46:25

piece handle=/soft/database_fullbak_CDB19C_20230328_110.bak tag=TAG20230328T144530 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00010 name=/oracle/app/oracle/oradata/CDB19C/erp/sysaux01.dbf

input datafile file number=00009 name=/oracle/app/oracle/oradata/CDB19C/erp/system01.dbf

input datafile file number=00011 name=/oracle/app/oracle/oradata/CDB19C/erp/undotbs01.dbf

input datafile file number=00025 name=/oracle/app/oracle/oradata/CDB19C/tb_cat.dbf

input datafile file number=00026 name=/oracle/app/oracle/oradata/CDB19C/recover.dbf

input datafile file number=00020 name=/oracle/app/oracle/oradata/CDB19C/tbs_ogg.dbf

input datafile file number=00024 name=/oracle/app/oracle/oradata/CDB19C/erp/mig01.dbf

input datafile file number=00012 name=/oracle/app/oracle/oradata/CDB19C/erp/users01.dbf

input datafile file number=00018 name=/oracle/app/oracle/oradata/CDB19C/erp/exptbs01.dbf

channel ORA_DISK_1: starting piece 1 at 2023-03-28 14:46:26

channel ORA_DISK_1: finished piece 1 at 2023-03-28 14:47:01

piece handle=/soft/database_fullbak_CDB19C_20230328_111.bak tag=TAG20230328T144530 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

input datafile file number=00022 name=/oracle/app/oracle/oradata/CDB19C/hr/sysaux01.dbf

input datafile file number=00021 name=/oracle/app/oracle/oradata/CDB19C/hr/system01.dbf

input datafile file number=00023 name=/oracle/app/oracle/oradata/CDB19C/hr/undotbs01.dbf

channel ORA_DISK_1: starting piece 1 at 2023-03-28 14:47:01

channel ORA_DISK_1: finished piece 1 at 2023-03-28 14:47:08

piece handle=/soft/database_fullbak_CDB19C_20230328_112.bak tag=TAG20230328T144530 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00016 name=/oracle/app/oracle/oradata/CDB19C/prodb/sysaux01.dbf

input datafile file number=00015 name=/oracle/app/oracle/oradata/CDB19C/prodb/system01.dbf

input datafile file number=00017 name=/oracle/app/oracle/oradata/CDB19C/prodb/undotbs01.dbf

channel ORA_DISK_1: starting piece 1 at 2023-03-28 14:47:08

channel ORA_DISK_1: finished piece 1 at 2023-03-28 14:47:15

piece handle=/soft/database_fullbak_CDB19C_20230328_113.bak tag=TAG20230328T144530 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00006 name=/oracle/app/oracle/oradata/CDB19C/pdbseed/sysaux01.dbf

input datafile file number=00005 name=/oracle/app/oracle/oradata/CDB19C/pdbseed/system01.dbf

input datafile file number=00008 name=/oracle/app/oracle/oradata/CDB19C/pdbseed/undotbs01.dbf

channel ORA_DISK_1: starting piece 1 at 2023-03-28 14:47:15

channel ORA_DISK_1: finished piece 1 at 2023-03-28 14:47:22

piece handle=/soft/database_fullbak_CDB19C_20230328_114.bak tag=TAG20230328T144530 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07

Finished backup at 2023-03-28 14:47:22

Starting Control File and SPFILE Autobackup at 2023-03-28 14:47:22

piece handle=/oracle/app/oracle/product/19.3.0/dbhome_1/dbs/c-593816513-20230328-04 comment=NONE

Finished Control File and SPFILE Autobackup at 2023-03-28 14:47:30

2.查看备份

list backup;   在/soft目录下

BS Key Type LV Size Device Type Elapsed Time Completion Time


96 Full 1.27G DISK 00:00:54 2023-03-28 14:46:24

BP Key: 96 Status: AVAILABLE Compressed: NO Tag: TAG20230328T144530 Piece Name: /soft/database_fullbak_CDB19C_20230328_110.bak

List of Datafiles in backup set 96

File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name


1 Full 7338332 2023-03-28 14:45:30 NO /oracle/app/oracle/oradata/CDB19C/system01.dbf

3 Full 7338332 2023-03-28 14:45:30 NO /oracle/app/oracle/oradata/CDB19C/sysaux01.dbf

4 Full 7338332 2023-03-28 14:45:30 NO /oracle/app/oracle/oradata/CDB19C/undotbs01.dbf

7 Full 7338332 2023-03-28 14:45:30 NO /oracle/app/oracle/oradata/CDB19C/users01.dbf

13 Full 7338332 2023-03-28 14:45:30 NO /oracle/app/oracle/oradata/text01.dbf

14 Full 7338332 2023-03-28 14:45:30 NO /oracle/app/oracle/oradata/text02.dbf



查看备份的控制文件

list backup of controlfile ; 

BS Key Type LV Size Device Type Elapsed Time Completion Time


101 Full 18.08M DISK 00:00:01 2023-03-28 14:47:23

BP Key: 101 Status: AVAILABLE Compressed: NO Tag: TAG20230328T144722 Piece Name: /oracle/app/oracle/product/19.3.0/dbhome_1/dbs/c-593816513-20230328-04

Control File Included: Ckp SCN: 7338566 Ckp time: 2023-03-28 14:47:22


list backup of spfile;  查看参数文件

BS Key Type LV Size Device Type Elapsed Time Completion Time


101 Full 18.08M DISK 00:00:01 2023-03-28 14:47:23

BP Key: 101 Status: AVAILABLE Compressed: NO Tag: TAG20230328T144722 Piece Name: /oracle/app/oracle/product/19.3.0/dbhome_1/dbs/c-593816513-20230328-04

SPFILE Included: Modification time: 2023-03-28 09:01:32

SPFILE db_unique_name: CDB19C


3.scp /soft/文件中的bak到异机的/soft/目录下

[oracle@henry soft]$ scp /soft/database_fullbak_CDB19C_20230328_110.bak oracle@192.168.6.132:/soft/


scp spfile文件和control文件到soft 目录下

[oracle@henry soft]$ scp /oracle/app/oracle/product/19.3.0/dbhome_1/dbs/c-593816513-20230328-04 oracle@192.168.6.132:/soft/

oracle@192.168.6.132's password:

c-593816513-20230328-04 100% 18MB 11.4MB/s 00:01

4.目标库进入rman中

恢复参数文件 (因为我的目标库是克隆的源库,所以参数文件可以不用恢复);

restore spfile from '/oracle/app/oracle/product/19.3.0/dbhome_1/dbs/c-593816513-20230328-01';

env查看环境主要注意oracle_sid

file spfile文件看格式是否是data,如果是ASCII text则是pfile文件格式

[oracle@henry soft]$ file c-593816513-20230328-04

c-593816513-20230328-04: data

需要 create spfile from pfile='文件路径'

如果报错找不到路径则要创建相对应的文件路径并赋权

5.在sql中执行

恢复控制文件

shutdown immediate

这里可以在RMAN 执行 startup nomount

RMAN> startup nomount;

Oracle instance started

Total System Global Area 2432695872 bytes

Fixed Size 9137728 bytes

Variable Size 587202560 bytes

Database Buffers 1828716544 bytes

Redo Buffers 7639040 bytes

在rman中执行

restore controlfile from '/soft/ c-593816513-20230328-04';

RMAN> restore controlfile from '/soft/c-593816513-20230328-04';

Starting restore at 2023-03-28 15:02:16

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=2 device type=DISK

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

output file name=/oracle/app/oracle/oradata/CDB19C/control01.ctl

output file name=/oracle/app/oracle/oradata/CDB19C/control02.ctl

Finished restore at 2023-03-28 15:02:18


6.源库backup archivelog all;备份归档日志

RMAN> backup archivelog all;

Starting backup at 2023-03-28 15:02:51

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=55 RECID=34 STAMP=1132334930

input archived log thread=1 sequence=56 RECID=35 STAMP=1132565098

input archived log thread=1 sequence=57 RECID=36 STAMP=1132566146

input archived log thread=1 sequence=58 RECID=37 STAMP=1132650092

input archived log thread=1 sequence=59 RECID=38 STAMP=1132657071

input archived log thread=1 sequence=60 RECID=39 STAMP=1132658064

input archived log thread=1 sequence=61 RECID=40 STAMP=1132671772

channel ORA_DISK_1: starting piece 1 at 2023-03-28 15:02:52

channel ORA_DISK_1: finished piece 1 at 2023-03-28 15:02:55

piece handle=/oracle/app/oracle/product/19.3.0/dbhome_1/dbs/3k1o6cos_1_1 tag=TAG20230328T150252 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03

Finished backup at 2023-03-28 15:02:55

Starting Control File and SPFILE Autobackup at 2023-03-28 15:02:55

piece handle=/oracle/app/oracle/product/19.3.0/dbhome_1/dbs/c-593816513-20230328-05 comment=NONE

Finished Control File and SPFILE Autobackup at 2023-03-28 15:02:56

7.并将备份的归档日志传到异机的soft文件下

piece handle=/oracle/app/oracle/product/19.3.0/dbhome_1/dbs/3k1o6cos_1_1

归档日志备份的地方

scp 过去

[oracle@henry ~]$ scp /oracle/app/oracle/product/19.3.0/dbhome_1/dbs/3k1o6cos_1_1 oracle@192.168.6.132:/soft/

8.. alter database mount;

9.catalog start with '/soft/';添加验证

RMAN> catalog start with '/soft'

searching for all files that match the pattern /soft

List of Files Unknown to the Database

File Name: /soft/07-LINUX.X64_193000_db_home.zip

File Name: /soft/scottdemo.sql

File Name: /soft/13-rlwrap-0.42.tar.gz

File Name: /soft/rlwrap-0.42/PLEA

File Name: /soft/rlwrap-0.42/tools/config.sub

File Name: /soft/rlwrap-0.42/tools/test-driver

File Name: /soft/rlwrap-0.42/tools/install-sh

File Name: /soft/rlwrap-0.42/tools/missing

File Name: /soft/rlwrap-0.42/tools/config.guess

File Name: /soft/rlwrap-0.42/tools/compile

File Name: /soft/rlwrap-0.42/tools/depcomp

File Name: /soft/rlwrap-0.42/NEWS

File Name: /soft/rlwrap-0.42/aclocal.m4

File Name: /soft/rlwrap-0.42/config.h.in

File Name: /soft/rlwrap-0.42/configure.ac

File Name: /soft/rlwrap-0.42/ChangeLog

File Name: /soft/rlwrap-0.42/completions/coqtop

File Name: /soft/rlwrap-0.42/completions/testclient

File Name: /soft/rlwrap-0.42/COPYING

File Name: /soft/rlwrap-0.42/src/string_utils.c

File Name: /soft/rlwrap-0.42/src/term.c

File Name: /soft/rlwrap-0.42/src/main.c

File Name: /soft/rlwrap-0.42/src/completion.rb

File Name: /soft/rlwrap-0.42/src/pty.c

File Name: /soft/rlwrap-0.42/src/utils.c

File Name: /soft/rlwrap-0.42/src/rlwrap.h

File Name: /soft/rlwrap-0.42/src/signals.c

File Name: /soft/rlwrap-0.42/src/redblack.h

File Name: /soft/rlwrap-0.42/src/completion.c

File Name: /soft/rlwrap-0.42/src/filter.c

File Name: /soft/rlwrap-0.42/src/ptytty.c

File Name: /soft/rlwrap-0.42/src/malloc_debug.h

File Name: /soft/rlwrap-0.42/src/Makefile.am

File Name: /soft/rlwrap-0.42/src/readline.c

File Name: /soft/rlwrap-0.42/src/malloc_debug.c

File Name: /soft/rlwrap-0.42/src/Makefile.in

File Name: /soft/rlwrap-0.42/src/Makefile

File Name: /soft/rlwrap-0.42/src/.deps/completion.Po

File Name: /soft/rlwrap-0.42/src/.deps/filter.Po

File Name: /soft/rlwrap-0.42/src/.deps/main.Po

File Name: /soft/rlwrap-0.42/src/.deps/malloc_debug.Po

File Name: /soft/rlwrap-0.42/src/.deps/pty.Po

File Name: /soft/rlwrap-0.42/src/.deps/ptytty.Po

File Name: /soft/rlwrap-0.42/src/.deps/readline.Po

File Name: /soft/rlwrap-0.42/src/.deps/signals.Po

File Name: /soft/rlwrap-0.42/src/.deps/string_utils.Po

File Name: /soft/rlwrap-0.42/src/.deps/term.Po

File Name: /soft/rlwrap-0.42/src/.deps/utils.Po

File Name: /soft/rlwrap-0.42/src/main.o

File Name: /soft/rlwrap-0.42/src/signals.o

File Name: /soft/rlwrap-0.42/src/readline.o

File Name: /soft/rlwrap-0.42/src/pty.o

File Name: /soft/rlwrap-0.42/src/completion.o

File Name: /soft/rlwrap-0.42/src/term.o

File Name: /soft/rlwrap-0.42/src/ptytty.o

File Name: /soft/rlwrap-0.42/src/utils.o

File Name: /soft/rlwrap-0.42/src/string_utils.o

File Name: /soft/rlwrap-0.42/src/malloc_debug.o

File Name: /soft/rlwrap-0.42/src/filter.o

File Name: /soft/rlwrap-0.42/src/rlwrap

File Name: /soft/rlwrap-0.42/TODO

File Name: /soft/rlwrap-0.42/BUGS

File Name: /soft/rlwrap-0.42/doc/rlwrap.man.in

File Name: /soft/rlwrap-0.42/doc/Makefile.am

File Name: /soft/rlwrap-0.42/doc/Makefile.in

File Name: /soft/rlwrap-0.42/doc/Makefile

File Name: /soft/rlwrap-0.42/doc/rlwrap.man

File Name: /soft/rlwrap-0.42/doc/rlwrap.1

File Name: /soft/rlwrap-0.42/configure

File Name: /soft/rlwrap-0.42/Makefile.am

File Name: /soft/rlwrap-0.42/INSTALL

File Name: /soft/rlwrap-0.42/README

File Name: /soft/rlwrap-0.42/test/testit

File Name: /soft/rlwrap-0.42/test/testclient

File Name: /soft/rlwrap-0.42/filters/listing

File Name: /soft/rlwrap-0.42/filters/logger

File Name: /soft/rlwrap-0.42/filters/pipeline

File Name: /soft/rlwrap-0.42/filters/RlwrapFilter.3pm

File Name: /soft/rlwrap-0.42/filters/history_format

File Name: /soft/rlwrap-0.42/filters/ftp_filter

File Name: /soft/rlwrap-0.42/filters/pipeto

File Name: /soft/rlwrap-0.42/filters/unbackspace

File Name: /soft/rlwrap-0.42/filters/Makefile.am

File Name: /soft/rlwrap-0.42/filters/null

File Name: /soft/rlwrap-0.42/filters/simple_macro

File Name: /soft/rlwrap-0.42/filters/censor_passwords

File Name: /soft/rlwrap-0.42/filters/README

File Name: /soft/rlwrap-0.42/filters/RlwrapFilter.pm

File Name: /soft/rlwrap-0.42/filters/Makefile.in

File Name: /soft/rlwrap-0.42/filters/count_in_prompt

File Name: /soft/rlwrap-0.42/filters/scrub_prompt

File Name: /soft/rlwrap-0.42/filters/template

File Name: /soft/rlwrap-0.42/filters/paint_prompt

File Name: /soft/rlwrap-0.42/filters/Makefile

File Name: /soft/rlwrap-0.42/Makefile.in

File Name: /soft/rlwrap-0.42/AUTHORS

File Name: /soft/rlwrap-0.42/config.log

File Name: /soft/rlwrap-0.42/config.status

File Name: /soft/rlwrap-0.42/Makefile

File Name: /soft/rlwrap-0.42/config.h

File Name: /soft/rlwrap-0.42/stamp-h1

File Name: /soft/.bash_profile

File Name: /soft/c-593816513-20230328-04

File Name: /soft/c-593816513-20230328-05

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

10.恢复数据库

restore database;

recover database;报如下错误

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=61

channel ORA_DISK_1: reading from backup piece /soft/3k1o6cos_1_1

channel ORA_DISK_1: piece handle=/soft/3k1o6cos_1_1 tag=TAG20230328T150252

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

archived log file name=/oracle/app/oracle/product/19.3.0/dbhome_1/dbs/arch1_61_1112633348.dbf thread=1 sequence=61

unable to find archived log

archived log thread=1 sequence=62

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of recover command at 03/28/2023 15:39:00

RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 62 and starting SCN of 7341428

指定SCN 恢复recover database until scn 7341428;

11.进入数据库startup发现已经启动

则输入alter database open resetlogs;


12.验证数据库是否有用

show pdbs

SQL> alter pluggable database prodb open;

Pluggable database altered.

---恢复成功

13.报以下错误,解决方法

ORA-01194: file 1 needs more recovery to be consistent

conn sys/oracle as sysdba  

1、查询

select v1.group#, member, sequence#, first_change#

from v$log v1, v$logfile v2

where v1.group# = v2.group#;

2、从结果里根据 sequence# 和 first_change# 找到了要用到的log file name:

在 Specify log: {=suggested | filename | AUTO | CANCEL} 下面输入:

/u01/app/oracle/oradata/orcl/redo03.log

提示:

Log applied.

Media recovery complete.

3. alter database open resetlogs;





最后修改时间:2023-04-13 11:13:23
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

星星之火
暂无图片
1年前
评论
暂无图片 0
https://www.modb.pro/db/1754671399281184768
1年前
暂无图片 点赞
评论
目录
  • 1.源库用rman进行全备并定义文件格式
  • 2.查看备份
  • 3.scp /soft/文件中的bak到异机的/soft/目录下
  • 4.目标库进入rman中
  • 5.在sql中执行
  • 6.源库backup archivelog all;备份归档日志
  • 7.并将备份的归档日志传到异机的soft文件下
  • 8.. alter database mount;
  • 9.catalog start with '/soft/';添加验证
  • 10.恢复数据库
  • 11.进入数据库startup发现已经启动
  • 12.验证数据库是否有用
  • 13.报以下错误,解决方法