裸设备--à 文件系统
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、使用RMAN的COPY功能备份裸设备文件为文件系统文件
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;
11、TBS_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/