概述
访问ASM中文件的方法
1、ASMCMD
10GR2版本后提供ASMCMD工具来对ASM中文件和路径进行浏览和管理。10G版本支持搜索、查看、创建路径和别名以及显示空间利用率等功能。11G中对这个工具进行了强化,使其支持cp命令,可以直接将ASM中文件复制到文件系统或者其他ASM路径中。
-bash-3.00$ id
uid=500(oracle) gid=500(dba)
-bash-3.00$ uname -a
SunOS db-2 5.10 Generic_142900-03 sun4u sparc SUNW,SPARC-Enterprise
-bash-3.00$ export ORACLE_SID=+ASM1
-bash-3.00$ asmcmd -p
ASMCMD [+] > help
asmcmd [-p] [command]
commands:
--------
cd
du
find
help
ls
lsct
lsdg
mkalias
mkdir
pwd
rm
rmalias
ASMCMD [+] >
11G可以使用cp命令来进行文件的复制,如:
ASMCMD [+] > cp +DATA1/RAC/DATAFILE/sample.256.629730771 /home/oracle/oradata/rac/sample.dbf
ASMCMD [+] > cp /home/oracle/oradata/rac/sample.dbf +DATA1/RAC/DATAFILE/
也可以实现远程复制
ASMCMD [+] > cp –ifr +DATA1/RAC/DATAFILE/sample.256.629730771 sys@server1,1521,+DATA2//RAC/DATAFILE/ sample.dbf
2、FTP
除了使用asmcmd命令之外,还可以通过FTP的方式访问ASM磁盘组中的文件。
默认情况,这个ftp的端口是关闭的,可以通过下面的命令打开:
SQL> conn / as sysdbaITPUB个人空间#u y%N[1]wR
已连接。ITPUB个人空间*IY3r7jC
SQL> @?/rdbms/admin/catxdbdbca.sql 7788 8800
-i @$p,{0K m|/y-J13177610SQL> SET FEEDBACK 1
;W)I {8q(f
a)gx_13177610SQL> SET NUMWIDTH 10ITPUB个人空间-p Rk:Z:B.G Q;L Y L‑g(y
SQL> SET LINESIZE 80
X UY'|‑p L:A(V(m13177610SQL> SET TRIMSPOOL ON
^f)y_.P3bxTl;y13177610SQL> SET TAB OFF
'@n4O&O4ZtS/Z2YFW`13177610SQL> SET PAGESIZE 100ITPUB个人空间2H3E'y{m r H M
SQL>ITPUB个人空间[g2G4J;E-G*H
SQL> define ftpport = &1ITPUB个人空间(YV w;PEN
SQL> define httpport = &2
9sE/i[1]k*@‑n]13177610SQL> Rem Create a function to traverse the dom elements.
l5K f1R l9Z*C @E13177610SQL> CREATE OR REPLACE FUNCTION traverseDom
.}2I"r!Tcik;[13177610 2 (parnode dbms_xmldom.DOMNode, pathSeg VARCHAR2)
0fe eoEr:k13177610 3 RETURN dbms_xmldom.DOMNode IS
a9|%`/`!M13177610 4 nodeList dbms_xmldom.DOMNodeList;ITPUB个人空间; IP%XG k&z oT7~
5 anElement dbms_xmldom.DOMElement;ITPUB个人空间‑m!X!E2`%z!^
6 aNode dbms_xmldom.DOMNode;ITPUB个人空间y$t4B@3h^5U+LN
7 BEGINITPUB个人空间'W;? x/U&{d:Ci4m
8 -- Convert the passed in dom node to an element
vg(L^6T k8Z V9h13177610 9 anElement := dbms_xmldom.makeElement(parnode);
5Q+L g W C6JC13177610 10 ITPUB个人空间;l9?;o ?
`}5n
11 -- Select the path segment requested by the userITPUB个人空间 sP FDW
12 nodeList := dbms_xmldom.getChildrenByTagName(anElement, pathSeg);ITPUB个人空间 o:G[Ig1zqm
13 ITPUB个人空间E~6]m-]~
14 -- get the first node out of the listITPUB个人空间f O)J
_;{
]
15 aNode := dbms_xmldom.item(nodeList, 0);ITPUB个人空间0R+J`?HCx
16 ITPUB个人空间7f3~-R vo0pt[1]EX
17 -- return that node (ignore errors here).ITPUB个人空间#Axe%cM'|Q-K
18 return aNode;
n#hL[v13177610 19 END;ITPUB个人空间D].FP9}B+`_ QB4?
20 /
函数已创建。
SQL>
‑c5t}O&F13177610SQL> declareITPUB个人空间 T8U&nl7RO y%F7N
2 configxml sys.xmltype;
+ZI v !DV uHXN13177610 3 configdomdoc dbms_xmldom.DOMDocument;ITPUB个人空间 nv+c9X-kG
4 textNode dbms_xmldom.DOMNode;ITPUB个人空间a/l1G5W@M
5 aNode dbms_xmldom.DOMNode;
l3k5V,x)p~e(_v:MC13177610 6 protNode dbms_xmldom.DOMNode;
'c X N^{13177610 7 anElement dbms_xmldom.DOMElement;ITPUB个人空间8A8Odx;O$R
8 listOfNodes dbms_xmldom.DOMNodeList;
@;s7@KTvP1`K t13177610 9 aString VARCHAR2(100);ITPUB个人空间&]'S:Zk6r%S:`&TOR
10 beginITPUB个人空间~%`e{C:j4n‑J[1]_2b)[![;N
11 ITPUB个人空间E‑@wp:[
h Jz
12 -- Select the resource and set it into the config
qK[1]D t$zOx4F13177610 13 select sys_nc_rowinfo$ into configxml from xdb.xdb$config ;
T1Jnrm/he)X,h p-k13177610 14
Uv/H|3fw‑Y o5U13177610 15 -- Create a dom document out of the xmltypeITPUB个人空间 lS T"Pc6E‑F
16 configdomdoc := dbms_xmldom.newDOMDocument(configxml);
C+Z G-LA13177610 17
` l5Q.r l(L13177610 18 -- Get the root Element of the dom
1L.T [L]
l#}13177610 19 anElement := dbms_xmldom.getDocumentElement(configdomdoc);ITPUB个人空间R r*g&z(h{y WL y
20 ITPUB个人空间 `Bin Q(J
QD A2]
21 -- Convert this to a node
[1]XL!$@ J(g13177610 22 aNode := dbms_xmldom.makeNode(anElement);ITPUB个人空间2`aa)nJ D
23
‑}8HO
d1L Clt:x13177610 24 -- Traverse One Element Down At A Time.
%J,Q rl8fc8~13177610 25 aNode := traverseDom(aNode, 'sysconfig');ITPUB个人空间#LR U:V ]5XG
26 protNode := traverseDom(aNode, 'protocolconfig');ITPUB个人空间 J!_cI7b9w#N e"k(GN
27
)C)uI%Hv uvc8b9D13177610 28 -- Set the FTP port by traversing /ftpconfig/ftp-port
M(h4V*s'H1Q:yW13177610 29 aNode := traverseDom(protNode, 'ftpconfig');ITPUB个人空间a3F}C v
30 aNode := traverseDom(aNode, 'ftp-port');ITPUB个人空间)q%R q|3O6q$W9D
31 textNode := dbms_xmldom.getFirstChild(aNode);
+|W,s'pz+D|#b Ci13177610 32 dbms_xmldom.setNodeValue(textNode, &ftpport);ITPUB个人空间e#B9e)~P l
33
v2qrb o13177610 34 -- Set the FTP port by traversing /ftpconfig/ftp-portITPUB个人空间IATr4a-b r
35 aNode := traverseDom(protNode, 'httpconfig');ITPUB个人空间a1N` E
v[1]W
36 aNode := traverseDom(aNode, 'http-port');
mhNF0zBO13177610 37 textNode := dbms_xmldom.getFirstChild(aNode);
SKE%eF7q;A13177610 38 dbms_xmldom.setNodeValue(textNode, &httpport);ITPUB个人空间h'S1^-]2U"j(o
39 ITPUB个人空间"U0Z/d7GT#P
40 dbms_xdb.cfg_update(configxml);ITPUB个人空间t,e1r?_[1]{:i
41 commit;
,j%~5h9z9k'v!Lg13177610 42
QT!Q x'[13177610 43 end;ITPUB个人空间.R:y[1]ek6I T+n;f T([)K u{
44 /
[1]I1J$qxsvg7a]~13177610原值 32: dbms_xmldom.setNodeValue(textNode, &ftpport);ITPUB个人空间Q})f‑w$n G7Ig[1]z
新值 32: dbms_xmldom.setNodeValue(textNode, 7788);ITPUB个人空间T y'v Q;v[
原值 38: dbms_xmldom.setNodeValue(textNode, &httpport);ITPUB个人空间 ob(}‑R6Yp$o0b‑D
新值 38: dbms_xmldom.setNodeValue(textNode, 8800);
PL/SQL过程已成功完成。
SQL>ITPUB个人空间r2U&W+j W
SQL>
jc!Y { a*@13177610SQL> drop function traverseDom;
函数已删除。
这个脚本需要SYS或者XDB用户来调用,后面跟的两个参数分别是FTP的端口和HTTP/WEBDAV的端口。
下面就可以通过端口7788来访问ASM磁盘组了:
SQL> hostITPUB个人空间7a9N[1]i%w[1]u:fs
$ ftp
m
~ OQ0yeNX j13177610ftp> open ser1 7788
0nB#t1t X I3A i13177610Connected to ser1.
+wZ"|1c-vOf*AMC&b!b13177610220- ser1
sa#r l$d`13177610Unauthorised use of this FTP server is prohibited and may be subject to civil and criminal prosecution.ITPUB个人空间;Tb/h"?[1]wm%|P
220 ser1 FTP Server (Oracle XML DB/Oracle Database) ready.
3IL:j{Or)I-z&W
yRi13177610Name (ser1:root): systemITPUB个人空间 go I k;F"O%Q5{
331 pass required for SYSTEM
r9]$Sos/g n13177610Password:
‑I/l"Z(B#U7Z13177610230 SYSTEM logged inITPUB个人空间Ch;H({'P}!G
Remote system type is Unix.ITPUB个人空间*^7tP6y BmI
N n
ftp> cd /sys/asm
oG qMa13177610250 CWD Command successfulITPUB个人空间3WkQW U.i
ftp> ls
5h ? ZH'X!fr*m13177610200 PORT Command successfulITPUB个人空间k‑Y-WvO9D{)l` ` h3k
150 ASCII Data Connection
*d&ehj$~$p p'{13177610DATAITPUB个人空间 ?YJ T;~a4d!sU
226 ASCII Transfer Complete
n#w w W(SE131776106 bytes received in 0.17 seconds (0.04 Kbytes/s)ITPUB个人空间%{,uy w(f,l1nv.@.W"^
ftp> cd DATA
vt SKp[1]]'yz213177610250 CWD Command successfulITPUB个人空间tbZU1i:hG_ [ ^
ftp> ls
(f
A‑M6DRr%v7M13177610200 PORT Command successful
*i D ?f8j C({2t&A,j13177610150 ASCII Data ConnectionITPUB个人空间5f.ALiN L+|k U
RACTESTITPUB个人空间/W Kr)N/M w
ASMTESTING
1kZ4}I t%s0bi13177610226 ASCII Transfer Complete
/a!}!Jk Xy"Q(FX1317761021 bytes received in 0.0021 seconds (9.58 Kbytes/s)
E Eto:d htZb QZ&S13177610ftp> cd RACTESTITPUB个人空间‑hs:f7~'`X
250 CWD Command successful
8Ulp8?l%h.P t _D7~13177610ftp> lsITPUB个人空间~Q xcOR
200 PORT Command successful
Z.J5r&E`:J[1]QP:]13177610150 ASCII Data Connection
6q7g S(D;jL/u*o[1]w13177610CONTROLFILEITPUB个人空间,g` CX?;E
ONLINELOG
;G,K!}'_;Y x13177610DATAFILEITPUB个人空间(} }bId
TEMPFILEITPUB个人空间uv8qL1y^9R0T
PARAMETERFILE
(g/O.kL L13177610spfileractest.oraITPUB个人空间[ lF3|%[&ws.O@'R
backupITPUB个人空间 U)r!~F$t G.S7a
226 ASCII Transfer CompleteITPUB个人空间~l4a C ^ Jo@
86 bytes received in 0.003 seconds (28.41 Kbytes/s)
%l |c"~"h
])H13177610ftp> lcd /dataITPUB个人空间fO-t*K_c
Local directory now /data
0vS g V`Q13177610ftp> cd DATAFILE
BE7n[1]Yd p‑)HYH_13177610250 CWD Command successfulITPUB个人空间w6k‑kD HD/VPa)U
ftp> ls
/X'lw[p&g13177610200 PORT Command successful
w:ZSx[ b,m13177610150 ASCII Data ConnectionITPUB个人空间}D.L_
T*b)o |
SYSTEM.259.664395355
[1]}(A `"Xf#HN13177610SYSAUX.260.664395357ITPUB个人空间-H%qn,W:g MJ
UNDOTBS1.261.664395359ITPUB个人空间6` u o z4bl
UNDOTBS2.263.664395371ITPUB个人空间j"|@&n t8F L
?
USERS.264.664395373ITPUB个人空间Q j9IsO/MEF
226 ASCII Transfer CompleteITPUB个人空间 p.o6z/ H
113 bytes received in 0.0028 seconds (38.79 Kbytes/s)
.{ P@1LiO+G3s13177610ftp> bin
.i
kH f+o13177610200 Type set to I.ITPUB个人空间L-U'zN1ZS'LZC:Wwz
ftp> promptITPUB个人空间&K6`&G(b7@5ag"r
Interactive mode off.
`DA#^.O6sv!y13177610ftp> mget SYSTEM.259.664395355ITPUB个人空间s&@*^)If -c l
200 PORT Command successfulITPUB个人空间R;x0po+e6i z
f-@*l
150 BIN Data ConnectionITPUB个人空间[1]d`U6CbL
226 BIN Transfer Complete
%g4~-^%D @4m13177610local: SYSTEM.259.664395355 remote: SYSTEM.259.664395355ITPUB个人空间-iT ?[1]PS7IT-p
734011392 bytes received in 17 seconds (41380.50 Kbytes/s)
e|‑r(]o*wu R{!_13177610ftp> ls
?3BD
cU%G6Z4N13177610200 PORT Command successfulITPUB个人空间#kU{[1]B W A
150 ASCII Data Connection
:^T] @/B4c13177610SYSTEM.259.664395355
;TI(n,_d]+X13177610SYSAUX.260.664395357ITPUB个人空间*Z9fdg7_[U
UNDOTBS1.261.664395359
!n6b^ _`o$R3[13177610UNDOTBS2.263.664395371ITPUB个人空间V{SkEN2DS
USERS.264.664395373ITPUB个人空间?~Xi_+|hX4B
226 ASCII Transfer CompleteITPUB个人空间8DR3nd‑Nx
113 bytes received in 0.0037 seconds (29.51 Kbytes/s)ITPUB个人空间q1@ Z C
ftp> cd ..ITPUB个人空间 yV gs C,R'z)h
250 CWD Command successful
%} L9a4d{r4^ `| |+g13177610ftp> lsITPUB个人空间Jz8JaN2A1R'k!^ M:a
200 PORT Command successful
C
P.f l
~$Sh
r8L13177610150 ASCII Data Connection
.U D0D F3O| mf3r13177610CONTROLFILE
f YA"k3X9l M{13177610ONLINELOG
;`r$Yas?13177610DATAFILEITPUB个人空间U+C]I5E4h(F8}
TEMPFILEITPUB个人空间7h1g }B;Z9H
PARAMETERFILE
#u+Jh[1]|6wJd'm13177610spfileractest.oraITPUB个人空间 O5Dfh+H P M
P
`A
backup
‑T1C Pd]u7BG13177610226 ASCII Transfer Complete
yS*]{4~0?Nk1317761086 bytes received in 0.003 seconds (27.67 Kbytes/s)ITPUB个人空间%l|
A D8k._
P
ftp> cd backup
f$f^:A6s7q13177610250 CWD Command successful
S R-Pl
d };Jk%Z8s./g13177610ftp> send SYSTEM.259.664395355 system.dbfITPUB个人空间K%s8H2yQ/r8mv$q l
200 PORT Command successful
0?(s0~mIY E2U13177610150 BIN Data ConnectionITPUB个人空间9SdqGAvi@
z‑o
226 BIN Transfer CompleteITPUB个人空间.F[1]W/l-@;n,J
local: SYSTEM.259.664395355 remote: system.dbfITPUB个人空间$R+Yx^ e~4a;j8z,x
734011392 bytes sent in 9.5 seconds (75647.23 Kbytes/s)ITPUB个人空间!O!o$vQ8q%S |%c0f
ftp> ls
j‑W!EK2_m9Z o ZX‑`13177610200 PORT Command successfulITPUB个人空间(q @Q e!Q j
150 ASCII Data ConnectionITPUB个人空间$wc-gL‑xm5u
02jplh5q_1_1
0ZY#[`*u13177610system.dbfITPUB个人空间 X!dd7F,cv
226 ASCII Transfer Complete
}d2A(R,v~y1317761026 bytes received in 0.0025 seconds (10.13 Kbytes/s)
Aw!s%Z^tD9z} s13177610ftp> quit
`X]8S"['V!J*u13177610221 QUIT Goodbye.
上面展示了利用ftp功能,在操作系统和ASM之间读写文件的操作。需要注意,ftp登陆需要一个非SYS的DBA账号。
登陆后在/sys/asm下可以找到ASM磁盘组信息。ftp的基本命令都可以使用,包括mkdir。
这个端口打开之后,除了本机之外,其他服务器也通过同样的方法可以直接访问ASM磁盘组。
3、SQLPLUS
SQL> select * from dict where table_name like 'V$ASM_%';
TABLE_NAME COMMENTS
------------------------------ ------------------------------------------
V$ASM_ALIAS Synonym for V_$ASM_ALIAS
V$ASM_CLIENT Synonym for V_$ASM_CLIENT
V$ASM_DISK Synonym for V_$ASM_DISK
V$ASM_DISKGROUP Synonym for V_$ASM_DISKGROUP
V$ASM_DISKGROUP_STAT Synonym for V_$ASM_DISKGROUP_STAT
V$ASM_DISK_STAT Synonym for V_$ASM_DISK_STAT
V$ASM_FILE Synonym for V_$ASM_FILE
V$ASM_OPERATION Synonym for V_$ASM_OPERATION
V$ASM_TEMPLATE Synonym for V_$ASM_TEMPLATE
9 rows selected
4、EM
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/13177610/viewspace-671733/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/13177610/viewspace-671733/
最后
以上就是缥缈草莓为你收集整理的访问ASM中的文件的全部内容,希望文章能够帮你解决访问ASM中的文件所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复