关于RMAN 复制的理论知识,参考我的Blog:
RMAN 复制目标数据库的理论知识
http://www.cndba.cn/Dave/article/1057
RMAN 异机复制和同机复制操作步骤是一样的,不同的是我们需要把备份的文件copy到辅助库上去,而且位置要和目标库上一直,因为备份集的位置是写在控制文件里的。
RMAN 同机复制数据库
http://www.cndba.cn/Dave/article/1056
实验平台: REDHAT linux 4.7 + oracle 10g
目标库信息:
ORACLE_BASE: /u01/app/oracle
ORACLE_HOME: /u01/app/oracle/product/10.2.0/db_1
ORACLE_SID:orcl
IP: 192.168.1.20
辅助库信息:
ORACLE_BASE: /u01/app/oracle
ORACLE_HOME: /u01/app/oracle/product/10.2.0/db_1
ORACLE_SID:orcl
IP: 192.168.1.21
我们以实例名相同的为例,实例名不同也一样,在pfile里修改对应参数就可以了。
步骤如下:
(1)构建辅助数据库目录结构
(2)创建pfile,并复制到辅助数据库,修改相关内容
(3)创建辅助实例口令文件
(4)RMAN 备份源库
(5)添加配置监听
(6)将源库备份文件拷贝到辅助库相同位置
(7)用pfile文件,将辅助数据库启动到nomount 状态
(8)执行RMAN duplicate命令复制数据库
(9)创建spfile文件
(10)在磁带上恢复备份
(11)使用DBNEWID程序生成新的DBID
一.构建辅助数据库目录结构
1.1 Oracle data 目录
[oracle@localhost oracle]$ mkdir oradata
[oracle@localhost oracle]$ ls
oradata oraInventory product
[oracle@localhost oracle]$ cd oradata/
[oracle@localhost oracle]$ mkdir orcl
1.2 其他目录
[oracle@localhost oracle]$ pwd
/u01/app/oracle
[oracle@localhost oracle]$ mkdir admin
[oracle@localhost oracle]$ ls
admin oradata oraInventory product
[oracle@localhost oracle]$ cd admin
[oracle@localhost admin]$ ls
[oracle@localhost admin]$ mkdir orcl
[oracle@localhost admin]$ ls
orcl
[oracle@localhost admin]$ cd orcl
[oracle@localhost orcl]$ mkdir adump
[oracle@localhost orcl]$ mkdir bdump
[oracle@localhost orcl]$ mkdir cdump
[oracle@localhost orcl]$ mkdir dpdump
[oracle@localhost orcl]$ mkdir pfile
[oracle@localhost orcl]$ mkdir udump
[oracle@localhost orcl]$ ls
adump bdump cdump dpdump pfile udump
二. 创建pfile,复制到辅助数据库,并修改相关参数
2.1 在源库上创建pfile 文件
SQL> conn sys/admin@orcl as sysdba;
Connected.
SQL> create pfile from spfile;
File created.
2.2 用scp 命令将pfile 文件传到辅助库。要放在$ORACLE_HOME/dbs目录下,不然ORACLE 不识别。
[oracle@db1 orcl]$ cd /u01/app/oracle/product/10.2.0/db_1/dbs
[oracle@db1 dbs]$ ls
hc_DAVE.dat initdw.ora lkDAVE orapworcl spfileorcl.ora
hc_orcl.dat init.ora lkORCL snapcf_orcl.f
initDAVE.ora initorcl.ora orapwDAVE spfileDAVE.ora
[oracle@db1 dbs]$ scp initorcl.ora 192.168.1.21:/$ORACLE_HOME/dbs
The authenticity of host '192.168.1.21 (192.168.1.21)' can't be established.
RSA key fingerprint is 1a:20:7a:05:bd:e0:ac:04:21:02:b1:72:01:69:40:d6.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.21' (RSA) to the list of known hosts.
oracle@192.168.1.21's password:
initorcl.ora 100% 1108 1.1KB/s 00:00
2.3 在辅助库上确认文件是否传送过来
[oracle@localhost orcl]$ cd $ORACLE_HOME/dbs
[oracle@localhost dbs]$ ls
initdw.ora init.ora initorcl.ora
2.4 在辅助库上修改pfile参数
[oracle@localhost dbs]$ more initorcl.ora
orcl.__db_cache_size=167772160
orcl.__java_pool_size=4194304
orcl.__large_pool_size=4194304
orcl.__shared_pool_size=62914560
orcl.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.background_dump_dest='/u01/app/oracle/admin/orcl/bdump'
*.compatible='10.2.0.1.0'
*.control_file_record_keep_time=14
*.control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/or
adata/orcl/control02.ctl','/u01/app/oracle/oradata/orcl/control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/orcl/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='orcl'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='location=/u01/archivelog'
*.open_cursors=300
*.pga_aggregate_target=81788928
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=246415360
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/orcl/udump'
说明,在这里我没有做修改,因为我异机复制实例名相同,存储位置也相同。 如果说你复制的不同的话,就需要修改相关的实例名。 如果存储位置不同的话,还需要添加以下参数,对数据文件位置进行转换。
db_file_name_convert = ('/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/DAVE')
三.创建辅助实例ORCL 的口令文件
[oracle@localhost dbs]$ cd $ORACLE_HOME/bin
[oracle@localhost bin]$ orapwd file=$ORACLE_HOME/dbs/orapworcl password=admin
[oracle@localhost bin]$ cd $ORACLE_HOME/dbs
[oracle@localhost dbs]$ ls
initdw.ora init.ora initorcl.ora orapworcl
windows下oracle默认的位置是$ORACLE_HOME/database目录,文件名格式是pwdSID.ora。
linux下oracle默认的位置是$ORACLE_HOME/dbs目录,文件名格式是orapwSID。
创建完后,数据库需要重启动,新的口令文件才能生效。
关于口令文件创建,详细内容参考blog:
Oracle OS认证 口令文件 密码丢失处理
http://www.cndba.cn/Dave/article/1251
四.RMAN 备份源库(orcl)
[oracle@db1 backup]$ rman target sys/admin@orcl
Recovery Manager: Release 10.2.0.1.0 - Production on Sun Jul 18 18:26:16 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1248423599)
RMAN>RUN {
allocate channel c1 type disk;
allocate channel c2 type disk;
BACKUP FORMAT '/u02/backup/orcl_%U_%T' skip inaccessible filesperset 5 DATABASE TAG orcl_hot_db_bk;
sql 'alter system archive log current';
BACKUP FORMAT '/u02/backup/arch_%U_%T' skip inaccessible filesperset 5 ARCHIVELOG ALL DELETE INPUT;
backup current controlfile tag='bak_ctlfile' format='/u02/backup/ctl_file_%U_%T';
backup spfile tag='spfile' format='/u02/backup/ORCL_spfile_%U_%T';
release channel c2;
release channel c1;
}
备份脚本,具体参考:
Linux 平台下 RMAN 全备 和 增量备份 shell 脚本
http://www.cndba.cn/Dave/article/1060
五.添加,配置监听
5.1 在辅助库的Listener.ora 文件中,添加如下内容
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(SID_NAME = orcl)
)
)
5.2 修改辅助库的tnsnames.ora 文件,添加如下内容
TARGETORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.20)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
5.3 修改源库的tnsnames.ora 文件,添加如下内容:
AUXORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.21)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
建议使用net manager 工具从界面来修改,这样不容易出错
Oracle 数据库监听配置
http://www.cndba.cn/dave/article/1232
Oracle Listener 动态注册 与 静态注册
http://www.cndba.cn/Dave/article/1177
六. 将源库的备份拷贝到辅助数据库的相同位置
这里有两种方法,一种直接在辅助库上建相同的目录结构,在用SCP 命令把这些备份文件copy过去,但是这样会占用大量的网络资源。 还有一种就是建好目录结构后用NFS直接Mount上去。 在这里我们用后面一种方法试一下。
6.1 在辅助库上建相同的备份目录结构
因为我们在源库上备份是备份到/u02/backup目录中的,所以我们在辅助库上也建这个目录
[root@localhost /]# mkdir -p /u02/backup
[root@localhost /]# chown oracle /u02
[root@localhost /]# chmod 777 /u02
6.2 将源库的备份挂载到辅助库上
6.2.1 在源库上将/u02/backup 目录添加到共享
[root@db1 ~]# more /etc/exports
/u02/backup 192.168.1.21(rw,async,anonuid=65534,anongid=65534)
[root@db1 ~]# service nfs start
6.2.2 在辅助库上挂载源库的目录,注意,mount命令必须以root用户执行
[root@localhost /]# mount -t nfs -o rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,vers=3,timeo=600,actimeo=0
10.85.10.1:/u02/backup /u02/backup
-- 注意: 在挂载NFS的时候,一定要加上-t -o 参数,不然在RMAN 复制的时候会报错:
--ORA-27054: NFS file system where the file is created or resides is not mounted with correct options
[root@localhost /]# cd /u02/backup/
[root@localhost backup]# ls
arch_3klj4676_1_1_20100718 orcl_3hlj45vf_1_1_20100718
arch_3llj4676_1_1_20100718 orcl_3ilj465c_1_1_20100718
ctl_file_3mlj467h_1_1_20100718 orcl_3jlj4661_1_1_20100718
orcl_3glj45vf_1_1_20100718 ORCL_spfile_3nlj467k_1_1_20100718
七. 启动辅助库至nomount 状态,注意使用pfile参数启动
[oracle@localhost dbs]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Jul 20 03:53:53 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup nomount pfile=?/dbs/initorcl.ora
ORACLE instance started.
Total System Global Area 247463936 bytes
Fixed Size 1218772 bytes
Variable Size 79693612 bytes
Database Buffers 163577856 bytes
Redo Buffers 2973696 bytes
SQL> exit -- 启动后就退出session,因为在duplicata的时候不能有session连接
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
八. RMAN 连接到目标实例和辅助实例,运行duplicate 命令复制数据库
[oracle@db1 ~]$ rman target sys/admin@orcl auxiliary sys/admin@auxorcl;
Recovery Manager: Release 10.2.0.1.0 - Production on Sun Jul 18 20:41:19 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1248423599)
connected to auxiliary database: ORCL (not mounted)
RMAN> duplicate target database to ORCL nofilenamecheck
2> logfile
3> '/u01/app/oracle/oradata/orcl/redo01.dbf' size 50m,
4> '/u01/app/oracle/oradata/orcl/redo02.dbf' size 50m,
5> '/u01/app/oracle/oradata/orcl/redo03.dbf' size 50m;
注: 这个地方有2个地方需要说明:
(1) Nofilenamecheck 参数:
如果在复制时,位置不同时,我们会用参数db_file_name_convert 对文件位置进行转换。 但是在这个复制示例中我们用的是相同的位置。 所以这里必须加上nofilenamecheck参数。 该参数通知复制操作不必在执行还原操作前确认文件名是不同的。如果没有指定nofilenamecheck参数,rman会给出如下错误:
RMAN-05001: auxiliary filename /u01/app/oracle/oradata/orcl/example01.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u01/app/oracle/oradata/orcl/users01.dbf conflicts with a file used by the target database
(2) logfile 参数:
在完成复制进程并执行最有一条open resetlogs命令时,RMAN 必须为辅助数据库构建全新的日志文件。 如上面命令所示,我们可以在duplicate 命令中指定logfile参数,并指定使用的日志文件的大小,数目和位置。
还可以在pfile里指定log_file_name_convert 参数来进行转换。 这种方法相对而言要简单一点。 但因为我们在RMAN 同机复制数据库的例子中用的就是这种方法,所以就换种方法来测试。
Starting Duplicate Db at 18-JUL-10
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 733545;
set newname for datafile 1 to "/u01/app/oracle/oradata/orcl/system01.dbf";
set newname for datafile 2 to "/u01/app/oracle/oradata/orcl/undotbs01.dbf";
set newname for datafile 3 to "/u01/app/oracle/oradata/orcl/sysaux01.dbf";
set newname for datafile 4 to "/u01/app/oracle/oradata/orcl/users01.dbf";
set newname for datafile 5 to "/u01/app/oracle/oradata/orcl/example01.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
executing command: SET NEWNAME
Starting restore at 18-JUL-10
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backupset restore -- 开始restore 数据文件
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /u01/app/oracle/oradata/orcl/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/orcl/sysaux01.dbf
restoring datafile 00005 to /u01/app/oracle/oradata/orcl/example01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u02/backup/orcl_3plj4ejl_1_1_20100718
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u02/backup/orcl_3plj4ejl_1_1_20100718 tag=ORCL_HOT_DB_BK
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:48
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 /u01/app/oracle/oradata/orcl/system01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u02/backup/orcl_3olj4ejk_1_1_20100718
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u02/backup/orcl_3olj4ejk_1_1_20100718 tag=ORCL_HOT_DB_BK
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:14
Finished restore at 18-JUL-10
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCL" RESETLOGS ARCHIVELOG
-- 创建源库的控制文件,然后根据这个文件进行相关的恢复
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/orcl/redo01.dbf' SIZE 50 M ,
GROUP 2 '/u01/app/oracle/oradata/orcl/redo02.dbf' SIZE 50 M ,
GROUP 3 '/u01/app/oracle/oradata/orcl/redo03.dbf' SIZE 50 M
DATAFILE
'/u01/app/oracle/oradata/orcl/system01.dbf'
CHARACTER SET WE8ISO8859P1
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
released channel: ORA_AUX_DISK_1
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=724831148 filename=/u01/app/oracle/oradata/orcl/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=724831148 filename=/u01/app/oracle/oradata/orcl/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=724831148 filename=/u01/app/oracle/oradata/orcl/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=724831148 filename=/u01/app/oracle/oradata/orcl/example01.dbf
contents of Memory Script:
{
set until scn 733545;
recover
clone database
delete archivelog ;
}
executing Memory Script
executing command: SET until clause
Starting recover at 18-JUL-10
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=155 devtype=DISK
starting media recovery
channel ORA_AUX_DISK_1: starting archive log restore to default destination
channel ORA_AUX_DISK_1: restoring archive log
archive log thread=1 sequence=46
channel ORA_AUX_DISK_1: reading from backup piece /u02/backup/arch_3tlj4er7_1_1_20100718
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u02/backup/arch_3tlj4er7_1_1_20100718 tag=TAG20100718T205809
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting archive log restore to default destination
channel ORA_AUX_DISK_1: restoring archive log
archive log thread=1 sequence=45
channel ORA_AUX_DISK_1: reading from backup piece /u02/backup/arch_3slj4er7_1_1_20100718
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u02/backup/arch_3slj4er7_1_1_20100718 tag=TAG20100718T205809
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
archive log filename=/u01/archivelog/1_45_720642866.dbf thread=1 sequence=45
channel clone_default: deleting archive log(s)
archive log filename=/u01/archivelog/1_45_720642866.dbf recid=2 stamp=724831155
archive log filename=/u01/archivelog/1_46_720642866.dbf thread=1 sequence=46
channel clone_default: deleting archive log(s)
archive log filename=/u01/archivelog/1_46_720642866.dbf recid=1 stamp=724831153
media recovery complete, elapsed time: 00:00:02
Finished recover at 18-JUL-10
contents of Memory Script:
{
shutdown clone;
startup clone nomount ;
-- 如果此时,辅助实例上有session连在上面,将一直等到session退出才能执行,如果等了很长时间还没有执行,不妨检查一下,有没有session连在数据库上。
}
executing Memory Script
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 247463936 bytes
Fixed Size 1218772 bytes
Variable Size 79693612 bytes
Database Buffers 163577856 bytes
Redo Buffers 2973696 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCL" RESETLOGS ARCHIVELOG
-- 创建新的控制文件
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/orcl/redo01.dbf' SIZE 50 M ,
GROUP 2 '/u01/app/oracle/oradata/orcl/redo02.dbf' SIZE 50 M ,
GROUP 3 '/u01/app/oracle/oradata/orcl/redo03.dbf' SIZE 50 M
DATAFILE
'/u01/app/oracle/oradata/orcl/system01.dbf'
CHARACTER SET WE8ISO8859P1
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/orcl/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/orcl/undotbs01.dbf";
catalog clone datafilecopy "/u01/app/oracle/oradata/orcl/sysaux01.dbf";
catalog clone datafilecopy "/u01/app/oracle/oradata/orcl/users01.dbf";
catalog clone datafilecopy "/u01/app/oracle/oradata/orcl/example01.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed temporary file 1 to /u01/app/oracle/oradata/orcl/temp01.dbf in control file
cataloged datafile copy datafile copy filename=/u01/app/oracle/oradata/orcl/undotbs01.dbf recid=1 stamp=724831185
cataloged datafile copy datafile copy filename=/u01/app/oracle/oradata/orcl/sysaux01.dbf recid=2 stamp=724831186
cataloged datafile copy datafile copy filename=/u01/app/oracle/oradata/orcl/users01.dbf recid=3 stamp=724831186
cataloged datafile copy datafile copy filename=/u01/app/oracle/oradata/orcl/example01.dbf recid=4 stamp=724831186
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=724831185 filename=/u01/app/oracle/oradata/orcl/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=724831186 filename=/u01/app/oracle/oradata/orcl/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=724831186 filename=/u01/app/oracle/oradata/orcl/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=724831186 filename=/u01/app/oracle/oradata/orcl/example01.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
executing Memory Script
database opened
Finished Duplicate Db at 18-JUL-10
九. 创建spfile,并验证数据库
通过上面8步的操作,复制操作已经完成。 我们现在创建一个spfile。
SQL> create spfile from pfile='/u01/app/oracle/product/10.2.0/db_1/dbs/initorcl.ora';
File created.
SQL> select name from v$database;
NAME
---------
ORCL
SQL> select tablespace_name,file_name from dba_data_files;
TABLESPACE_NAME FILE_NAME
------------------------------ -------------------------------------------------
SYSTEM /u01/app/oracle/oradata/orcl/system01.dbf
UNDOTBS1 /u01/app/oracle/oradata/orcl/undotbs01.dbf
SYSAUX /u01/app/oracle/oradata/orcl/sysaux01.dbf
USERS /u01/app/oracle/oradata/orcl/users01.dbf
EXAMPLE /u01/app/oracle/oradata/orcl/example01.dbf
十. 在远程服务器上复制磁带备份
如果在远程服务器上复制磁带备份,必须配置辅助通道,以反映介质管理器的需求。 除了指定介质管理器和用于常规通道的类或池外,还必须指定目标客户端名称,如下所示:
RMAN> configure auxiliary channel 1 device type sbt parms="env=(nb_ora_serv=db1,nb_ora_client=db2)";
十一. 使用DBNEWID 适用程序的不完全复制
复制时最令人不满意的一点是不存在"可重启的复制",也就是说,如果在执行还原所有文件的步骤(复制进程中最常出错)时出错。比如在恢复操作期间出错,就必须再次重启复制进程并重新还原文件。我们无法修复复制进程(如使丢失的归档日志可用),只能重新开始整个过程。
将resote optimization 选项设置为on, rman 就不会在还原位置中再次还原具有相同数据文件头SCN信息文件。这也适合用于复制操作。 如果复制操作还原一个文件,然后重新启动该复制操作,RMAN 将不会再次还原该文件。 然后,如果将一个归档日志应用于该文件,则会再次还原该归档日志。
在Oracle 10g中,使用DBNEWID使用程序可以部分修复恢复进程,这个使用程序以安全和可控的方式为复制的数据库指定新的DBID。 我们可以手工恢复复制的数据库,准备所有元素,然后再次运行DBNEWID实用程序完成由复制操作启动的进程。 这就允许我们至少可以手工完成复制操作。
DBNEWID 使用程序的用法很简单。 首先,必须确认在使用实用程序前生成了有效的备份,尽管要执行验证备份的进程,但是在修改DBID期间仍然可能会遇到不可恢复的错误。 确认备份有效后,还必须在一致的状态中关闭数据库,然后将数据库切换回加载状态。
使用示例如下:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 247463936 bytes
Fixed Size 1218772 bytes
Variable Size 79693612 bytes
Database Buffers 163577856 bytes
Redo Buffers 2973696 bytes
Database mounted.
SQL> !
[oracle@localhost u01]$ nid target=/
DBNEWID: Release 10.2.0.1.0 - Production on Tue Jul 20 07:20:37 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to database ORCL (DBID=1252611919)
Connected to server version 10.2.0
Control Files in database:
/u01/app/oracle/oradata/orcl/control01.ctl
/u01/app/oracle/oradata/orcl/control02.ctl
/u01/app/oracle/oradata/orcl/control03.ctl
Change database ID of database ORCL? (Y/[N]) => y
Proceeding with operation
Changing database ID from 1252611919 to 1252672326
Control File /u01/app/oracle/oradata/orcl/control01.ctl - modified
Control File /u01/app/oracle/oradata/orcl/control02.ctl - modified
Control File /u01/app/oracle/oradata/orcl/control03.ctl - modified
Datafile /u01/app/oracle/oradata/orcl/system01.dbf - dbid changed
Datafile /u01/app/oracle/oradata/orcl/undotbs01.dbf - dbid changed
Datafile /u01/app/oracle/oradata/orcl/sysaux01.dbf - dbid changed
Datafile /u01/app/oracle/oradata/orcl/users01.dbf - dbid changed
Datafile /u01/app/oracle/oradata/orcl/example01.dbf - dbid changed
Datafile /u01/app/oracle/oradata/orcl/temp01.dbf - dbid changed
Control File /u01/app/oracle/oradata/orcl/control01.ctl - dbid changed
Control File /u01/app/oracle/oradata/orcl/control02.ctl - dbid changed
Control File /u01/app/oracle/oradata/orcl/control03.ctl - dbid changed
Instance shut down
Database ID for database ORCL changed to 1252672326.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database ID.
DBNEWID - Completed succesfully.
------------------------------------------------------------------------------
QQ: 492913789
Email: ahdba@qq.com
Blog: http://www.cndba.cn/dave
网上资源: http://tianlesoftware.download.csdn.net
相关视频:http://blog.csdn.net/tianlesoftware/archive/2009/11/27/4886500.aspx
DBA1 群:62697716(满); DBA2 群:62697977
DBA3 群:63306533; 聊天 群:40132017