ホームページ >データベース >mysql チュートリアル >RMAN duplicate 异机恢复
开发人员把一张比较重要的表truncate了,于是找到我们,便做了一次异机恢复,恢复出这张表。下面是事后我在vm上做的一次实验,完
前不久,,因为开发人员把一张比较重要的表truncate了,于是找到我们,便做了一次异机恢复,恢复出这张表。
下面是事后我在vm上做的一次实验,完全复制,当然也可以设置时间,scn,恢复到过去某个时间点。
1.语句准备
select 'set newname for datafile '||file_id||' to "/home/Oracle/oradata/s1/'||substr(file_name,25)||'";' from dba_data_files;
select 'set newname for tempfile '||file_id||' to "/home/oracle/oradata/s1/'||substr(file_name,25)||'";' from dba_temp_files;
select 'group '||a.group#||' (''/home/oracle/oradata/s1/'||substr(member,25)||''')size '||bytes||' reuse,'
from v$logfile a,v$log b
where a.GROUP#=b.GROUP#;
2.复制相关文件到s2(备份目录,日志目录,flash_recovery_area可用nfs将s1的目录mount到s2,注意目录权限问题)
复制inits1.ora并添加(路径一样则可省略)
db_file_name_convert=('/home/oracle/oradata/s1','/home/oracle/oradata/s1')
log_file_name_convert=('/home/oracle/oradata/s1','/home/oracle/oradata/s1')
db_unique_name=s2
及相关对于的修改
复制tnsnames.ora,备份文件,归档文件,flash_recovery_area ,与dump相关的admin目录
创建oradata/s1目录
3.启动s2到nomount状态
startup nomount
如果采用nfs挂载应先在s2上执行
SQL>Alter system set events '10298 trace name context forever,level 32'
否则会报
ORA-27054: NFS file system where the file is created or resides is not mounted with correct options
4.执行
rman target 'sys/fishcat@s1' auxiliary /
-----set newname 路径一样可省略
run{
set newname for datafile 7 to "/home/oracle/oradata/s1/test01.dbf";
set newname for datafile 6 to "/home/oracle/oradata/s1/vip01.dbf";
set newname for datafile 5 to "/home/oracle/oradata/s1/example01.dbf";
set newname for datafile 4 to "/home/oracle/oradata/s1/users01.dbf";
set newname for datafile 3 to "/home/oracle/oradata/s1/sysaux01.dbf";
set newname for datafile 2 to "/home/oracle/oradata/s1/undotbs01.dbf";
set newname for datafile 1 to "/home/oracle/oradata/s1/system01.dbf";
set newname for tempfile 1 to "/home/oracle/oradata/s1/temp01.dbf";
duplicate target database to s2 nofilenamecheck logfile
group 3 ('/home/oracle/oradata/s1/redo03.log')size 52428800 reuse,
group 2 ('/home/oracle/oradata/s1/redo02.log')size 52428800 reuse,
group 1 ('/home/oracle/oradata/s1/redo01.log')size 52428800 reuse;
}