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

相关文章

使用Python实现网络设备配置备份与恢复

《使用Python实现网络设备配置备份与恢复》网络设备配置备份与恢复在网络安全管理中起着至关重要的作用,本文为大家介绍了如何通过Python实现网络设备配置备份与恢复,需要的可以参考下... 目录一、网络设备配置备份与恢复的概念与重要性二、网络设备配置备份与恢复的分类三、python网络设备配置备份与恢复实

Nginx指令add_header和proxy_set_header的区别及说明

《Nginx指令add_header和proxy_set_header的区别及说明》:本文主要介绍Nginx指令add_header和proxy_set_header的区别及说明,具有很好的参考价... 目录Nginx指令add_header和proxy_set_header区别如何理解反向代理?proxy

MySQL使用binlog2sql工具实现在线恢复数据功能

《MySQL使用binlog2sql工具实现在线恢复数据功能》binlog2sql是大众点评开源的一款用于解析MySQLbinlog的工具,根据不同选项,可以得到原始SQL、回滚SQL等,下面我们就来... 目录背景目标步骤准备工作恢复数据结果验证结论背景生产数据库执行 SQL 脚本,一般会经过正规的审批

通过ibd文件恢复MySql数据的操作方法

《通过ibd文件恢复MySql数据的操作方法》文章介绍通过.ibd文件恢复MySQL数据的过程,包括知道表结构和不知道表结构两种情况,对于知道表结构的情况,可以直接将.ibd文件复制到新的数据库目录并... 目录第一种情况:知道表结构第二种情况:不知道表结构总结今天干了一件大事,安装1Panel导致原来服务

MySQL InnoDB引擎ibdata文件损坏/删除后使用frm和ibd文件恢复数据

《MySQLInnoDB引擎ibdata文件损坏/删除后使用frm和ibd文件恢复数据》mysql的ibdata文件被误删、被恶意修改,没有从库和备份数据的情况下的数据恢复,不能保证数据库所有表数据... 参考:mysql Innodb表空间卸载、迁移、装载的使用方法注意!此方法只适用于innodb_fi

mysql通过frm和ibd文件恢复表_mysql5.7根据.frm和.ibd文件恢复表结构和数据

《mysql通过frm和ibd文件恢复表_mysql5.7根据.frm和.ibd文件恢复表结构和数据》文章主要介绍了如何从.frm和.ibd文件恢复MySQLInnoDB表结构和数据,需要的朋友可以参... 目录一、恢复表结构二、恢复表数据补充方法一、恢复表结构(从 .frm 文件)方法 1:使用 mysq

mysql8.0无备份通过idb文件恢复数据的方法、idb文件修复和tablespace id不一致处理

《mysql8.0无备份通过idb文件恢复数据的方法、idb文件修复和tablespaceid不一致处理》文章描述了公司服务器断电后数据库故障的过程,作者通过查看错误日志、重新初始化数据目录、恢复备... 周末突然接到一位一年多没联系的妹妹打来电话,“刘哥,快来救救我”,我脑海瞬间冒出妙瓦底,电信火苲马扁.

Git中恢复已删除分支的几种方法

《Git中恢复已删除分支的几种方法》:本文主要介绍在Git中恢复已删除分支的几种方法,包括查找提交记录、恢复分支、推送恢复的分支等步骤,文中通过代码介绍的非常详细,需要的朋友可以参考下... 目录1. 恢复本地删除的分支场景方法2. 恢复远程删除的分支场景方法3. 恢复未推送的本地删除分支场景方法4. 恢复

Python MySQL如何通过Binlog获取变更记录恢复数据

《PythonMySQL如何通过Binlog获取变更记录恢复数据》本文介绍了如何使用Python和pymysqlreplication库通过MySQL的二进制日志(Binlog)获取数据库的变更记录... 目录python mysql通过Binlog获取变更记录恢复数据1.安装pymysqlreplicat

使用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