ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 【原创】ASM下的数据文件转换为普通文件

【原创】ASM下的数据文件转换为普通文件

原创 Linux操作系统 作者:木头一个 时间:2008-06-22 22:00:54 0 删除 编辑

发现很多文章都是介绍如何将普通文件装换为ASM下的数据文件的,介绍ASM下的文件转换为普通文件的较少。下面的实验就是介绍如何将ASM的文件转换为普通文件的,主要使用了RMAN和ASMCMD工具。

注:此实验的为SYSAUX表空间。如果将整个数据库都从ASM中转移出来,其他表空间的操作类似,不过在线日志、Undo表空间、临时表空间重建即可,不需要转移出来。

具体实验步骤
1.使用RMAN将需要转换的文件+TEST/test/datafile/sysaux.257.650496219备份为F:\sysaux01.dbf
C:\WINDOWS>rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Fri Jun 20 23:32:26 2008

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

connected to target database: T (DBID=544433466)

RMAN> report schema;

using target database control file instead of recovery catalog
Report of database schema

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    540      SYSTEM               ***     +TEST/test/datafile/system.258.650496175
2    140      UNDOTBS1             ***     +TEST/test/datafile/undotbs1.259.650496245
3    370      SYSAUX               ***     +TEST/test/datafile/sysaux.257.650496219
4    5        USERS                ***     +TEST/test/datafile/users.260.650496247
5    1        TEST_BIG             ***     +TEST/test/datafile/test_big.262.650496255
6    10       SYSAUX               ***     F:\ORACLE\PRODUCT\ORADATA\TEST\SYSAUX02.DBF
8    10       TEST                 ***     F:\ORACLE\PRODUCT\ORADATA\TEST\TEST01.DBF
9    10       TEST1                ***     F:\ORACLE\PRODUCT\ORADATA\TEST\TEST02.DBF
10   10       UNDO01               ***     F:\ORACLE\PRODUCT\ORADATA\TEST\UNDO01.DBF
11   10       UNDO02               ***     F:\ORACLE\PRODUCT\ORADATA\TEST\UNDO02.DBF
12   10       TEST03               ***     F:\ORACLE\PRODUCT\ORADATA\TEST\TEST03.DBF

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
2    30       TEMP                 30          +TEST/temp01.dbf

RMAN> copy datafile 3 to 'F:\sysaux01.dbf';

Starting backup at 20-JUN-08
configuration for DISK channel 2 is ignored
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=158 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00003 name=+TEST/test/datafile/sysaux.257.650496219
output filename=D:\1.DBF tag=TAG20080620T233341 recid=13 stamp=657934458
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
Finished backup at 20-JUN-08

2.由于操作的是SYSAUX表空间,恢复需要在mount下进行
RMAN> shutdown immediate

database closed
database dismounted
Oracle instance shut down

RMAN> startup mount

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area     268435456 bytes

Fixed Size                     1248504 bytes
Variable Size                138412808 bytes
Database Buffers             121634816 bytes
Redo Buffers                   7139328 bytes

3.使用ASMCMD删除ASM中已有的SYSAUX表空间的数据文件
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.

C:\WINDOWS>set ORACLE_HOME=f:\oracle\product/10.2.0
C:\WINDOWS>set ORACLE_SID=+asm
C:\WINDOWS>asmcmd
ASMCMD> ls

TEST/
ASMCMD> cd test
ASMCMD> ls

TEST/
redo04.log
redo05.log
redo06.log
temp01.dbf

ASMCMD> cd test
ASMCMD> ls

BACKUPSET/
CONTROLFILE/
DATAFILE/
ONLINELOG/
TEMPFILE/
control01.ctl
control02.ctl
ASMCMD> cd datafile
ASMCMD> ls

SYSAUX.257.650496219
SYSTEM.258.650496175
TEST_BIG.262.650496255
UNDOTBS1.259.650496245
USERS.260.650496247

ASMCMD> rm SYSAUX.257.650496219
ASMCMD> ls

SYSTEM.258.650496175
TEST_BIG.262.650496255
UNDOTBS1.259.650496245
USERS.260.650496247

ASMCMD>

4.修改备份的数据文件名(这步也可以不需要,在备份的时候直接备份到需要的位置即可)
从F:\sysaux01.dbf移动至F:\ORACLE\PRODUCT\ORADATA\TEST\SYSAUX01.DB

5.修改数据库的控制文件,将原来SYSAUX的数据文件由ASM下改名到备份的文件
RMAN> run
2> {set newname for datafile '+TEST/test/datafile/sysaux.257.650496219' to 'F:\oracle\product\oradata\test\sysaux01.dbf';
3> switch datafile all;
4> }

由于移动了备份的文件的位置(从F:\sysaux01.dbf移动至F:\ORACLE\PRODUCT\ORADATA\TEST\SYSAUX01.DB),而新的文件没有catalog,所以报错了
executing command: SET NEWNAME

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of switch command at 06/20/2008 23:41:02
RMAN-20230: datafile copy not found in the recovery catalog
RMAN-06015: error while looking up datafile copy name: F:\ORACLE\PRODUCT\ORADATA\TEST\SYSAUX01.DBF

6.将移动后的备份数据文件catalog
RMAN> catalog datafilecopy 'F:\ORACLE\PRODUCT\ORADATA\TEST\SYSAUX01.DBF';

cataloged datafile copy
datafile copy filename=F:\ORACLE\PRODUCT\ORADATA\TEST\SYSAUX01.DBF recid=14 stamp=657934913

7.重新修改数据文件的位置
RMAN> run
2> {set newname for datafile '+TEST/test/datafile/sysaux.257.650496219' to 'F:\oracle\product\oradata\test\sysaux01.dbf';
3> switch datafile all;
4> }

executing command: SET NEWNAME

datafile 3 switched to datafile copy
input datafile copy recid=14 stamp=657934913 filename=F:\ORACLE\PRODUCT\ORADATA\TEST\SYSAUX01.DBF

8.恢复数据文件
RMAN> recover datafile 3;

Starting recover at 20-JUN-08
configuration for DISK channel 2 is ignored
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=152 devtype=DISK

starting media recovery
media recovery complete, elapsed time: 00:00:03

Finished recover at 20-JUN-08

9.打开数据库,此时SYSAUX表空间的数据文件已经由ASM下转移为普通文件
RMAN> sql 'alter database open';

sql statement: alter database open

RMAN>

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

请登录后发表评论 登录
全部评论

注册时间:2008-04-14

  • 博文量
    58
  • 访问量
    101649