rman 异机恢复 set newname 的实验

2023-11-29 13:18

本文主要是介绍rman 异机恢复 set newname 的实验,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

12月17日rman 异机恢复:

对本次试验的一点说明:

(1)RMAN 异机恢复的时候,db_name必须相同。 如果说要想改成其他的实例名,可以在恢复成功后,用nid 命令修改。 实例名的信息会记录到控制文件里,所以如果在恢复的时候,如果实例名不一致,恢复的时候会报错。

(2)如果恢复的路径和源库不一致,就需要在restore时用set 命令指定新位置。 并且使用switch datafile all将信息更新的到控制文件。

       在做duplicate的时候,RMAN 会自动根据pfile中的log_file_name_convert和db_file_name_convert来进行set 的转换。 手工restore时,只能只只能使用set 命令。

(3)异机恢复对相同目录和不同目录都做了说明。


RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/rman/ctl_%F';

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/rman/ctl_%F';
new RMAN configuration parameters are successfully stored

RMAN> show all;

RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/rman/ctl_%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/pp/oracle/product/10.2/db_1/dbs/snapcf_ezhou.f'; # default

好,先全库备份:
RMAN> run{
2> backup
3> format '/u02/rman/full_%d_%t'
4> database;
5> }

Starting backup at 17-DEC-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u02/ezhou/system01.dbf
input datafile fno=00003 name=/u02/ezhou/sysaux01.dbf
input datafile fno=00005 name=/u02/ezhou/example01.dbf
input datafile fno=00002 name=/u02/ezhou/undotbs01.dbf
input datafile fno=00004 name=/u02/ezhou/users01.dbf
channel ORA_DISK_1: starting piece 1 at 17-DEC-11
channel ORA_DISK_1: finished piece 1 at 17-DEC-11
piece handle=/u02/rman/full_EZHOU_770149569 tag=TAG20111217T182608 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:38
Finished backup at 17-DEC-11

Starting Control File and SPFILE Autobackup at 17-DEC-11
piece handle=/u01/rman/ctl_c-4046377924-20111217-00 comment=NONE
Finished Control File and SPFILE Autobackup at 17-DEC-11

RMAN>

看一下备份路径:
[oracle@aoracle rman]$ pwd
/u02/rman
[oracle@aoracle rman]$ ls -l
total 609616
-rw-r----- 1 oracle oinstall 623632384 Dec 17 18:28 full_EZHOU_770149569
[oracle@aoracle rman]$

不过使用RMAN, DB要先启动到nomout 状态。 这个可以用默认的init.ora 来启动。

原来的init.ora要进行修改:
grep -v ^# init.ora > inittest.ora

export ORACLE_SID=xin
sqlplus / as sysdba
sql:> startup nomount pfile='/u01/pp/oracle/product/10.2/db_1/dbs/inittest.ora;
报错:
ORA-00371: not enough shared pool memory, should be atleast 62198988 bytes

好,下面修改inittest.ora 里的参数:
注释掉:
#db_block_buffers = 100                                                 # SMALL

#shared_pool_size = 3500000                                            # SMALL

就可以了:
SQL> startup nomount pfile='/u01/pp/oracle/product/10.2/db_1/dbs/inittest.ora;
ORACLE instance started.

Total System Global Area  113246208 bytes
Fixed Size                  1218004 bytes
Variable Size              58722860 bytes
Database Buffers           50331648 bytes
Redo Buffers                2973696 bytes

------------------

3. 创建初始化参数
将Target 库的pfile 文件copy过来。

也可以使用RMAN 从我们Target库的备份集中恢复,因为我们之前备份过spfile。不过使用RMAN, DB要先启动到nomout 状态。 这个可以用默认的init.ora 来启动。

[oracle@qs-dmm-rh2 backup]$ export ORACLE_SID=dave

[oracle@qs-dmm-rh2 backup]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Fri Mar 11 15:11:31 2011

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

connected to target database: DAVE (not mounted)

RMAN> restore spfile to pfile '/u01/rman/initezhou.ora' from '/u01/rman/ezhou_spfile_1_1_20110309'


下面很重要的一点就是:

如果修改数据文件保存的位置,那么要修改参数文件控制文件的相关的参数:
*.control_files='/u01/rman/control01.ctl','/u01/rman/control02.ctl','/u01/rman/control03.ctl'

*.db_name='dave'

 

4. 将用pfile将Auxiliary库启动到nomout 状态
SQL> startup nomount pfile=?/dbs/initezhou.ora

 

5. 恢复控制文件
[oracle@qs-dmm-rh2 dbs]$ export ORACLE_SID=ezhou

[oracle@qs-dmm-rh2 dbs]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Fri Mar 11 15:25:55 2011

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

connected to target database: ezhou (not mounted)

RMAN>  restore controlfile from '/u01/backup/ctl_file_15m6qtdc_1_1_20110309'

。。。。。

会看到恢复好的control 文件放到了/u01/rman 下面。

----------------------------------------------------------------------

好,下面先看一下control 文件:
strings control01.ctl

/u02/ezhou/redo03.log
/u02/ezhou/redo02.log
/u02/ezhou/redo01.log
/u02/ezhou/users01.dbf
/u02/ezhou/sysaux01.dbf
/u02/ezhou/undotbs01.dbf
/u02/ezhou/system01.dbf
/u02/ezhou/temp01.dbf
/u02/ezhou/example01.dbf
/u02/ezhou/redo03.log
/u02/ezhou/redo02.log
/u02/ezhou/redo01.log
/u02/ezhou/users01.dbf
/u02/ezhou/sysaux01.dbf
/u02/ezhou/undotbs01.dbf
/u02/ezhou/system01.dbf
/u02/ezhou/temp01.dbf
/u02/ezhou/example01.dbf
SYSTEM
UNDOTBS1
SYSAUX
USERS
TEMP
EXAMPLE
SYSTEM
UNDOTBS1
SYSAUX
USERS
TEMP
EXAMPLE
CONTROLFILE AUTOBACKUP
CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE
DISK TO '/u01/rman/ctl_%F'
CONTROLFILE AUTOBACKUP


下面对control 文件的内容进行更改:
[oracle@aoracle rman]$ env |grep ORA
ORACLE_SID=xin
ORACLE_BASE=/u01/pp/oracle
ORACLE_HOME=/u01/pp/oracle/product/10.2/db_1
[oracle@aoracle rman]$ sqlplus / as sysdba;

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Dec 17 21:02:05 2011

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

Connected to an idle instance.

SQL> startup nomount pfile='/u01/rman/initxin.ora';
ORACLE instance started.

Total System Global Area  335544320 bytes
Fixed Size                  1219280 bytes
Variable Size             104858928 bytes
Database Buffers          226492416 bytes
Redo Buffers                2973696 bytes
SQL> alter database mount;

Database altered.

SQL> !
[oracle@aoracle rman]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Sat Dec 17 21:07:33 2011

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

connected to target database: EZHOU (DBID=4046377924, not open)

RMAN> run {
2> set newname for datafile 1 to "/u01/rman/system01.dbf";
3> set newname for datafile 2 to "/u01/rman/undotbs01.dbf";
4> set newname for datafile 3 to "/u01/rman/sysaux01.dbf";
5> set newname for datafile 4 to "/u01/rman/users01.dbf";
6> set newname for datafile 5 to "/u01/rman/example01.dbf";
7> restore database;
8> switch datafile all;
9> }

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 17-DEC-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/rman/system01.dbf
restoring datafile 00002 to /u01/rman/undotbs01.dbf
restoring datafile 00003 to /u01/rman/sysaux01.dbf
restoring datafile 00004 to /u01/rman/users01.dbf
restoring datafile 00005 to /u01/rman/example01.dbf
channel ORA_DISK_1: reading from backup piece /u02/rman/full_EZHOU_770149569
channel ORA_DISK_1: restored backup piece 1
piece handle=/u02/rman/full_EZHOU_770149569 tag=TAG20111217T182608
channel ORA_DISK_1: restore complete, elapsed time: 00:01:05
Finished restore at 17-DEC-11

datafile 1 switched to datafile copy
input datafile copy recid=7 stamp=770160044 filename=/u01/rman/system01.dbf
datafile 2 switched to datafile copy
input datafile copy recid=8 stamp=770160044 filename=/u01/rman/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=9 stamp=770160044 filename=/u01/rman/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=10 stamp=770160045 filename=/u01/rman/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=11 stamp=770160045 filename=/u01/rman/example01.dbf

恢复目录相同:

RMAN> restore database;

Starting restore at 17-DEC-11
using channel ORA_DISK_1

channel ORA_DISK_1: restoring datafile 00001
input datafile copy recid=12 stamp=770160045 filename=/u02/ezhou/system01.dbf
destination for restore of datafile 00001: /u01/rman/system01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00001
output filename=/u01/rman/system01.dbf recid=17 stamp=770160303
channel ORA_DISK_1: restoring datafile 00002
input datafile copy recid=13 stamp=770160045 filename=/u02/ezhou/undotbs01.dbf
destination for restore of datafile 00002: /u01/rman/undotbs01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00002
output filename=/u01/rman/undotbs01.dbf recid=18 stamp=770160314
channel ORA_DISK_1: restoring datafile 00003
input datafile copy recid=14 stamp=770160045 filename=/u02/ezhou/sysaux01.dbf
destination for restore of datafile 00003: /u01/rman/sysaux01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00003
output filename=/u01/rman/sysaux01.dbf recid=19 stamp=770160352
channel ORA_DISK_1: restoring datafile 00004
input datafile copy recid=15 stamp=770160045 filename=/u02/ezhou/users01.dbf
destination for restore of datafile 00004: /u01/rman/users01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00004
output filename=/u01/rman/users01.dbf recid=20 stamp=770160361
channel ORA_DISK_1: restoring datafile 00005
input datafile copy recid=16 stamp=770160045 filename=/u02/ezhou/example01.dbf
destination for restore of datafile 00005: /u01/rman/example01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00005
output filename=/u01/rman/example01.dbf recid=21 stamp=770160379
Finished restore at 17-DEC-11


RMAN> recover database;

Starting recover at 17-DEC-11
using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 3 is already on disk as file /u02/ezhou/redo02.log
archive log filename=/u02/ezhou/redo02.log thread=1 sequence=3
media recovery complete, elapsed time: 00:00:04
Finished recover at 17-DEC-11

注意到上面的log file 还是在/u02/ezhou/下没有改变到/u02/rman下。

好,下面先到open 在改变:

RMAN> alter database open;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 12/17/2011 21:28:22
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

RMAN> alter database open resetlogs;

database opened

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u02/ezhou/redo03.log
/u02/ezhou/redo02.log
/u02/ezhou/redo01.log

oracle 至少有2组redo log。 所以我们可以将已经完成归档的redo drop掉, 重新创建。

 

SQL> alter database drop logfile group 3;

Database altered.

SQL> alter database add logfile group 3 ('/u01/rman/redo03.log') size 50m;

Database altered.

SQL> alter system switch logfile;

System altered.

SQL> alter database drop logfile group 1;

Database altered.

SQL> alter database add logfile group 1 ('/u01/oradata/redo01.log') size 50m;

Database altered.

SQL> alter system switch logfile;

System altered.

SQL> alter database drop logfile group 2;

Database altered.

SQL> alter database add logfile group 2 ('/u01/oradata/redo02.log') size 50m;

Database altered.

SQL> select group#,member from v$logfile;

    GROUP# MEMBER
---------- ---------------------------------------------------------------------
         3 /u01/rman/redo03.log
         2 /u01/rman/redo02.log
         1 /u01/rman/redo01.log

---------

最后要进行temp 文件的重建。
更多内容,可以参考:http://blog.csdn.net/tianlesoftware/article/details/6240983

这篇关于rman 异机恢复 set newname 的实验的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/432972

相关文章

使用SecondaryNameNode恢复NameNode的数据

1)需求: NameNode进程挂了并且存储的数据也丢失了,如何恢复NameNode 此种方式恢复的数据可能存在小部分数据的丢失。 2)故障模拟 (1)kill -9 NameNode进程 [lytfly@hadoop102 current]$ kill -9 19886 (2)删除NameNode存储的数据(/opt/module/hadoop-3.1.4/data/tmp/dfs/na

电脑桌面文件删除了怎么找回来?别急,快速恢复攻略在此

在日常使用电脑的过程中,我们经常会遇到这样的情况:一不小心,桌面上的某个重要文件被删除了。这时,大多数人可能会感到惊慌失措,不知所措。 其实,不必过于担心,因为有很多方法可以帮助我们找回被删除的桌面文件。下面,就让我们一起来了解一下这些恢复桌面文件的方法吧。 一、使用撤销操作 如果我们刚刚删除了桌面上的文件,并且还没有进行其他操作,那么可以尝试使用撤销操作来恢复文件。在键盘上同时按下“C

poj 3050 dfs + set的妙用

题意: 给一个5x5的矩阵,求由多少个由连续6个元素组成的不一样的字符的个数。 解析: dfs + set去重搞定。 代码: #include <iostream>#include <cstdio>#include <set>#include <cstdlib>#include <algorithm>#include <cstring>#include <cm

rman compress

级别         初始         备完    耗时    low          1804       3572    0:10     High         1812       3176   2:00     MEDIUM  1820       3288    0:13    BASIC      1828   3444    0:56 ---不如MEDIUM,

Collection List Set Map的区别和联系

Collection List Set Map的区别和联系 这些都代表了Java中的集合,这里主要从其元素是否有序,是否可重复来进行区别记忆,以便恰当地使用,当然还存在同步方面的差异,见上一篇相关文章。 有序否 允许元素重复否 Collection 否 是 List 是 是 Set AbstractSet 否

STM32(十一):ADC数模转换器实验

AD单通道: 1.RCC开启GPIO和ADC时钟。配置ADCCLK分频器。 2.配置GPIO,把GPIO配置成模拟输入的模式。 3.配置多路开关,把左面通道接入到右面规则组列表里。 4.配置ADC转换器, 包括AD转换器和AD数据寄存器。单次转换,连续转换;扫描、非扫描;有几个通道,触发源是什么,数据对齐是左对齐还是右对齐。 5.ADC_CMD 开启ADC。 void RCC_AD

论文翻译:ICLR-2024 PROVING TEST SET CONTAMINATION IN BLACK BOX LANGUAGE MODELS

PROVING TEST SET CONTAMINATION IN BLACK BOX LANGUAGE MODELS https://openreview.net/forum?id=KS8mIvetg2 验证测试集污染在黑盒语言模型中 文章目录 验证测试集污染在黑盒语言模型中摘要1 引言 摘要 大型语言模型是在大量互联网数据上训练的,这引发了人们的担忧和猜测,即它们可能已

多路转接之select(fd_set介绍,参数详细介绍),实现非阻塞式网络通信

目录 多路转接之select 引入 介绍 fd_set 函数原型 nfds readfds / writefds / exceptfds readfds  总结  fd_set操作接口  timeout timevalue 结构体 传入值 返回值 代码 注意点 -- 调用函数 select的参数填充  获取新连接 注意点 -- 通信时的调用函数 添加新fd到

如何恢复回收站中已删除/清空的文件

回收站清空后如何恢复已删除的文件?是否可以恢复永久删除的文件?或者最糟糕的是,如果文件直接被删除怎么办?本文将向您展示清空回收站后恢复已删除数据的最佳方法。 回收站清空后如何恢复已删除的文件? “回收站清空后我还能恢复已删除的文件吗?” 答案是肯定的,但是在这种情况下您将需要一个  回收站恢复工具 来从回收站中检索文件: 错误/永久删除回收站或任何数字存储设备中的文件 直接删除的文件/

HNU-2023电路与电子学-实验3

写在前面: 一、实验目的 1.了解简易模型机的内部结构和工作原理。 2.分析模型机的功能,设计 8 重 3-1 多路复用器。 3.分析模型机的功能,设计 8 重 2-1 多路复用器。 4.分析模型机的工作原理,设计模型机控制信号产生逻辑。 二、实验内容 1.用 VERILOG 语言设计模型机的 8 重 3-1 多路复用器; 2.用 VERILOG 语言设计模型机的 8 重 2-1 多