其他分享
首页 > 其他分享> > ASM数据文件和FS之间的各种转换方法(2)

ASM数据文件和FS之间的各种转换方法(2)

作者:互联网


2.2  rman+backup as copy+mount状态

run{

shutdown immediate;

startup mount;

backup as copy datafile 14 format '+DATA';

}

SWITCH TABLESPACE testdg TO COPY;

alter database open;

 

[oracle@rhel6_lhr ~]$ rman target /

 

Recovery Manager: Release 11.2.0.3.0 - Production on Tue Jan 13 15:00:19 2015

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: ORCLASM (DBID=3424884828)

 

RMAN> report schema;

 

using target database control file instead of recovery catalog

Report of database schema for database with db_unique_name ORCLASM

 

List of Permanent Datafiles

===========================

File Size(MB) Tablespace           RB segs Datafile Name

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

1    890      SYSTEM               ***     +DATA/orclasm/datafile/system.256.850260145

2    940      SYSAUX               ***     +DATA/orclasm/datafile/sysaux.257.850260145

3    190      UNDOTBS1             ***     +DATA/orclasm/datafile/undotbs1.258.851526539

4    2676     USERS                ***     +DATA/orclasm/datafile/users.259.850260147

5    345      EXAMPLE              ***     +DATA/orclasm/datafile/example.265.850260295

6    5        UNDOTBS2             ***     +DATA/orclasm/datafile/undotbs2.267.851204361

7    50       TBS_RC               ***     +DATA/orclasm/datafile/tbs_rc.268.852116523

8    100      TS_LHR               ***     +DATA/orclasm/datafile/ts_lhr.269.852632495

9    1        ENCRYPTED_TS         ***     +DATA/orclasm/datafile/encrypted_ts.272.854650889

10   100      GOLDENGATE           ***     +DATA/orclasm/datafile/goldengate.273.862829891

11   50       APP1TBS              ***     +DATA/orclasm/datafile/app1tbs.274.866911939

12   50       APP2TBS              ***     +DATA/orclasm/datafile/app2tbs.275.866912075

13   50       IDXTBS               ***     +DATA/orclasm/datafile/idxtbs.276.866912133

14   2        TESTDG               ***     /home/oracle/testdg.dbf

 

List of Temporary Files

=======================

File Size(MB) Tablespace           Maxsize(MB) Tempfile Name

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

1    237      TEMP                 32767       +DATA/orclasm/tempfile/temp.264.850260283

2    10       TEMP1                10          +DATA/orclasm/tempfile/temp1.270.853779297

 

RMAN> @/home/oracle/h.sql

 

RMAN> run{

2> shutdown immediate;

3> startup mount;

4> backup as copy datafile 14 format '+DATA';

5> }

database closed

database dismounted

Oracle instance shut down

 

connected to target database (not started)

Oracle instance started

database mounted

 

Total System Global Area     375828480 bytes

 

Fixed Size                     2228464 bytes

Variable Size                268439312 bytes

Database Buffers             100663296 bytes

Redo Buffers                   4497408 bytes

 

Starting backup at 13-JAN-15

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=399 device type=DISK

channel ORA_DISK_1: starting datafile copy

input datafile file number=00014 name=/home/oracle/testdg.dbf

output file name=+DATA/orclasm/datafile/testdg.282.868892465 tag=TAG20150113T150104 RECID=35 STAMP=868892465

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

Finished backup at 13-JAN-15

 

Starting Control File and SPFILE Autobackup at 13-JAN-15

piece handle=/home/oracle/oracle_bk/orclasm/control_c-3424884828-20150113-09.bak comment=NONE

Finished Control File and SPFILE Autobackup at 13-JAN-15

 

RMAN> SWITCH TABLESPACE testdg TO COPY;

datafile 14 switched to datafile copy "+DATA/orclasm/datafile/testdg.282.868892465"

 

RMAN> alter database open;

database opened

 

RMAN> **end-of-file**

 

RMAN> report schema;

 

Report of database schema for database with db_unique_name ORCLASM

 

List of Permanent Datafiles

===========================

File Size(MB) Tablespace           RB segs Datafile Name

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

1    890      SYSTEM               ***     +DATA/orclasm/datafile/system.256.850260145

2    940      SYSAUX               ***     +DATA/orclasm/datafile/sysaux.257.850260145

3    190      UNDOTBS1             ***     +DATA/orclasm/datafile/undotbs1.258.851526539

4    2676     USERS                ***     +DATA/orclasm/datafile/users.259.850260147

5    345      EXAMPLE              ***     +DATA/orclasm/datafile/example.265.850260295

6    5        UNDOTBS2             ***     +DATA/orclasm/datafile/undotbs2.267.851204361

7    50       TBS_RC               ***     +DATA/orclasm/datafile/tbs_rc.268.852116523

8    100      TS_LHR               ***     +DATA/orclasm/datafile/ts_lhr.269.852632495

9    1        ENCRYPTED_TS         ***     +DATA/orclasm/datafile/encrypted_ts.272.854650889

10   100      GOLDENGATE           ***     +DATA/orclasm/datafile/goldengate.273.862829891

11   50       APP1TBS              ***     +DATA/orclasm/datafile/app1tbs.274.866911939

12   50       APP2TBS              ***     +DATA/orclasm/datafile/app2tbs.275.866912075

13   50       IDXTBS               ***     +DATA/orclasm/datafile/idxtbs.276.866912133

14   2        TESTDG               ***     +DATA/orclasm/datafile/testdg.282.868892465

 

List of Temporary Files

=======================

File Size(MB) Tablespace           Maxsize(MB) Tempfile Name

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

1    237      TEMP                 32767       +DATA/orclasm/tempfile/temp.264.850260283

2    10       TEMP1                10          +DATA/orclasm/tempfile/temp1.270.853779297

 

RMAN>



2.3  dbms_file_transfer

create directory asmsrc as'+DATA/orclasm/datafile/';

create directory osdesc as '/home/oracle/';

 

alter tablespace testdg offline;

 

exec dbms_file_transfer.copy_file('osdesc','testdg.dbf','ASMSRC','testdg.dbf);

 

alter database rename file'/home/oracle/testdg.dbf'  to '+DATA/orclasm/datafile/testdg.dbf';

alter tablespace testdg online ;

 

 

2.4  RMAN convert

 

rman下:

convert datafile '/home/oracle/testdg.dbf' format '+DATA';

sql 下:

alter tablespace testdg offline ;

alter tablespace testdg rename datafile '/home/oracle/testdg.dbf' to '+DATA/orclasm/datafile/testdg.284.868895277';

recover datafile 14;

alter tablespace testdg online;

 

 

2.5  cp命令

11g的asm实例可以直接使用cp命令来实现,从asm实例的cp帮助信息上看,已经可以直接从本地数据库直接cp到远端数据库了!

alter tablespace testdg offline;

[root@rhel6_lhr ~]# cp /home/oracle/testdg.dbf /home/grid/testdg.dbf

[root@rhel6_lhr ~]# chown grid:oinstall /home/grid/testdg.dbf

[root@rhel6_lhr ~]# su - grid

ASMCMD> cp /home/grid/testdg.dbf +DATA/orclasm/datafile/testdg.dbf

copying /home/grid/testdg.dbf -> +DATA/orclasm/datafile/testdg.dbf

ASMCMD>  

alter database rename file'/home/oracle/testdg.dbf'  to '+DATA/orclasm/datafile/testdg.dbf';

alter tablespace testdg online ;


标签:datafile,FS,orclasm,dbf,转换方法,testdg,home,DATA,ASM
来源: https://blog.51cto.com/lhrbest/2716024