【翻译自mos文章】 使用asmcmd cp命令 把datafile从文件系统移动(move)到asm磁盘组中--针对11gR2,asmcmd11gr2
使用asmcmd cp命令 把datafile从文件系统移动(move)到asm磁盘组中--针对11gR2
参考原文:
How to Move a Datafile from Filesystem to ASM Using ASMCMD CP Command. (Doc ID 1610615.1)
适用于:
Oracle Database - Enterprise Edition - Version 11.2.0.1 to 11.2.0.4 [Release 11.2]
Information in this document applies to any platform.
症状:
datafile被错误的添加到了文件系统中,应该是放在asm磁盘组中的。
原因:
这不是一个system表空间的datafile
解决方案:
1 让该datafile offline
SQL> alter system switch logfile;
System altered.
SQL> select file_name, file_id from dba_data_files;
FILE_NAME FILE_ID
---------------------
/u01/oracle/oradata/test1.dbf 6
SQL> alter database datafile 6 offline;
Database altered.
SQL> select file_name, file_id, online_status from dba_data_files where file_id=6;
FILE_NAME FILE_ID ONLINE_STATUS
---------- -------
/u01/oracle/oradata/test1.dbf 6 RECOVER
2. 使用asmcmd命令 将此文件从文件系统拷贝到asm磁盘组中。
ASMCMD> cp /u01/oracle/oradata/test1.dbf +DATA/LONDON/DATAFILE/test.dbf
copying /u01/oracle/oradata/test1.dbf -> +DATA/LONDON/DATAFILE/test.dbf
ASMCMD> ls -lt
Type Redund Striped Time Sys Name
N test.dbf => +DATA/ASM/DATAFILE/test.dbf.286.833718815
ASMCMD> pwd
+DATA/ASM/DATAFILE
3. 一旦该datafile被拷贝完成,重命名该datafile
SQL> alter database rename file '/u01/oracle/oradata/test1.dbf' to '+DATA/LONDON/DATAFILE/test.dbf';
Database altered.
4. recover 该datafile ,并且onlime 该datafile
SQL> alter database recover datafile 6;
Database altered.
SQL> alter database datafile 6 online;
Database altered.
5.确认正确的文件名和路径
SQL> select file_name, file_id, online_status from dba_data_files where file_id=6;
FILE_NAME FILE_ID ONLINE_STATUS
---------- -------
+DATA/london/datafile/test.dbf 6 ONLINE
oracle 10R2推出了asmcmd这个工具,可以用来管理asm存储上的文件。
1.使用asmcmd命令必须先启动asm实例,不然会有以下报错:rac2-> asmcmd -p
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux Error: 2: No such file or directory (DBD ERROR: OCISessionBegin)2.使用asmcmd必须先指定ORACLE_HOME和ORACLE_SID,注意此处ORACLE_SID是asm的sid,不然会报错:rac2-> asmcmd -p
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux Error: 2: No such file or directory (DBD ERROR: OCISessionBegin)3.asmcmd命令带p参数和不带p参数的作用:
带p,使用asmcmd将显示当前路径:rac2-> asmcmd -p
ASMCMD [+] > ls
DG1/
RECOVERDEST/
ASMCMD [+] > cd DG1
ASMCMD [+DG1] > ls
DEVDB/
ASMCMD [+DG1] > cd DEVDB
ASMCMD [+DG1/DEVDB] >不带p,不显示当前路径:rac2-> asmcmd
ASMCMD> ls
DG1/
RECOVERDEST/
ASMCMD> cd DG1
ASMCMD> ls
DEVDB/
ASMCMD> cd DEVDB
ASMCMD>4.其他相关参数,可使用help查看ASMCMD [+] > help
asmcmd [-p] [command]
The environment variables ORACLE_HOME and ORACLE_SID determine the
instance to which the program connects, and ASMCMD establishes a
bequeath connection to it, in the same manner as a SQLPLUS / AS
SYSDBA. The user must be a member of the SYSDBA group.
Specifying the -p option allows the current directory to be displayed
in the command prompt, like so:
ASMCMD [+DATAFILE/ORCL/CONTROLFILE] >
[command] specifies one of the following commands, along with its
parameters.
Type "h......余下全文>>
.asm是源代码而已,是纯文本,要用masm.exe把它编译成中间文件,再用link.exe把中间文件链接成目标文件(*.exe)才能运行