【翻譯自mos文章】使用asmcmd命令在本地和遠程 asm 執行個體之間 拷貝asm file的方法,asmcmdasm

來源:互聯網
上載者:User

【翻譯自mos文章】使用asmcmd命令在本地和遠程 asm 執行個體之間 拷貝asm file的方法,asmcmdasm

使用asmcmd命令在本地和遠程 asm 執行個體之間 拷貝asm file的方法

參考原文:
How to Copy asm files between remote ASM instances using ASMCMD command (Doc ID 785580.1)

適用於:
Oracle Database - Enterprise Edition - Version 11.1.0.6 to 11.2.0.2 [Release 11.1 to 11.2]
Information in this document applies to any platform.
***Checked for relevance on 14-Jan-2011***
***Checked for relevance on 09-Jul-2014 ***


目標:
本文檔的目的是提供使用asmcmd命令在本地執行個體和遠程執行個體之間拷貝asm file的方法。

解決方案:
11g 有新特性--可以在本地和遠程執行個體之間拷貝asm file
也可以用於 從asm 磁碟組拷貝檔案到os

cp -ifr <source file name> <user_name>@<host_name>.<Port Number>.<SID>:<targer path>/<target file name>

user_name@host_name.<Port Number>.<SID>

The user_name, host_name, and SID are required. The default port number is 1521.

--->注意,此處的sid是 asm執行個體的sid,不是資料庫執行個體的sid

舉例:
asmcmd>cp -ifr +DATA/RAC/PARAMETERFILE/spfile.257.678975489 sys@stgrac1.1521.+ASM2:+FRA/RAC/ARCHIVELOG/spfile


ASMCMD remote copy 的一些解釋:
asmcmd remote copy 的運行需要通過監聽器建立串連
asmcmd remote connection 可能由於一些錯誤導致串連失敗。

ASMCMD-08202: internal error: [asmcmdshare_error_msg_05] [8201]

[8201] means unable to connect remote ASM Instance.

該錯誤的可能原因如下:
* not able to reach remote host. 不能串連遠程主機
* Remote host listener is down.  遠程監聽器down掉
* Remote ASM Instance is not registered with listener and running non-default port. 遠程asm執行個體沒有註冊到監聽器中,並且監聽器運行在非預設連接埠
* sysasm remote connection does not work.  sysasm遠端連線不工作
* Incorrect password given for sys user.  sys 使用者的錯誤密碼
* Remote ASM Instance password file missing. 遠程asm執行個體的 密碼檔案丟失

我們需要啟用額外的tracing(跟蹤),以得到asmcmd connection 失敗的準確資訊。

++設定 DBI_TRACE 環境變數,以便進行 asmcmd perl tracing

export DBI_TRACE=1

++現在使用asmcmd串連,並再現該問題:

Example 1:
--->例子開始
asmcmd>cp +data/spfileorcl.ora.289.686235413 sys@stgrac1.1521.+ASM1:+test

-> DBI->connect(dbi:Oracle:host=stgrac1;port=1521;sid=+ASM1, sys, ****, HASH (0x8b2b044))
connect using '(DESCRIPTION=(ADDRESS=(HOST=stgrac1)(PROTOCOL=tcp)(PORT=1521))(CONNECT_DATA=(SID=+ASM1)))'
ERROR: '1031' 'ORA-01031: insufficient privileges

(DBD ERROR: OCISessionBegin)'
<- DESTROY= undef at DBI.pm line 591
DBI connect('host=stgrac1;port=1521;sid=+ASM1','sys',...) failed: ORA-01031: insufficient privileges (DBD ERROR: OCISessionBegin)
KK FROM HERE A
ASMCMD-08202: internal error: [asmcmdshare_error_msg_05] [8201]

--->例子結束

可以看到由於ORA-01031錯誤,asmcmd 拷貝檔案失敗。
如果-a選項不使用的話,asmcmd 預設使用sysasm 許可權。
這裡的問題是:遠端asm執行個體中,sysasm 許可權沒有被授予sys user
把sysasm許可權給sys使用者。當你授予系統許可權時,密碼檔案會被更新。

SQL> grant sysasm to sys;
Grant succeeded.

SQL> select * from v$pwfile_users;
USERNAME SYSDB SYSOP SYSAS
------------------------------ ----- ----- -----
SYS TRUE TRUE TRUE


現在,遠程asm 拷貝能正常工作了。

關於更多細節,請參考下面的文章:
Note.730067.1 - Troubleshooting ORA-1031 Insufficient Privilege
Note.578796.1 - ORA-01031 While Connecting as SYSASM


Example 2:

ASMCMD> cp -ifr thread_2_seq_5.264.678983423 sys@bderac2-vip.1521.+ASM2:+FRA/RAC/ARCHIVELOG/
Enter password: ***
ASMCMD-08016: copy source->'+FRA/RAC/ARCHIVELOG/2009_02_16/thread_2_seq_5.264.678983423' and target->'+FRA/RAC/ARCHIVELOG/thread_2_seq_5.264.678983423' failed
ORA-17628: Oracle error 19505 returned by remote Oracle server
ORA-06512: at "SYS.X$DBMS_DISKGROUP", line 258
ORA-06512: at line 3 (DBD ERROR: OCIStmtExecute)
ASMCMD>

cp命令失敗的原因是:
目標的asm file 名字沒有指定, 或者 檔案名稱字不應該包括file number/incarnation.
--->注意,我對本句的翻譯有點疑問,
原文為The cp command failed because the target ASM file name was not specified  or File name should not contain the file number/incarnation

不指定檔案名稱字,我們不能拷貝omf 命名格式的檔案。

cp -ifr thread_2_seq_5.264.678983423 sys@bderac2-vip.1521.+ASM2:+FRA/RAC/ARCHIVELOG/thread_2_seq_5

The file number/incarnation 會在拷貝的過程中被自動建立.

 


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)才能運行
 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.