asm和file system之间数据文件的转换

简介:

How to move a datafile from a file system to ASM
Moving a datafile from the file system can be achived in two ways.


i. While the database is shutdown (in mount stage).
ii. While the database is running (with the selected tablespace offline).
(
数据文件实现文件系统到ASM的转换迁移,一是在数据库mount状态,二是在open状态,但数据文件所属表空间需要offline状态)
-----------------------------------------------------------------------------------------------

i. While the database is shutdown (in mount stage).
1mount状态)
Moving oracle datafile while the database is in mount stage is performed in the following way:

1. Shutdown and mount the database.

[oracle@linux] sqlplus '/as sysdba'
SQL> shutdown immediate;
SQL> startup mount;


2. Ensure you have enough space in the ASM diskgroup to copy the datafile.
First identify the size of the datafile you wish to move.

ASM上要有足够的空间

SQL> select file#, name, (bytes/1048576) File_Size_MB from v$datafile;
FILE# NAME FILE_SIZE_MB
----- ---------------------------- --------------
...
4 /oradata/PROD/users01.dbf 2500
...
* In this example we will be moving users01.dbf

[oracle@linux] export ORACLE_SID=+ASM

SQL> select NAME, STATE, TOTAL_MB, FREE_MB from v$asm_diskgroup;

NAME STATE TOTAL_MB FREE_MB
------------------------------ ----------- ---------- ----------
DGROUP1 MOUNTED 100 3
DGROUP2 MOUNTED 4882 4830


3. Connect to RMAN and copy the datafile from the filesystem to the select ASM diskgroup.

RMAN copy 数据文件

[oracle@linux] rman target=/
RMAN> copy datafile 4 to '+DGROUP2'
Starting backup at 2006/09/05 12:14:23
using target database controlfile instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=31 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=/oradata/PROD/users01.dbf
output filename=+DGROUP2/PROD/datafile/users01.258.600351265 tag=TAG20060905T121424 recid=10 stamp=600351264
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:05:01
Finished backup at 2006/09/05 12:19:24


4. Update the controlfile with the new location of the datafile.

更新控制文件中的数据文件新的文件位置

[oracle@linux] rman target /
RMAN> switch datafile 4 to copy;
datafile 4 switched to datafile copy "+DGROUP2/PROD/datafile/users01.258.600351265".

5. The file is now if the new location.

在数据库中查看,文件位置已经更新

SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
..
+DGROUP2/PROD/datafile/users01.258.600351265
..

6. The database may now be opened.
open
数据库。

While the database is running (with the select tablespace offline).

open状态下转换
In order to move a datafile on a running active database the tablespace where the datafile resides must be placed offline.

1. Identify the tablespace which contains the datafile and offline the tablespace.

确保表空间offline

SQL> select tablespace_name, file_name from dba_data_files where file_id=4;

TABLESPACE_NAME FILE_NAME
------------------ ------------------------------
USERS /oradata/RMAN/users01.dbf


SQL> alter tablespace USERS offline;

 

* * * * * Continue with Steps 2 - 5 above. * * * * *

以上步骤2-5相同

6. After you have successfully completed the above steps (2 -5) place the

tablespace online;

 

SQL> alter tablespace USERS online;

 

目录
相关文章
|
SQL 数据库
asm管理的dg数据文件缺失的处理方法
一次由于DG磁盘组满了,而这段时间生产上又产生新的数据文件,导致在dg上新建的数据文件变成UNNAMED命名的数据文件了1、        生产库通过convert备份缺失的文件RMAN> convert datafile '+DATA/ctsdb/datafile/ts_recent.
1000 0
|
SQL Oracle 关系型数据库
【ASM】ASM数据文件和OS文件(FILESYSTEM)转移方法总结
【ASM】ASM数据文件和OS文件(FILESYSTEM)转移方法总结 blog文档结构图:   1  说明 本blog介绍了各种asm数据文件和filesystem文件之间的转换方法,有的记录了过程,有的没有记录过程只记录了相关代码,大家若有兴趣可以自行测试。
855 0
|
SQL Oracle 关系型数据库
[20130115]测试从asm中取出spfile文件以及一个数据文件.txt
[20130115]测试从asm中取出spfile文件以及一个数据文件.txt参考: http://www.xifenfei.com/3019.html 使用dd复制asm中文件SQL> column name format a50 SQL> select fi...
601 0