10g数据库做rman duplicate的复制功能,刚接触的时候看得一头雾水,由于之前接触过本地备份,异地还原的事。所以感觉这个功能很多余。
深入的看了下体系结构,发现其实就是个自动化执行的命令,我们事先把基本的复制环境搭建好,一执行命令就可以了,也还是那些步骤,创建控制文件,restore数据库,recover数据库,关闭打开然后open resetlogs。这些都是可以手动执行的,只不过通过duplicate命令简化了,自动化也有自动化的坏处就是得按照它的方式把环境设置好,例如:为什么还要把备份cp到辅助端呢?貌似11g可以实现在线复制了,但也是很笨拙的。等把数据库升级鸟,在玩11g的duplicate吧!
目标数据库:test1 辅助数据库:test1
由于做的是远程复制所以必须是实例名一致的,貌似可以做成不一致的,但我试验过了,没成功。貌似在创建控制文件的时候有问题。
1 在辅助数据库创建目标数据库的参数文件。
cp过来target中的参数文件即可放在$ORACLE_HOME/dbs/ 下起名inittest1.ora
2 创建auxiliary的test1的密码文件
orapwd file=$ORACLE_HOME/dbs/orapwtest1 passwork=**** force=y
注意这行一定执行,否则从target连接auxiliary数据库的时候回报权限不足。需要密码认证的。
3 在target端执行备份
BACKUP DEVICE TYPE DISK FORMAT '/opt/oracle/backup/%U' DATABASE PLUS ARCHIVELOG;
BACKUP DEVICE TYPE DISK FORMAT '/opt/oracle/backup/%U' CURRENT CONTROLFILE;
scp 刚才备份的所有备份文件到辅助端相同的目录下。
4 配置网络服务
auxiliary端:
vim listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
# (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = test1)
(ORACLE_HOME =/u01/app/oracle/product/11g/db_1)
(SID_NAME = test1)
)
)
--此步骤很重要位的就是实现辅助端的静态注册,否则监听的状态会是BLOCKED,由于后面要启动到NOMOUNT阶段。
target端:配置个ls_test1的监听以监听辅助数据库
5 target端执行:
[oracle@test1 ~]$ rman target / auxiliary sys/****@ls_test1
Recovery Manager: Release 10.2.0.1.0 - Production on Thu Sep 20 14:24:58 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: TEST1 (DBID=1171356332)
connected to auxiliary database (not started)
RMAN> duplicate target database to test1 nofilenamecheck;
Starting Duplicate Db at 20-SEP-12
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=155 devtype=DISK
contents of Memory Script:
{
set until scn 637384;
set newname for datafile 1 to
"/opt/oracle/oradata/test1/system01.dbf";
set newname for datafile 2 to
"/opt/oracle/oradata/test1/undotbs01.dbf";
set newname for datafile 3 to
"/opt/oracle/oradata/test1/sysaux01.dbf";
set newname for datafile 4 to
"/opt/oracle/oradata/test1/users01.dbf";
restore
check readonly
clone database
;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 20-SEP-12
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /opt/oracle/oradata/test1/system01.dbf
.....
--一是制定nofilenamecheck恢复到与target的文件目录一直的路径上。
alter database open resetlogs;