Hp unix oracle11g 迁移裸设备和文件系统之间的数据文件

裸设备--à 文件系统

1、创建测试用的LV (LV的大小设置为PE的整倍数)
# lvcreate -L 32 -n lvdata00 vg00

2、设置LV的权限 (裸设备使用c块文件类型,设置此文件的权限即可)

# chown oracle:dba /dev/vg00/rlvdata00

3、使用sys登录数据库

oracle@cp-cs02 /oracle $ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.7.0 - Production on Wed Aug 18 17:10:13 2010

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

4、建立表空间,指定大小需小于LV大小

SQL> create  tablespace  TBS_TEST  datafile  '/dev/vg00/rlvdata00' size 20M;

5、查看刚建立的表空间状态

SQL>select file_name,status from dba_data_files where tablespace_name = 'TBS_TEST';

FILE_NAME                 STATUS

------------------------- ---------

/dev/vg00/rlvdata00       AVAILABLE

6、在TBS_TEST表空间中建表

SQL> create table test tablespace TBS_TEST as select * from dba_indexes;

SQL> select count(*) from test;

  COUNT(*)

----------

      4812

7、设置TBS_TEST表空间为离线

SQL> alter tablespace TBS_TEST offline;

SQL> host

8、使用RMANCOPY功能备份裸设备文件为文件系统文件

oracle@cp-cs02 /oracle $ rman target /

Recovery Manager: Release 11.1.0.7.0 - Production on Wed Aug 18 17:22:34 2010

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

connected to target database: TSDB (DBID=3914389360)

RMAN> copy datafile '/dev/vg00/rlvdata00' to '/oracle/tmp/test01.dbf';

Starting backup at 18-AUG-10

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=1547 device type=DISK

channel ORA_DISK_1: starting datafile copy

input datafile file number=00078 name=/dev/vg00/rlvdata00

output file name=/oracle/tmp/test01.dbf tag=TAG20100818T172515 RECID=4 STAMP=727377940

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25

Finished backup at 18-AUG-10

RMAN>exit

9、使用rename重新指定数据文件存储位置

oracle@cp-cs02 /oracle $ exit

SQL> alter database rename file '/dev/vg00/rlvdata00' to '/oracle/tmp/test01.dbf';

10、查看表空间状态,并设置为在线

SQL> select tablespace_name,status from dba_tablespaces where tablespace_name = 'TBS_TEST';

TABLESPACE_NAME                STATUS

------------------------------ ---------

TBS_TEST                       OFFLINE

SQL> alter tablespace TBS_TEST online;

11TBS_TEST表空间数据文件已转换成文件系统文件

SQL> select file_name,status from dba_data_files where tablespace_name = 'TBS_TEST';

FILE_NAME                      STATUS

----------------------        -----------------

/oracle/tmp/test01.dbf        AVAILABLE

SQL> select count(*) from test;

  COUNT(*)

---------

      4812

12、在表中插入数据,测试转换后的数据文件正常

SQL> insert into test select * from test;

SQL> commit;

SQL> select count(*) from test;

  COUNT(*)

----------

      9624

 

文件系统--à裸设备

13、设置TBS_TEST表空间为离线

SQL> alter tablespace TBS_TEST offline;

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

oracle@cp-cs02 /oracle $ rman target /

Recovery Manager: Release 11.1.0.7.0 - Production on Wed Aug 18 17:50:09 2010

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

connected to target database: TSDB (DBID=3914389360)

RMAN> copy datafile '/oracle/tmp/test01.dbf' to '/dev/vg00/rlvdata00';

Starting backup at 18-AUG-10

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=1542 device type=DISK

channel ORA_DISK_1: starting datafile copy

input datafile file number=00078 name=/oracle/tmp/test01.dbf

output file name=/dev/vg00/rlvdata00 tag=TAG20100818T175104 RECID=5 STAMP=727379466

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03

Finished backup at 18-AUG-10

RMAN> exit

14、使用rename重新指定数据文件存储位置

oracle@cp-cs02 /oracle $ sqlplus / as sysdba

SQL> alter database rename file '/oracle/tmp/test01.dbf' to '/dev/vg00/rlvdata00';

15、设置表空间在线

SQL> alter tablespace TBS_TEST online;

SQL> select file_name,status from dba_data_files where tablespace_name = 'TBS_TEST'

FILE_NAME                 STATUS

------------------------- ---------

/dev/vg00/rlvdata00       AVAILABLE

16、在表中插入数据,测试转换后的数据文件正常

SQL> insert into test select * from test;

SQL> commit;

SQL> select count(*) from test;

  COUNT(*)

---------

     19248

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24376892/viewspace-671416/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/24376892/viewspace-671416/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值