博客
关于我
oracle 可传输的表空间:rman
阅读量:794 次
发布时间:2023-02-24

本文共 3605 字,大约阅读时间需要 12 分钟。

实验环境与数据库复制指南

源数据库服务器与目标数据库配置

  • 源数据库服务器:IP地址为192.168.2.188,host名为beijing,数据库全局名和SID均为orcl。
  • 目标数据库:运行在suzhou服务器,IP地址为192.168.2.199,host名为suzhou,数据库全局名和SID为orcl。

辅助数据库配置

  • 辅助数据库:suzhou仅安装了数据库软件,尚未新建数据库。
  • 目标数据库名:bj(数据库名与实例名相同)。
  • TNS名:源数据库使用TNS名bj,目标数据库使用TNS名sz。

安装路径

  • 安装盘符:F盘和E盘。

实验步骤

1. 源数据库服务器配置

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. 源数据库新建测试表空间和用户

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';

3. 检测数据库是否自包含

conn as sysdbaexec dbms_tts.transport_set_check('OCP', TRUE , TRUE);SELECT * FROM TRANSPORT_SET_VIOLATIONS;

4. 创建目录

conn / as sysdbacreate directory dump as 'f:\dump'; -- 必须创建此目录 f:\dumpdrop directory dump; -- 删除exit;

5. 使用RMAN备份源数据库

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;

6. 源数据库准备传输集

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中其他终端回话。

常见错误及解决方法

错误1:使用SID='sqcx'创建自动实例

错误信息

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);

错误2:启动自动实例ORCL

错误信息

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_destcontrol_files参数的位置与auxiliary destination一致。

目标数据库操作

5.1 创建目录

sqlplus / as sysdbacreate directory dump as 'e:\dump' -- 必须创建此目录 e:\dumpexit;

5.2 从源数据库复制数据

xcopy \\192.168.2.188\f$\dump\*.* e:\dump /E

5.3 导入目标数据库

sqlplus / as sysdba@e:\dump\impocpscript.sql

注意事项

  • 确保在使用RMAN时关闭所有SQL*Plus终端回话。
  • 数据文件建议复制到默认位置,以避免未来数据文件存储位置异常。
  • 修改脚本路径时,确保路径正确,避免报错。

转载地址:http://bxpfk.baihongyu.com/

你可能感兴趣的文章
OKR为什么到今天才突然火了?
查看>>
ollama-python-Python快速部署Llama 3等大型语言模型最简单方法
查看>>
ollama本地部署DeepSeek(Window图文说明)
查看>>
On Error GOTO的好处
查看>>
onclick事件的基本操作
查看>>
onCreate()方法中的参数Bundle savedInstanceState 的意义用法
查看>>
OneASP 安全公开课,深圳站, Come Here, Feel Safe!
查看>>
OneBlog Shiro 反序列化漏洞复现
查看>>
one_day_one--mkdir
查看>>
ONI文件生成与读取
查看>>
onlyoffice新版5.1.2版解决中文汉字输入重复等问题
查看>>
oobbs开发手记
查看>>
OPEN CASCADE Curve Continuity
查看>>
Open Graph Protocol(开放内容协议)
查看>>
Open vSwitch实验常用命令
查看>>
Open WebUI 忘了登入密码怎么办?
查看>>
Open-E DSS V7 应用系列之五 构建软件NAS
查看>>
open-vm-tools-dkms : 依赖: open-vm-tools (>= 2:9.4.0-1280544-5ubuntu3) 但是它将不会被安装
查看>>
open3d-Dll缺失,未找到指定模块解决
查看>>
Openbox-桌面图标设置
查看>>