利用RMAN转移裸设备到文件系统
本文只是为了个人备忘。
参考eagyle的:http://www.eygle.com/archives/2005/12/oracle_howto_move_datafile_raw.html
我首先挂了一块硬盘。然后执行:fdisk /dev/sdd
生成了一块逻辑盘/dev/sdd1,得到扩展盘/dev/sdd5。
然后在 /etc/rc.local里设定: chown oracle:dba /dev/sdd5。
我想,采用这种方式,意味着跳过udev。
启动数据库,在裸设备下建立表空间:
****************************************
SQL>create tablespace gao datafile ‘/dev/sdd5’ size 10M;
SQL>Create table gaotab tablespace gao as select * from dba_objects;
SQL>select count(*) from gaotab;
SQL>Select tablespace_name from dba_tablespaces;
TABLESPACE_NAME
----------------------------------------------
SYSTEM
UNDOTBS1
SYSAUx
TEMP
USERS
GAO
SQL>alter tablespace gao offline;
Tablespace altered.
SQL>
****************************************
然后,进行转换:
****************************************
su – oracle
$rman target /
…
RMAN> copy datafile ‘/dev/sdd5’ to ‘/oracle/tbs/gaotbs.dbf’;
Starting backup at 13-APR-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=146 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=/dev/sdd5
output filename=/oracle/tbs/gaotbs.dbf tag=TAG20140413T204555 recid=1 stamp=844807557
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 13-APR-14
RMAN>exit
****************************************
再回到数据库中,改表空间对应的文件名:
SQL>alter database rename file ‘/dev/sdd5’ to ‘/oracle/tbs/gaotbs.dfb’;
Database altered.
SQL>alter tablespace gao online;
Tablespace altered.
SQL>select file_name from dba_data_files where tablespace_name=’GAO’;
FILE_NAME
-------------------------------------------------
/oracle/tbs/gaotbs.dfb
SQL>