Please see my other blog for Oracle EBusiness Suite Posts - EBMentors

Search This Blog

Note: All the posts are based on practical approach avoiding lengthy theory. All have been tested on some development servers. Please don’t test any post on production servers until you are sure.

Monday, July 29, 2013

12c: Using DBFS

Oracle 12c introduces HTTP/HTTPS, FTP and WebDAV access to DBFS via the "/dbfs" virtual directory in the XML DB repository.


Setup
1- Create a tablespace to hold the file system.

C:\Users\inam.HOME>set oracle_sid=or12c
C:\Users\inam.HOME>sqlplus / as sysdba
SQL> CREATE TABLESPACE tsdbfs DATAFILE 'D:\app\Inam\oradata\or12c\dbfs01.dbf' SIZE 1M AUTOEXTEND ON NEXT 1M;

Tablespace created.

2- Create a user, grant DBFS_ROLE to the user and make sure it has a quota on the tablespace. Trying to create a file system from the SYS user fails, so it must be done via another user.

SQL> CREATE USER c##udbfs IDENTIFIED BY udbfs
2 DEFAULT TABLESPACE tsdbfs QUOTA UNLIMITED ON tsdbfs;


User created.

SQL> GRANT CREATE SESSION, RESOURCE, CREATE VIEW, DBFS_ROLE TO c##udbfs;

Grant succeeded.
SQL> exit
3- Create the file system in tablespace by running the "dbfs_create_filesystem.sql" script as the test user (C##UDBFS). The script accepts two parameters identifying the tablespace and file system name.

C:\Users\inam.HOME>sqlplus c##udbfs/udbfs

SQL> @D:\app\Inam\product\12.1.0\dbhome_1\RDBMS\ADMIN\dbfs_create_filesystem.sql tsdbfs dbfs_stage
No errors.
--------
CREATE STORE:
begin dbms_dbfs_sfs.createFilesystem(store_name => 'dbfs_stage', tbl_name =>
'dbfs_stage', tbl_tbs => 'tsdbfs', lob_tbs => 'tsdbfs', do_partition => false,
partition_key => 1, do_compress => false, compression => '', do_dedup => false,
do_encrypt => false); end;
--------
REGISTER STORE:
begin dbms_dbfs_content.registerStore(store_name=> 'dbfs_stage', provider_name
=> 'sample1', provider_package => 'dbms_dbfs_sfs'); end;
--------
MOUNT STORE:
begin dbms_dbfs_content.mountStore(store_name=>'dbfs_stage',
store_mount=>'dbfs_stage'); end;
--------
CHMOD STORE:
declare m integer; begin m := dbms_fuse.fs_chmod('/dbfs_stage', 16895); end;
No errors.
SQL>


4- Access using HTTP and HTTPS. Oracle 12c automatically enables read-only access to the DBFS file systems via the "/dbfs" virtual directory in the XML DB repository.

Check the HTTPS port is configured on your server.
SQL> SELECT DBMS_XDB_CONFIG.gethttpsport FROM dual;

GETHTTPSPORT
------------
5500

You can set the desired port using the following command (using sys).

SQL> EXEC DBMS_XDB_CONFIG.sethttpsport(5500);

PL/SQL procedure successfully completed.

The DBFS file system should now be visible using the following style of URL.
https://inam-pc:5500/dbfs





5- Access FTP, Oracle 12c automatically enables FTP access to the DBFS file systems via the "/dbfs" virtual directory in the XML DB repository. set the port if it is not set already.

SQL> SELECT DBMS_XDB_CONFIG.getftpport FROM dual;

GETFTPPORT
----------
0

SQL> EXEC DBMS_XDB_CONFIG.setftpport(4000); -- using sys

PL/SQL procedure successfully completed.

The DBFS file system will now be available using any FTP client using the host:port combination you have specified, along with the credentials of the owner of the file system.

No comments: