oracle 将 RMAN 备份还原到另一个实例:控制文件中的数据库名称不是实例名称
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20428748/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Restoring RMAN backup to another instance: database name in control file is not instance name
提问by Corey
I've been tasked with developing an Oracle 11g backup/restore strategy for some remote instances. My goal is to have one script that will backup the instance, which I will be able to use with an existing instance (possibly on the same server) or create an entirely new instance with.
我的任务是为某些远程实例开发 Oracle 11g 备份/恢复策略。我的目标是有一个脚本来备份实例,我将能够将其与现有实例(可能在同一台服务器上)一起使用或创建一个全新的实例。
Let's say I have two instances, a source
and destination
.
假设我有两个实例, asource
和destination
。
The source
instance configuration, as a result of RMAN> show all
:
的source
实例配置,作为结果RMAN> show all
:
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name SOURCE are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
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 COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
I've written a backup script, seen below:
我写了一个备份脚本,如下所示:
#!/bin/bash
export ORACLE_SID=SOURCE
rman target / <<EOF
CONFIGURE CONTROLFILE AUTOBACKUP ON;
SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/backup/%F';
SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT_TAPE to '/backup/%F';
DELETE NOPROMPT BACKUP;
BACKUP CURRENT CONTROLFILE;
BACKUP AS BACKUPSET CHECK LOGICAL DATABASE PLUS ARCHIVELOG DELETE INPUT;
QUIT;
EOF
In /backup
there appears some files such as backup_4noqqute_151_1
, backup_4noqqute_152_1
, and so on, as well as c-454077755-20131206-07
-- I believe that the former files are the database/archive log backups, the latter the controlfile.
在/backup
那里出现了一些文件,例如backup_4noqqute_151_1
,backup_4noqqute_152_1
等等,还有c-454077755-20131206-07
——我相信前者是数据库/归档日志备份,后者是控制文件。
I run the following commands in attempt to restore the backup to another instance, DESTINATION
:
我运行以下命令以尝试将备份恢复到另一个实例DESTINATION
:
export ORACLE_SID=DESTINATION
rman target /
RMAN> SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/backup/%F';
RMAN> RESTORE CONTROLFILE FROM '/backup/c-454077755-20131206-07';
RMAN> ALTER DATABASE MOUNT;
And receive this error message:
并收到此错误消息:
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 12/06/2013 10:44:51
ORA-01103: database name 'SOURCE' in control file is not 'DESTINATION'
How do I solve this problem? I can't rename DESTINATION
as SOURCE
is on the same server and is still running. I saw a similar problem in this post, but it is incompletely explained and I don't understand it. I'm hoping that since I've provided a lot of information, someone is able to adequately explain to me how to fix this problem.
我该如何解决这个问题?我不能重命名DESTINATION
为SOURCE
是在同一台服务器上,并仍在运行。我在这篇文章中看到了类似的问题,但它解释不完整,我不明白。我希望因为我提供了很多信息,所以有人能够向我充分解释如何解决这个问题。
Thanks.
谢谢。
回答by kubanczyk
RESTORE is not the most convenient command to fulfill you requirements (in this case you would need to temporarily set db_name= parameter on a new instance to be identical to the existing database, then restore all files to different names and then to perform a procedure to change database name and id - quite a difficult task).
RESTORE 不是满足您要求的最方便的命令(在这种情况下,您需要临时将新实例上的 db_name= 参数设置为与现有数据库相同,然后将所有文件恢复为不同的名称,然后执行一个过程以更改数据库名称和 ID - 一项艰巨的任务)。
On 11g, the proper command intended to use in this situation is DUPLICATE DATABASE. The source that DUPLICATE use is either from backup (exactly as RESTORE does) or FROM ACTIVE DATABASE.
在 11g 上,在这种情况下使用的正确命令是 DUPLICATE DATABASE。DUPLICATE 使用的源来自备份(与 RESTORE 完全一样)或来自 ACTIVE DATABASE。
回答by user4157275
set init.ora
db_name=source
db_unique_name=destination
and restore
并恢复