ASM与本地文件系统的交互实验
一、通过Oracle自带包提取
1. 从ASM提取到本地
SQL> create directory sou as '+data/RAC';
Directory created.
SQL> create directory des as '/home/oracle';
Directory created.
SQL> exec dbms_file_transfer.copy_file('sou','spfilerac.ora','des','aa.ora');
PL/SQL procedure successfully completed.
2. 从本地提取到ASMSQL> exec dbms_file_transfer.copy_file('des','aa.ora','des','test.ora');
PL/SQL procedure successfully completed.
SQL> exec dbms_file_transfer.copy_file('des','aa.ora','sou','test.ora');
PL/SQL procedure successfully completed.
二、利用Oracle XDB添加ftp
oracle@rac12c2:~> sqlplus "/as sysdba"
SQL*Plus: Release 12.1.0.1.0 Production on Wed Jul 16 14:21:34 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
SQL> @?/rdbms/admin/catxdbdbca.sql 7777 8888
SQL> select dbms_xdb.GETHTTPPORT() from dual;
DBMS_XDB.GETHTTPPORT()
----------------------
8888
1 row selected.
SQL> select dbms_xdb.GETFTPPORT() from dual;
DBMS_XDB.GETFTPPORT()
---------------------
7777
1 row selected.
grid@rac12c1:~> srvctl stop listener -n rac12c1
grid@rac12c1:~> srvctl stop listener -n rac12c2
grid@rac12c1:~> srvctl start listener -n rac12c1
grid@rac12c1:~> srvctl start listener -n rac12c2
grid@rac12c1:~> lsnrctl status
LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 16-JUL-2014 14:26:44
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.1.0.1.0 - Production
Start Date 16-JUL-2014 14:26:28
Uptime 0 days 0 hr. 0 min. 16 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/12.1.0/grid/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/rac12c1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.70.136.150)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.70.136.151)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac12c1)(PORT=8888))(Presentation=HTTP)(Session=RAW))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac12c1)(PORT=7777))(Presentation=FTP)(Session=RAW))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM1", status READY, has 2 handler(s) for this service...
Service "pdb_p2" has 1 instance(s).
Instance "rac1", status READY, has 1 handler(s) for this service...
Service "pdb_test" has 1 instance(s).
Instance "rac1", status READY, has 1 handler(s) for this service...
Service "rac" has 1 instance(s).
Instance "rac1", status READY, has 1 handler(s) for this service...
Service "racXDB" has 1 instance(s).
Instance "rac1", status READY, has 1 handler(s) for this service...
The command completed successfully
oracle@rac12c2:~> ftp rac12c2 7777
Connected to rac12c2.
220- rac12c2
Unauthorised use of this FTP server is prohibited and may be subject to civil and criminal prosecution.
220 rac12c2 FTP Server (Oracle XML DB/Oracle Database) ready.
Name (rac12c2:root): system
331 pass required for SYSTEM
Password:
230 SYSTEM logged in
Remote system type is Unix.
ftp> ls
229 Entering Extended Passive Mode (|||30180|)
150 ASCII Data Connection
drw-r--r-- 2 SYS oracle 0 MAY 24 12:06 dbfs
drw-r--r-- 2 SYS oracle 0 MAY 24 12:35 home
drw-r--r-- 2 SYS oracle 0 MAY 24 13:08 images
drw-r--r-- 2 SYS oracle 0 MAY 24 12:41 olap_data_security
drw-r--r-- 2 SYS oracle 0 MAY 24 12:06 public
drw-r--r-- 2 SYS oracle 0 MAY 24 12:06 sys
-rw-r--r-- 1 SYS oracle 0 JUL 16 06:21 xdbconfig.xml
drw-r--r-- 2 SYS oracle 0 MAY 24 12:41 xds
226 ASCII Transfer Complete
ftp> cd sys
250 CWD Command successful
ftp> ls
229 Entering Extended Passive Mode (|||40161|)
150 ASCII Data Connection
drw-r--r-- 2 SYS oracle 0 MAY 24 12:06 acloids
drw-r--r-- 2 SYS oracle 0 MAY 24 13:09 acls
drw-r--r-- 2 SYS oracle 0 MAY 24 12:06 apps
drw-r--r-- 2 SYS oracle 0 MAY 24 12:06 asm
drw-r--r-- 2 SYS oracle 0 MAY 24 12:06 log
drw-r--r-- 2 SYS oracle 0 MAY 24 12:06 oid
drw-r--r-- 2 SYS oracle 0 MAY 24 12:06 principals
drw-r--r-- 2 SYS oracle 0 MAY 24 12:06 schemas
drw-r--r-- 2 SYS oracle 0 MAY 24 12:06 version
drw-r--r-- 2 SYS oracle 0 MAY 24 12:06 workspaces
226 ASCII Transfer Complete
ftp> cd asm
250 CWD Command successful
ftp> ls
229 Entering Extended Passive Mode (|||14316|)
150 ASCII Data Connection
drw-r--r-- 2 SYS oracle 0 JUL 16 06:47 DATA
drw-r--r-- 2 SYS oracle 0 JUL 16 06:47 ASMDATA
226 ASCII Transfer Complete
ftp> cd data
250 CWD Command successful
ftp> ls
229 Entering Extended Passive Mode (|||26378|)
150 ASCII Data Connection
drw-r--r-- 2 SYS oracle 0 JUL 16 06:47 RAC
226 ASCII Transfer Complete
ftp> cd *
550- Error Response
ORA-31001: Invalid resource handle or path name "data/*"
ORA-15046: ASM file name '+data/*' is not in single-file creation form
ORA-15122: ASM file name '+data/*' contains an invalid file number
550 End Error Response
ftp> ls
229 Entering Extended Passive Mode (|||14152|)
150 ASCII Data Connection
drw-r--r-- 2 SYS oracle 0 JUL 16 06:47 RAC
226 ASCII Transfer Complete
ftp> cd rac
250 CWD Command successful
ftp> ls
229 Entering Extended Passive Mode (|||9076|)
150 ASCII Data Connection
drw-r--r-- 2 SYS oracle 0 JUL 16 06:47 PASSWORD
-rw-r--r-- 1 SYS oracle 7680 JUL 16 06:47 orapwrac
drw-r--r-- 2 SYS oracle 0 JUL 16 06:47 DATAFILE
drw-r--r-- 2 SYS oracle 0 JUL 16 06:47 CONTROLFILE
drw-r--r-- 2 SYS oracle 0 JUL 16 06:47 ONLINELOG
drw-r--r-- 2 SYS oracle 0 JUL 16 06:47 TEMPFILE
drw-r--r-- 2 SYS oracle 0 JUL 16 06:47 DD7C48AA5A4404A2E04325AAE80A403C
drw-r--r-- 2 SYS oracle 0 JUL 16 06:47 FDC35539888779E2E0439888460AB843
drw-r--r-- 2 SYS oracle 0 JUL 16 06:47 PARAMETERFILE
-rw-r--r-- 1 SYS oracle 4608 JUL 16 06:47 spfilerac.ora
drw-r--r-- 2 SYS oracle 0 JUL 16 06:47 FDCD4E40B54C0443E0439688460A4A04
drw-r--r-- 2 SYS oracle 0 JUL 16 06:47 ARCHIVELOG
drw-r--r-- 2 SYS oracle 0 JUL 16 06:47 FDE0F3731C1C7070E0439688460A270F
drw-r--r-- 2 SYS oracle 0 JUL 16 06:47 FDE19911118776AFE0439688460A0F97
-rw-r--r-- 1 SYS oracle 4608 JUL 16 06:47 test.ora
226 ASCII Transfer Complete
ftp> get test.ora
local: test.ora remote: test.ora
229 Entering Extended Passive Mode (|||23557|)
150 ASCII Data Connection
550- Error Response
ORA-31198: Mismatch in number of bytes transferred due to non-binary mode
550 End Error Response
4655 bytes received in 00:00 (340.23 KB/s)
ftp> !
oracle@rac12c2:~> ls -lrt
total 16
-rw-r----- 1 oracle asmadmin 4608 Jul 16 14:14 aa.ora
-rw-r----- 1 oracle asmadmin 4608 Jul 16 14:47 test.ora
oracle@rac12c2:~> date
Wed Jul 16 14:47:47 CST 2014
oracle@rac12c2:~> exit
ftp> put aa.ora
local: aa.ora remote: aa.ora
229 Entering Extended Passive Mode (|||25229|)
150 ASCII Data Connection
100% |*****************************************************************************************| 4655 31.93 MB/s --:-- ETA
226 ASCII Transfer Complete
4655 bytes sent in 00:00 (99.29 KB/s)
ftp>
注:Oracle用户必需具有DBA权限
三、ASM中cp命令,支持从本地与ASM间交互,但不支持所有文件
ASMCMD> cp /home/grid/aa.ora .
ASMCMD-8012: cannot determine file type for file
ORA-15056: additional error message
ORA-27046: file size is not a multiple of logical block size
Additional information: 1
ORA-06512: at "SYS.X$DBMS_DISKGROUP", line 373
ORA-06512: at line 3 (DBD ERROR: OCIStmtExecute)
ASMCMD> ls
ARCHIVELOG/
CONTROLFILE/
DATAFILE/
DD7C48AA5A4404A2E04325AAE80A403C/
FDC35539888779E2E0439888460AB843/
FDCD4E40B54C0443E0439688460A4A04/
FDE0F3731C1C7070E0439688460A270F/
FDE19911118776AFE0439688460A0F97/
ONLINELOG/
PARAMETERFILE/
PASSWORD/
TEMPFILE/
orapwrac
spfilerac.ora
test.ora
ASMCMD> cd CONTROLFILE
ASMCMD> ls
Current.257.852498191
ASMCMD> cp Current.257.852498191 /home/grid
copying +data/RAC/CONTROLFILE/Current.257.852498191 -> /home/grid/Current.257.852498191
ASMCMD> cp /home/grid/Current.257.852498191 control.bak
copying /home/grid/Current.257.852498191 -> +data/RAC/CONTROLFILE/control.bak
ASMCMD> exit
grid@rac12c1:~> ls
aa.ora Current.257.852498191 grid.rsp oradiag_grid test.ora
grid@rac12c1:~> asmcmd
ASMCMD> cd data
ASMCMD> ls
ASM/
RAC/
ASMCMD> cd rac
ASMCMD> ls
ARCHIVELOG/
CONTROLFILE/
DATAFILE/
DD7C48AA5A4404A2E04325AAE80A403C/
FDC35539888779E2E0439888460AB843/
FDCD4E40B54C0443E0439688460A4A04/
FDE0F3731C1C7070E0439688460A270F/
FDE19911118776AFE0439688460A0F97/
ONLINELOG/
PARAMETERFILE/
PASSWORD/
TEMPFILE/
orapwrac
spfilerac.ora
test.ora
ASMCMD> cd con*
ASMCMD> ls
Current.257.852498191
control.bak
ASMCMD> ls -l
Type Redund Striped Time Sys Name
CONTROLFILE UNPROT FINE JUL 17 08:00:00 Y Current.257.852498191
CONTROLFILE UNPROT FINE JUL 17 08:00:00 N control.bak => +DATA/ASM/CONTROLFILE/control.bak.277.853145299
ASMCMD>