——————————————–
实验环境:windows + oracle 10.1.0.2.0
原数据库:ning[归档模式] 复制数据库:test
author:ningoo 2005-3-27
——————————————-
在同一台server上使用rman的duplicate database创建复制数据库。
1. 创建新的instance
准备好相应的目录结构
e:\oracle\product\10.1.0\admin\test\bdump
e:\oracle\product\10.1.0\admin\test\cdump
e:\oracle\product\10.1.0\admin\test\create
e:\oracle\product\10.1.0\admin\test\pfile
e:\oracle\product\10.1.0\admin\test cripts
e:\oracle\product\10.1.0\admin\test\udmp
创建参数文件inittest.ini(可使用原库的pfile进行修改),主要参数如下:
db_name=test
background_dump_dest=e:\oracle\product\10.1.0\admin\test\bdump
core_dump_dest=e:\oracle\product\10.1.0\admin\test\cdump
user_dump_dest=e:\oracle\product\10.1.0\admin\test\udump
control_files=e:\oracle\oradata\test\control01.ctl,e:\oracle\oradata\test \control02.ctl,e:\oracle\oradata\test \control03.ctl
db_file_name_convert=(e:\oracle\oradata\ning,e:\oracle\oradata\test)
log_file_name_convert=(e:\oracle\oradata\ning,e:\oracle\oradata\test)
置于e:\oracle\product\10.1.0\admin\test\pfile或者e:\oracle\product\10.1.0\db_1\database即可。
使用oradim创建新的instance
c:\>oradim -new -sid test
例程已创建。
使用orapwd创建password文件
c:\>orapwd file=e:\oracle\product\10.1.0\db_1\database\pwdtest.ora password=test entries=10
配置好监听和tnsnames,然后使用sqlplus测试连接
c:\>sqlplus /nolog
sql*plus: release 10.1.0.2.0 – production on 星期日 3月 27 21:01:13 2005
copyright (c) 1982, 2004, oracle. all rights reserved.
sql> conn sys@test as sysdba
请输入口令:
已连接到空闲例程。
2.使用rman备份原库
rman> connect target sys/ning@ning
连接到目标数据库: ning (dbid=1141544503)
正在使用目标数据库控制文件替代恢复目录
rman> backup full database tag fullbk format e:\oracle\oraback\full%u_%s_%p;
启动 backup 于 27-3月 -05
使用通道 ora_disk_1
通道 ora_disk_1: 启动全部数据文件备份集
通道 ora_disk_1: 正在指定备份集中的数据文件
输入数据文件 fno=00001 name=e:\oracle\oradata\ning ystem01.dbf
输入数据文件 fno=00002 name=e:\oracle\oradata\ning\undotbs01.dbf
输入数据文件 fno=00004 name=e:\oracle\oradata\ning\users01.dbf
输入数据文件 fno=00003 name=e:\oracle\oradata\ning ysaux01.dbf
输入数据文件 fno=00005 name=e:\oracle\oradata\ning\test01.dbf
通道 ora_disk_1: 正在启动段 1 于 27-3月 -05
通道 ora_disk_1: 已完成段 1 于 27-3月 -05
段 handle=e:\oracle\oraback\full03ggcqa4_3_1 comment=none
通道 ora_disk_1: 备份集已完成, 经过时间:00:00:45
通道 ora_disk_1: 启动全部数据文件备份集
通道 ora_disk_1: 正在指定备份集中的数据文件
备份集中包括当前控制文件
在备份集中包含当前的 spfile
通道 ora_disk_1: 正在启动段 1 于 27-3月 -05
通道 ora_disk_1: 已完成段 1 于 27-3月 -05
段 handle=e:\oracle\oraback\full04ggcqbh_4_1 comment=none
通道 ora_disk_1: 备份集已完成, 经过时间:00:00:09
完成 backup 于 27-3月 -05
3.使用rman复制数据库
c:\>rman target sys/ning@ning auxiliary sys/test@test
恢复管理器: 版本10.1.0.2.0 – production
opyright (c) 1995, 2004, oracle. all rights reserved.
连接到目标数据库: ning (dbid=1141544503)
已连接到备用数据库: test (未装载)
rman> duplicate target database to test;
启动 duplicate db 于 27-3月 -05
使用通道 ora_aux_disk_1
内存脚本的内容:
{
set until scn 169960;
set newname for datafile 1 to
"e:\oracle\oradata\test ystem01.dbf";
set newname for datafile 2 to
"e:\oracle\oradata\test\undotbs01.dbf";
set newname for datafile 3 to
"e:\oracle\oradata\test ysaux01.dbf";
set newname for datafile 4 to
"e:\oracle\oradata\test\users01.dbf";
set newname for datafile 5 to
"e:\oracle\oradata\test\test01.dbf";
restore
check readonly
clone database
;
}
正在执行内存脚本
正在执行命令: set until clause
正在执行命令: set newname
正在执行命令: set newname
正在执行命令: set newname
正在执行命令: set newname
正在执行命令: set newname
启动 restore 于 27-3月 -05
使用通道 ora_aux_disk_1
通道 ora_aux_disk_1: 正在开始恢复数据文件备份集
通道 ora_aux_disk_1: 正在指定从备份集恢复的数据文件
正将数据文件00001恢复到e:\oracle\oradata\test ystem01.dbf
正将数据文件00002恢复到e:\oracle\oradata\test\undotbs01.dbf
正将数据文件00003恢复到e:\oracle\oradata\test ysaux01.dbf
正将数据文件00004恢复到e:\oracle\oradata\test\users01.dbf
正将数据文件00005恢复到e:\oracle\oradata\test\test01.dbf
通道 ora_aux_disk_1: 已恢复备份段 1
段句柄 = e:\oracle\oraback\full03ggcqa4_3_1 标记 = fullbk
通道 ora_aux_disk_1: 恢复完成
完成 restore 于 27-3月 -05
sql 语句: create controlfile reuse set database "test" resetlogs archivelog
maxlogfiles 16
maxlogmembers 3
maxdatafiles 100
maxinstances 8
maxloghistory 454
logfile
group 1 e:\oracle\oradata\test\redo01.log size 10 m ,
group 2 e:\oracle\oradata\test\redo02.log size 10 m ,
group 3 e:\oracle\oradata\test\redo03.log size 10 m
datafile
e:\oracle\oradata\test ystem01.dbf
character set zhs16gbk
内存脚本的内容:
{
switch clone datafile all;
}
正在执行内存脚本
数据文件 2 已转换成数据文件副本
输入数据文件副本 recid=1 stamp=554071105 文件名=e:\oracle\oradata\test\undotbs01
.dbf
数据文件 3 已转换成数据文件副本
输入数据文件副本 recid=2 stamp=554071105 文件名=e:\oracle\oradata\test ysaux01.
dbf
数据文件 4 已转换成数据文件副本
输入数据文件副本 recid=3 stamp=554071105 文件名=e:\oracle\oradata\test\users01.d
bf
数据文件 5 已转换成数据文件副本
输入数据文件副本 recid=4 stamp=554071105 文件名=e:\oracle\oradata\test\test01.db
f
内存脚本的内容:
{
set until scn 169960;
recover
clone database
delete archivelog
;
}
正在执行内存脚本
正在执行命令: set until clause
启动 recover 于 27-3月 -05
使用通道 ora_aux_disk_1
正在开始介质的恢复
存档日志线程 1 序列 16 已作为文件 e:\oracle\arch\arc00016_0553949015.001 存在于
磁盘上
存档日志文件名 =e:\oracle\arch\arc00016_0553949015.001 线程 =1 序列 =16
完成介质的恢复
完成 recover 于 27-3月 -05
内存脚本的内容:
{
shutdown clone;
startup clone nomount ;
}
正在执行内存脚本
数据库已卸载
oracle 例程已关闭
已连接到备用数据库 (未启动)
oracle 例程已启动
系统全局区域总计 142606336 字节
fixed size 787848 字节
variable size 116390520 字节
database buffers 25165824 字节
redo buffers 262144 字节
sql 语句: create controlfile reuse set database "test" resetlogs archivelog
maxlogfiles 16
maxlogmembers 3
maxdatafiles 100
maxinstances 8
maxloghistory 454
logfile
group 1 e:\oracle\oradata\test\redo01.log size 10 m ,
group 2 e:\oracle\oradata\test\redo02.log size 10 m ,
group 3 e:\oracle\oradata\test\redo03.log size 10 m
datafile
e:\oracle\oradata\test ystem01.dbf
character set zhs16gbk
内存脚本的内容:
{
catalog clone datafilecopy "e:\oracle\oradata\test\undotbs01.dbf";
catalog clone datafilecopy "e:\oracle\oradata\test ysaux01.dbf";
catalog clone datafilecopy "e:\oracle\oradata\test\users01.dbf";
catalog clone datafilecopy "e:\oracle\oradata\test\test01.dbf";
switch clone datafile all;
}
正在执行内存脚本
已将数据文件副本列入目录
数据文件副本 filename=e:\oracle\oradata\test\undotbs01.dbf recid=1 stamp=5540716
73
已将数据文件副本列入目录
数据文件副本 filename=e:\oracle\oradata\test ysaux01.dbf recid=2 stamp=55407167
3
已将数据文件副本列入目录
数据文件副本 filename=e:\oracle\oradata\test\users01.dbf recid=3 stamp=554071673
已将数据文件副本列入目录
数据文件副本 filename=e:\oracle\oradata\test\test01.dbf recid=4 stamp=554071673
数据文件 2 已转换成数据文件副本
输入数据文件副本 recid=1 stamp=554071673 文件名=e:\oracle\oradata\test\undotbs01
.dbf
数据文件 3 已转换成数据文件副本
输入数据文件副本 recid=2 stamp=554071673 文件名=e:\oracle\oradata\test ysaux01.
dbf
数据文件 4 已转换成数据文件副本
输入数据文件副本 recid=3 stamp=554071673 文件名=e:\oracle\oradata\test\users01.d
bf
数据文件 5 已转换成数据文件副本
输入数据文件副本 recid=4 stamp=554071673 文件名=e:\oracle\oradata\test\test01.db
f
内存脚本的内容:
{
alter clone database open resetlogs;
}
正在执行内存脚本
数据库已打开
完成 duplicate db 于 27-3月 -05
4.检查复制库的状态
c:\>sqlplus /nolog
sql*plus: release 10.1.0.2.0 – production on 星期日 3月 27 21:05:52 2005
copyright (c) 1982, 2004, oracle. all rights reserved.
sql> conn sys@test as sysdba
请输入口令:
已连接。
sql> select instance_name,status from v$instance;
instance_name status
—————- ————
test open
然后去掉inittest.ora的db_file_name_convert和log_file_name_convert参数,再使用该文件生成spfile
sql> create spfile from pfile=e:\oracle\product\10.1.0\db_1\database\inittest.ora;
文件已创建。
===============================================================
参考文章:
oracle® database backup and recovery advanced users guide 10g release 1 (10.1) part number b10734-01
