22 DBFS Access Using OFS

You can access Database File System (DBFS) using the Oracle File Server (OFS) process.

This chapter provides details about how OFS uses OFSD, a dedicated background process, to manage DBFS. It also provides details about how you can access and manage DBFS.

To access a newly created DBFS across multiple nodes where there are no Oracle Client installations, use OFS to NFS mount the file system. In the absence of an Oracle Client installation, use OFS to mount the newly created DBFS to NFS and use it across multiple nodes. All file system requests are served by threads in the OFS background process.

22.1 About OFS

Oracle File Server (OFS) addresses the need to store PDB specific scripts, logs, trace files and other files produced by running an application in the database.

Additionally, you can use OFS for the following tasks:

  • As a staging area where you can host the source data before it is loaded into database tables.
  • To store import or export files from Oracle Data Pump process.

Ensure that you do not place core database files such as data, redo, archive log files, and database trace file on OFS as this can produce a dependency cycle and cause the system to hang. Similarly, the diagnostic_dest initialization parameter that sets the location of the automatic diagnostic repository should not point to a directory inside OFS.

OFS provides methods and procedures to allow you to create a Database file system using storage that is part of the PDB. You can mount the created file system, unmount it like any other Unix file system using PL/SQL procedures, and destroy the file system when it is no longer in use. When the PDB is destroyed, the file system is also destroyed, which frees up the underlying storage space.

22.2 About Oracle File Server Process

OFS manages the database file system using a non-fatal and dedicated background process called Oracle File Server Deamon (OFSD).

For more information about background process, see Background Processes in the Database Reference guide.

When an instance starts, the OFSD process gets spawned on operating system platforms, such as Linux, where OFS is supported. OFSD is multi-threaded and non-fatal. It serves both file system management requests and file requests from each mounted file system.

The centralized server background process model of OFS allows multiple file systems to be mounted and accessed using a limited set of server threads. It allows better resource sharing and a linear scalability with new file server threads created on demand. Both memory and CPU used by these threads are controlled through system wide parameters set in the RDBMS instance.

OFSD process starts two types of threads: receiver thread and worker thread. The receiver thread receives requests from the mounted file system. The name of this thread name is similar to of01. The requests received by this thread are placed in a submit queue which is served by different worker threads. The submit queue is hash partitioned to efficiently distribute the incoming requests across all the worker threads. By default, OFSD starts 3 worker threads. You can update the value of the OFS_THREADS parameter to increase the number of worker thread.

OFSD process

OFSD supports these 2 types of file systems: DBFS and OFS.

Use the DBMS_FS PL/SQL procedures to create, mount, and work with the file systems managed by the OFSD process.

OFSD uses a pool of worker threads to serve requests from multiple file systems that are mounted on the instance. Use V$OFSMOUNT to query the mounted file systems. The response that is returned is specific to each PDB. It lists only the file systems that are mounted in the specified PDB.

22.3 OFS Client Interface

The OFS interface includes views and procedures that support OFS operations.

22.3.1 DBMS_FS Package

The DBMS_FS package enables users to perform operations on Oracle file system (make, mount, unmount and destroy) in the Oracle database.

See Also:

Oracle Database PL/SQL Packages and Types Reference for more information about Oracle OFS procedures.

The following example illustrates the use of DBMS_FS package.

BEGIN
 DBMS_FS.MAKE_ORACLE_FS (
  fstype           => 'dbfs',
  fsname           => 'dbfs_fs1',
  mount_options    => 'TABLESPACE=dbfs_fs1_tbspc');
END;
/
BEGIN
 DBMS_FS.MOUNT_ORACLE_FS (
  fstype           => 'dbfs',                              
  fsname           => 'dbfs_fs1',                              
  mount_point      => '/oracle/dbfs/testfs',                              
  mount_options    => 'default_permissions, allow_other, persist'); 
END;
/
/************** Now you can access the file system. All the FS operations go here ***************/

BEGIN
 DBMS_FS.UNMOUNT_ORACLE_FS (
  fsname           => 'dbfs_fs1',                              
  mount_point      => '/oracle/dbfs/testfs',
  mount_options    => 'force'); 
END;
/
BEGIN
 DBMS_FS.DESTROY_ORACLE_FS (
  fstype           => 'dbfs',
  fsname           => 'dbfs_fs1');
END;
/

22.3.2 Views for OFS

The views that support OFS operations start with V$OFS .

See Also:

Oracle Database Reference for the columns and data types of these views.

22.4 Managing DBFS Locally Using FUSE

Understand how you can manage DBFS using Filesystem in User Space (FUSE).

The FUSE interface in the Linux kernel makes the file systems available to the operating system processes. After mounting the file system, you can export it, and then NFS mount it on other nodes where client applications can access this file system.

22.4.1 Configuring FUSE

OFSD exposes the database file system through FUSE. Before using OFSD to mount the database file systems, you must install and configure the FUSE module.

If you are running your database instance in a Compute node, configure the FUSE module in that node. The file system gets mounted and is visible through a mounted path on the compute node. In a RAC configuration, configure FUSE in each node, so that the OFS file systems can be mounted independently in each node.
To configure the FUSE module in Cloud or on-premises environment, where the database instance is running:
  1. Set read and execute permissions for an Oracle user to use the FUSE executable file, fusermount.
    sudo chmod o+rx /usr/bin/fusermount
    Use the fusermount file to mount and unmount the FUSE user mode file systems.
  2. Set the setuid bit on the fusermount file to permit an Oracle user to mount file systems.
    sudo chmod u+s /usr/bin/fusermount
  3. Permit other users to access the mounted file system.
    sudo sh -c ''echo user_allow_other >> /etc/fuse.conf''
  4. Optional. By default, the maximum number of file systems that you can mount using FUSE is 1000. If you are running a large number of PDBs and need to configure a separate file system for each PDB, then run the following command to increase the number of file systems that can be mounted using FUSE. The following command increases the number of file systems that can be mounted using FUSE to 4000.
    sudo sh -c ''echo mount_max=4000 >> /etc/fuse.conf''
  5. Allow all users to read the fuse.conf file, so that the Oracle process can read this file at run time.
    sudo chmod a+r /etc/fuse.conf

22.4.2 Accessing OFS in Cloud

To access files from an OFS mounted on any Cloud environment, you must perform additional steps to configure the environment.

To access files in an OFS mount in the Cloud environment, you may need to perform additional configuration. It may not be possible to export the OFS mount point from database node to client node due to security reasons. This may hinder client applications from accessing the OFS files through operating system commands and utilities and the OFS mount path may not be available to access using system calls. In such situations, Oracle recommends that you use the utl_file package to access files in the OFS mount. For information about UTL file package, see Summary of UTL_FILE Subprograms in PL/SQL Packages and Types Reference.

To configure the environment so that client applications in Cloud can access files in an OFS:
  1. Create a directory object using the OFS mount path.

    The following sample code displays how you can create a directory object called pdb1_ofsdir when /u03/dbfs/<pdbid>/data is the OFS mount directory on the db node.

    CREATE DIRECTORY pdb1_ofsdir AS '/u03/dbfs/<pdbid>/data/';
  2. Grant access to the user to access the directory object.

    For more information on creating a directory object and setting access permissions on it, see CREATE DIRECTORY in PL/SQL Packages and Types Reference.

Do not access the OFS files by directly querying or modifying the DBFS tables. Do not use dbfs_client when the DBFS file system is mounted through OFS or else it could lead to metadata and data inconsistency. To access the OFS files, use the UTL_FILE package in addition to the procedures listed in the DBMS_FS package. See FS_EXISTS and LIST_FILES in PL/SQL Packages and Types Reference.