Monday, April 4, 2011

Get ASM Files Using LFTP

If a database has XML DB set and ftp port configured then lftp could be used to get files out of the ASM.
FTP port could be configured with
SQL> @$ORACLE_HOME/rdbms/admin/catxdbdbca.sql 7001 8001
7001 is the ftp port 
8001 is the http port
Listener status would display these ports
lsnrctl status
...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hostname)(PORT=7001))(Presentation=FTP)(Session=RAW))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hostname)(PORT=8001))(Presentation=HTTP)(Session=RAW))
...
To get a file for example an archive log file use
lftp rac4 -usystem,passwd -p7001 -e 'get /sys/asm/FLASH/RAC11G2/ARCHIVELOG/2011_04_02/thread_2_seq_472.390.747360023;exit;'
41125376 bytes transferred in 4 seconds (11.02M/s)
Here rac4 is the host on which the ASM instance is running, command could be executed from a remote node as well. Following -u is the username used to login into the system, in this case database's system user and comma separated by the password for system user. FTP port is specified with -p.

Without the exit at the end, after the file is transferred shell prompt will end up in the ftp prompt.

To remove the http and ftp ports get rid of the dispatcher parameter (as per 274508.1 Listener Issue: Removing XDB Handlers for HTTP and FTP Ports) or
conn / as sysdba
exec dbms_xdb.sethttpport(0);
exec dbms_xdb.setftpport(0);
alter system register;
More on Master Note for Oracle XML DB Protocols: FTP HTTP HTTPS WebDAV, APEX and Native Database Web Services [ID 1083991.1]

Apart from lftp ftp client such filezilla could be used to connect to the ftp port specified and get the files.