若数据库用ASM文件系统进行管理,那么在文件下载、上传方面有些困难,即使使用了asmcmd工具,也没有类似cp的命令来复制其中的文件,于是oracle提供了ftp来实现一系列ASM文件的管理。
Using FTP with Oracle ASM Files
Oracle Automatic Storage Management (Oracle ASM) organizes database files into disk groups for simplified management and added benefits such as database mirroring and I/O balancing.Database administrators can use protocols and resource APIs to access Oracle ASM files in the Oracle XML DB repositoryvirtual folder/sys/asm
. All files in/sys/asm
are binary.
Typical uses are listing, copying, moving, creating, and deleting Oracle ASM files and folders.Example 28-1 is an example of navigating the Oracle ASM virtual folder and listing the files in a subfolder.
The structure of the Oracle ASM virtual folder, /sys/asm
, is described inChapter 21, "Accessing Oracle XML DB Repository Data". InExample 28-1, the disk groups are DATA
and RECOVERY
; the database name isMFG
; and the directories created for aliases aredbs
andtmp
. This example navigates to a subfolder, lists its files, and copies a file to the local file system.
要使用ftp必须先再监听内配置端口:
如:SQL> @$ORACLE_HOME/rdbms/admin/catxdbdbca.sql 7777 8888
用sys用户执行以上语句,后面的两个端口可以自己指定,7070是ftp端口,8080是web端口。
查看下监听:
oel57t1:oracle:rac2 > lsnrctl status
出现以下内容,表示配置成功:
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.0.241)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.0.51)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=OEL57t1)(PORT=7777))(Presentation=FTP)(Session=RAW))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=OEL57t1)(PORT=8888))(Presentation=HTTP)(Session=RAW))
Example 28-1 Navigating Oracle ASM Folders
ftp> open myhost 7777
ftp> user system
Password required for SYSTEM
Password: password
ftp> cd /sys/asm
ftp> ls
DATA
RECOVERY
ftp> cd DATA
ftp> ls
dbs
MFG
ftp> cd dbs
ftp> ls
t_dbl.f
t_axl.f
ftp> binary
ftp> get t_dbl.f, t_axl.f
ftp> put my_db2.f
In Example 28-1, after connecting to and logging onto database myhost
(first four lines), FTP methodscd
and ls
are used to navigate and list folders, respectively. When in folder/sys/asm/DATA/dbs
, FTP commandget
is used to copy filest_db1.f
and t_ax1.f
to the current folder of the local file system. Then, FTP commandput
is used to copy filemy_db2.f
from the local file system to folder/sys/asm/DATA/dbs
.
最常用的命令有:
ls 列出远程机的当前目录
cd 在远程机上改变工作目录
lcd 在本地机上改变工作目录
ascii 设置文件传输方式为ASCII模式
binary 设置文件传输方式为二进制模式
close 终止当前的ftp会话
hash 每次传输完数据缓冲区中的数据后就显示一个#号
get(mget) 从远程机传送指定文件到本地机
put(mput) 从本地机传送指定文件到远程机
open 连接远程ftp站点
bye 断开与远程机的连接并退出ftp
? 显示本地帮助信息
! 转到Shell中
ftp> ?
Commands may be abbreviated. Commands are:
! cr mdir proxy send
$ delete mget sendport site
account debug mkdir put size
append dir mls pwd status
ascii disconnect mode quit struct
bell form modtime quote system
binary get mput recv sunique
bye glob newer reget tenex
case hash nmap rstatus trace
ccc help nlist rhelp type
cd idle ntrans rename user
cdup image open reset umask
chmod lcd passive restart verbose
clear ls private rmdir ?
close macdef prompt runique
cprotect mdelete protect safe