本文共 3605 字,大约阅读时间需要 12 分钟。
1.1 创建备份目录
mkdir f:\backupmkdir f:\dump
1.2 检测源数据库和目标数据库
set oracle_sid=orcl-- 添加列:col name heading '实例名' for a10col version heading '数据库版本' for a15col platform_name heading '操作系统平台' for a30col endian_format heading '字节顺序' for a15-- 查询语句:SELECT d.NAME, i.VERSION, d.PLATFORM_NAME, ENDIAN_FORMATFROM V$TRANSPORTABLE_PLATFORM tp, V$DATABASE d, V$INSTANCE iWHERE tp.PLATFORM_NAME = d.PLATFORM_NAMEAND d.DB_UNIQUE_NAME = i.INSTANCE_NAME;
2.1 创建表空间:
create tablespace ocpdatafile 'F:\app\Administrator\oradata\orcl\ocp01.dbf'size 100mautoextend on next 10m maxsize unlimitedextent management local autoallocatesegment space management auto;
2.2 创建用户:
create user test identified by passworddefault tablespace ocptemporary tablespace temp;
2.3 授权用户:
grant dba to test;
2.4 创建测试表并插入数据:
conncreate table t1 ( sid int not null primary key, sname varchar2(10));insert into t1 values(101,'wind');insert into t1 values(102,'snow');insert into t1 values(103,'apple');commit;
2.5 查询表空间信息:
select table_name from dba_tables where tablespace_name='OCP';
conn as sysdbaexec dbms_tts.transport_set_check('OCP', TRUE , TRUE);SELECT * FROM TRANSPORT_SET_VIOLATIONS; conn / as sysdbacreate directory dump as 'f:\dump'; -- 必须创建此目录 f:\dumpdrop directory dump; -- 删除exit;
rman> run { configure retention policy to recovery window of 14 days; configure controlfile autobackup on; configure controlfile autobackup format for device type disk to 'F:\backup\bak_%F'; allocate channel c1 device type disk format 'F:\backup\bak_%u'; allocate channel c2 device type disk format 'F:\backup\bak_%u'; backup database skip inaccessible plus archivelog filesperset 20 delete all input; release channel c1; release channel c2;}allocate channel for maintenance device type disk;crosscheck backupset;delete noprompt obsolete; rman> transport tablespace "OCP"tablespace destination 'f:\dump'auxiliary destination 'f:\dump'datapump directory "dump"dump file "ocp.dmp"import script "impocpscript.sql"export log "expocplog.log";-- 需要关闭SQL*Plus中其他终端回话。
错误信息:
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-03002: recover 命令 (在 03/18/2010 14:18:03 上) 失败ORA-19852: 创建辅助实例 sqcx 的服务时出错 (错误 0)ORA-27302: 错误发生在:ORA-27303: 附加信息: failed to start instance
解决方法:
exec sys.dbms_backup_restore.manageAuxInstance('TSPITR', 1); 错误信息:
RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-03002: transport tablespace 命令 (在 11/11/2011 17:44:47 上) 失败RMAN-04014: 启动失败: ORA-01261: Parameter db_create_file_dest destination stringg cannot be translatedORA-01263: Name given for file destination directory is invalidOSD-04018: ??????????????????????????O/S-Error: (OS 2) ??????????????????????
解决方法:
auxiliary destination参数设置的路径是否有效。如果路径无效,将导致上述错误。db_create_file_dest和control_files参数的位置与auxiliary destination一致。sqlplus / as sysdbacreate directory dump as 'e:\dump' -- 必须创建此目录 e:\dumpexit;
xcopy \\192.168.2.188\f$\dump\*.* e:\dump /E
sqlplus / as sysdba@e:\dump\impocpscript.sql
RMAN时关闭所有SQL*Plus终端回话。转载地址:http://bxpfk.baihongyu.com/