eygle.com   eygle.com
eygle.com  
 

« Oracle HowTo:如何Shrink Undo表空间,释放过度占用的空间 | Blog首页 | 我的DBA飞走了 »

Oracle HowTo:如何通过RMAN进行裸设备和文件系统之间的数据文件迁移

作者:eygle |【转载时请以超链接形式标明文章和作者信息及本声明
链接:
因为一个朋友问起,做个范例简单介绍如何使用Rman进行数据文件的裸设备和文件系统转换。

1.使用裸设备建立EYGLE测试表空间
[oracle@danaly ~]$ sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Nov 30 14:41:53 2005

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options

SQL> create tablespace eygle
  2  datafile '/dev/cciss/c0d0p11' size 10M;

Tablespace created.

SQL> create table eygle tablespace eygle as select * from dba_objects;

Table created.


SQL> select count(*) from eygle;

  COUNT(*)
----------
     50420

SQL> alter tablespace eygle offline;

Tablespace altered.

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options

2.使用RMAN的COPY功能备份裸设备文件为文件系统文件
[oracle@danaly ~]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Nov 30 16:00:42 2005

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: DANALY (DBID=3965153484)

RMAN> copy datafile '/dev/cciss/c0d0p11' to '/opt/oracle/eygle01.dbf'; 

Starting backup at 30-NOV-05
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=137 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=/dev/cciss/c0d0p11
output filename=/opt/oracle/eygle01.dbf tag=TAG20051130T160137 recid=2 stamp=575740898
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:02
Finished backup at 30-NOV-05

RMAN> exit


Recovery Manager complete.

3.通过rename修改文件位置
[oracle@danaly ~]$ sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Nov 30 16:01:54 2005

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options

SQL> alter database rename file '/dev/cciss/c0d0p11' to '/opt/oracle/eygle01.dbf'; 

Database altered.

SQL> alter tablespace eygle online;

Tablespace altered.

SQL> select file_name from dba_data_files where tablespace_name='EYGLE';

FILE_NAME
--------------------------------------------------------------------------------
/opt/oracle/eygle01.dbf

4.进行数据修改
SQL> insert into eygle as select * from eygle;
insert into eygle as select * from eygle
                  *
ERROR at line 1:
ORA-00926: missing VALUES keyword


SQL> insert into eygle select * from eygle;
insert into eygle select * from eygle
            *
ERROR at line 1:
ORA-01653: unable to extend table SYS.EYGLE by 128 in tablespace EYGLE

SQL> alter database datafile '/opt/oracle/eygle01.dbf' resize 20m;

Database altered.

SQL> insert into eygle select * from eygle;

50420 rows created.

SQL> commit;

Commit complete.

SQL> alter tablespace eygle offline;

Tablespace altered.

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options

5.从文件系统迁移文件至裸设备
[oracle@danaly ~]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Nov 30 16:08:51 2005

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: DANALY (DBID=3965153484)

RMAN> copy datafile '/opt/oracle/eygle01.dbf' to '/dev/cciss/c0d0p11';

Starting backup at 30-NOV-05
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=135 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=/opt/oracle/eygle01.dbf
output filename=/dev/cciss/c0d0p11 tag=TAG20051130T160935 recid=3 stamp=575741376
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 30-NOV-05

RMAN> exit


Recovery Manager complete.
[oracle@danaly ~]$ sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Nov 30 16:09:48 2005

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options

SQL> alter database rename file '/opt/oracle/eygle01.dbf' to '/dev/cciss/c0d0p11';

Database altered.

SQL> alter tablespace eygle online;

Tablespace altered.

SQL> select count(*) from eygle; 

  COUNT(*)
----------
    100840

SQL> 

rman使得对于裸设备的操作大大简化。
-----
这篇 【Oracle HowTo:如何通过RMAN进行裸设备和文件系统之间的数据文件迁移】来自 www.eygle.com | CSDN技术网摘| del.icio.us|365Key

By eygle on 2005-12-01 07:01 | Comments (2) | Posted to HowTo | Edit |Pageviews:

相关文章 随机文章
  • 使用Catalog命令注册RMAN备份集
  • 使用dbms_backup_restore修改DBID
  • RMAN的"rman: can't open target"错误
  • 使用RMAN进行快速Dataguard数据库创建
  • 用Rman的Plus archvielog选项简化数据库备份
  • Oracle支撑起世界最大人口身份信息数据库
    又是一年圣诞时
    如何判断Solaris上是否支持异步IO
    Oracle中临时表产生过量Redo的说明
    Oracle10g中过程(PROCEDURE )重建的增强
    搜索本站:

    留言 (2)

    真是太酷了,以前没用过RAW DEVICE,RMAN功能真神奇

    Posted by: yanggq at February 17, 2006 1:24 PM

    看过eygle的不少文章,比较注重操作步骤,缺少综合性的方法概述

    Posted by: topsec at July 17, 2008 8:54 AM

    发表留言:



    Remember Me?
    (输入验证码后方可评论,谢谢支持)



    CopyRight © 2004 eygle.com, All rights reserved.