【翻譯自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
linux 中 ASM命令作用
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......餘下全文>>
怎使用cmd的命令直接運行asm程式,不用masm軟體 ??
.asm是原始碼而已,是純文字,要用masm.exe把它編譯成中間檔案,再用link.exe把中間檔案連結成目標檔案(*.exe)才能運行