Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
NFS Services Administrator’s Guide: HP-UX 11i version 3 > Chapter 4 Configuring and Administering a Cache Filesystem

Configuring and Administering CacheFS

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

You can use CacheFS to cache both manually mounted NFS filesystems or automatically mounted NFS filesystems. All CacheFS operations, except displaying CacheFS statistics, require superuser permissions.

This section describes the tasks to configure and administer CacheFS:

Creating a CacheFS Cache

This section describes how to configure a cache directory in a local filesystem. To configure a local filesystem as a cache directory, follow these steps:

  1. Log in to the NFS client system as superuser.

  2. Ensure that the disk partition containing the cache has enough space for the cache directory. If does not have enough space, configure and mount a new HFS or VxFS filesystem to be used as the front filesystem, where data will be cached.

  3. To create a cache directory, enter the following command:

    cfsadmin -c cache_directory

    For example to create a CacheFS directory called /disk2/cache using the following command:

    cfsadmin -c /disk2/cache

    This creates a new directory called cache under the /disk2 directory.

CacheFS allows more than one filesystem to be cached in the same cache. You need not create a separate cache directory for each CacheFS mount.

Mounting an NFS Filesystem Using CacheFS

This section describes how to mount an NFS filesystem using CacheFS. The syntax for mounting an NFS filesystem using CacheFS is as follows:

mount [-F cachefs] [-rqOV] -o backfstype=file_system_type 
   [specific_options]  resource mount_point

Consider the following example where the /opt/frame directory is going to be NFS-mounted from the NFS server nfsserver to the local /opt/cframe directory.

To mount the example NFS filesystem using CacheFS manually, enter the following command on an NFS client system:

mount -F cachefs -o backfstype=nfs, \
cachedir=/disk2/cache    nfsserver:/opt/frame /opt/cframe

The /opt/frame directory can now be accessed like any other mounted filesystem. When data in /opt/cframe is referenced, it is copied into /disk2/cache.

To mount an NFS filesystem using CacheFS automatically at system boot, add the following line to the /etc/fstab file:

nfsserver:/opt/frame /opt/cframe cachefs \
backfstype=nfs,cachedir=/disk2/cache 0 0 

When data in the /opt/cframe directory is accessed for the first time, the requested data is retrieved across the network from the NFS server. A copy of this data is then placed in the local cache directory. All future accesses to the data will be served from the local cache, assuming the data has not been modified on the server.

When a CacheFS filesystem is mounted, a file or CacheId is created in the cache directory for it. The name of the file is of the form:

NFS_server:mounted_directory:mount-point

Where each “/” is replaced by “_”. The CacheId is unique for each CacheFS mount-point and is a link into the part of a cache directory assigned to that mount-point.

For example:

NFSserver				: nfss04
Mounted directory : /exp
Mount-point				: /mnt
symbolic name			: nfss04:_exp:_mnt

Users can explicitly specify the CacheId using the cache ID mount option. If you do not specify a cache ID, CacheFS constructs one.

Switching Mount Options

CacheFS is commonly used when the data on the server is read a number of times and rarely modified. For example, consider a filesystem that is initially mounted with the noconst option. The mount option has been chosen because the data on the server is rarely modified. If for some reason the data on the server is modified, you may want to change the mount options. In earlier versions of HP-UX, if you mounted a filesystem with certain mount options, you could not change those mount options without deleting or recreating the cache. Starting with HP-UX 11i v3, you can switch mount options without deleting and recreating the cache.

To change the mount option from noconst to the default option, without deleting or rebuilding the cache, enter the following commands:

umount /mnt1

mount -F cachefs -o backfstype=nfs,cachedir=/cache
CFS1:/tmp  /mnt1    

To change the mount option from default to weakconst after unmounting, enter the following command:

mount -F cachefs -o backfstype=nfs,cachedir=/cache,weakconst
CFS2:/tmp  /mnt1    

For more information on the various mount options of the CacheFS filesystem, see mount_cachefs(1M).

Automounting a Filesystem Using CacheFS

This section describes how to automount a filesystem using CacheFS.

Before you automount an NFS filesystem using CacheFS, you must configure a directory in a local filesystem as cache. For more information on how to configure a directory as cache, see “Creating a CacheFS Cache”.

To automount a filesystem using CacheFS, follow these steps:

  1. Add a line to the appropriate AutoFS direct or indirect map, as in the following examples:

    Example 1

    Direct map example:

    /tmp/dist -nosuid,fstype=cachefs,backfstype=nfs, \
    cachedir=/disk2/cache  distserver:/export/dist

    Example 2

    Indirect map example:

    proj1  -nosuid,fstype=cachefs,backfstype=nfs, \
    	                     cachedir=/disk2/cache   \
    				/src  testbox1:/export/proj1/src      \
           /data  testbox2:/export/proj1/data	      
  2. If you have modified a direct map, enter the following command on each NFS client that uses the map, to force AutoFS to reread its maps:

    /usr/sbin/automount
    NOTE: If you have modified an indirect map, the changes are read immediately. AutoFS need not be restarted and forced to reread it maps.

You can specify caching in an NIS AutoFS map, or by using LDAP, only if all the clients who use the map have their caching directory set up in the same location (/disk2/cache in the examples).

Enabling Logging in CacheFS

This section describes how you can enable logging in CacheFS. You can use the cachefslog command to enable logging for a CacheFS mount-point. Enabling the logging functionality may have a performance impact on the operations performed for all the CacheFS mount-points that are using the same cache directory.

To enable CacheFS logging, follow these steps:

  1. Log in as superuser.

  2. To enable logging for a CacheFS mount-point, say /cfs_mnt1, enter the following command:

    cachefslog -f /tmp/logfile /cfs_mnt1
    

    Where:

    /tmp/logfile

    Specifies the logfile to be used.

    NOTE: When multiple mount-points use the same cache directory, enabling logging for one CacheFS mount-point automatically enables logging for all the other mount-points.
  3. To verify if logging is enabled for /cfs_mnt1, enter the following command:

    cachefslog /cfs_mnt1

    If logging has been enabled, the logfile is displayed.

Disabling Logging in CacheFS

You can use the cachefslog command to halt or disable logging for a CacheFS mount-point.

To disable CacheFS logging, follow these steps:

  1. Log in as superuser.

  2. To halt or disable logging for the same CacheFS mount-point, /cfs_mnt1, enter the following command:

    cachefslog -h /cfs_mnt1
    
    NOTE: When multiple mount-points use the same cache directory, disabling logging for one CacheFS mount-point automatically disables logging for all the other mount-points.
  3. To verify if logging has been halted or disabled for /cfs_mnt1, enter the following command:

    cachefslog /cfs_mnt1

    If logging has not been enabled or if it has been halted, the following message is displayed:

    not logged: /cfs_mnt1

Caching a Complete Binary

CacheFS is designed to work best with NFS filesystems that contain stable read-only data. One of the most common uses of CacheFS is managing application binaries. These are typically read-only and are rarely ever modified. They are modified when new versions of the application are installed or a patch containing a modified binary is installed. The rpages mount option enables you to cache a complete binary file.

When an application in a cached NFS filesystem is executed, CacheFS checks if the binary file is cached. If it is not cached, then the client reads the entire binary file and automatically caches it. If the rpages mount option is not used, only the accessed portion of the binary is cached. Using the rpages mount option causes slower initial load times, but subsequent executions of the application binary are significantly faster.

For example, to load the netscape binary, do the following:

  1. To create a cache, if it does not exist, enter the following command:

    cfsadmin -c  /cachedir
  2. To mount the cache filesystem, enter the following command:

    mount -F cachefs -o backfstype=nfs,rpages,cachedir=/cachedir \
    nfsserver:/opt/netscape  /opt/netscape
  3. To run the netscape binary in /opt/netscape, enter the following command:

    /opt/netscape/netscape

    The netscape binary and the files that netscape needs are cached and populated in the cache directory /cachedir.

For more information on the rpages mount option, see mount_cachefs(1M).

Packing a Cached Filesystem

Starting with HP-UX 11i v3, the cachefspack command is introduced to provide greater control over the cache. This command enables you to specify files and directories to be loaded, or packed, in the cache. It also ensures that the current copies are always available in the cache.

You can pack files using one of the following methods:

  • Specifying the files or directories to be packed

    Enter the following command to pack a file in the cache:

    cachefspack -p filename

    where:

    -p

    Packs the file or files in the cache.

    filename

    Name of the file or directory that is to be packed in the cache.

    NOTE: When you pack a directory, all files in that directory, subdirectories, and files in the subdirectories are packed. For instance, consider a directory /dir1 that contains two subdirectories /subdir1, and /subdir2, as well as two files test1, and test2. When you pack /dir1, /subdir1, /subdir2, test1, and test2 are packed.
  • Using the packing-list file

    A packing-list file is an ASCII file that contains a list of files and directories that are to be pre-packed in the cache. Creating a packing-list file saves time, because you need not individually pack each file. It also enables you to access the BASE, LIST, and IGNORE options that are not available from the command-line interface. The packing-list file can be updated or removed when required.

    To pack files in the cache using the packing-list file, follow these steps:

    1. Create the packing-list file, if it does not exist. The file can be created using a text editor.

      NOTE: For information on the format and rules governing the creation of a packing-list file, see packingrules(4).
    2. Add an entry to the file. A sample of the packing-list file consists of the following entries:

      BASE /net/server/share/home/casey
      LIST work
      LIST m/sentitems
      IGNORE core *.o *.bak 

      where:

      BASE

      Specifies the path to the directory that contains the files to pack.

      LIST

      Specifies the files to pack within the directory.

      IGNORE

      Specifies the files or file types or both that you do not want to pack in the cache.

    3. To pack the files specified in the packing-list file enter the following command:

      cachefspack -f packing-list 

      where:

      packing-list

      Specifies the name of the packing-list file.

      The files specified in the packing list are now packed in the cache.

You can unpack files that you no longer require, using one of the following methods:

  • Using the -u option

    To unpack a specific packed file or files from the cache directory, enter the following command:

    cachefspack -u filename

    where:

    -u

    Specifies that certain files are to be unpacked.

    filename

    Specifies the file to unpack.

  • Using the -U option

    To unpack all the packed files in the cache, enter the following command:

    cachefspack -U cache-dir

    where:

    -U

    Specifies that you want to unpack all the packed files in the cache.

    cache-dir

    Specifies the cache directory that is to be unpacked.

    For more information about the cachefspack command, see cachefspack(1M).

Forcing a Cache Consistency Check

CacheFS periodically checks the consistency of files when a user attempts to access the file stored in the cache. This ensures that the cached directories and files are up to date with the back filesystem. To check consistency, CacheFS compares the time stamp of the cached file with the time stamp of the corresponding file on the back filesystem. If CacheFS detects a time difference, the cached data is purged, and the updated data is retrieved from the back filesystem. If you have not accessed any files, checks are not performed. Use of this option does not result in a sudden “storm” of consistency checks.

Forcing a Consistency Check for a Specific Mount-Point

By default, CacheFS verifies the consistency of the cached contents against the back filesystem every 30 seconds. However, if you want to disable these automatic consistency checks and instead perform manual consistency checks you can mount the CacheFS filesystem with the demandconst option, and then use the cfsadmin command to force a consistency check. To force a consistency check on a specific mount-point, enter the following command:

cfsadmin -s mount_point
IMPORTANT: The -s option works only if CacheFS is mounted with the demandconst option. For information and an example on how to switch between mount options, see “Switching Mount Options”

Forcing a Consistency Check for all the Mount-Points

To request for a consistency check on all the mount-points, enter the following command:

cfsadmin -s all

For information on cfsadmin options, see cfsadmin(1M).

Unmounting a Cache Filesystem

To unmount a Cache filesystem, enter the following command:

umount mount-point

where:

mount-point

Specifies the CacheFS mount-point that you want to unmount.

Checking the Integrity of a Cache

You can use the fsck command to check the integrity of a cache. The CacheFS version of the fsck command checks the integrity of the cache and automatically corrects any CacheFS problems that it encounters. The CacheFS fsck command is run automatically by the mount command when the cache directory is accessed for the first time after a system reboot. The command is run either during system bootup if there is an entry in /etc/fstab, or the first time the cache directory is referenced as part of the mount operation.

To manually check the integrity of a cache, enter the following command:

fsck_cachefs -F cachefs [-m | -o noclean]
cache-directory

where:

-m

Specifies that the cache must be checked without making any repairs.

noclean

Forces a check on the CacheFS filesystems.

cache-directory

Specifies the name of the directory where the cache resides.

The cache directory must not be in use while performing a cache integrity check using the fsck command. To list the CacheFS mount-points that are using a specific cache directory, for example, /disk2/cache, enter the following command:

mount | grep -w "cachedir=/disk2/cache" | awk '{print $1}

An output similar to the following is displayed if CacheFS mount-points are using the cache directory:

/cfs_mnt1
/cfs_mnt2

You must now unmount these mount-points before you check the integrity of a cache. For information on how to unmount a cache mount-point, see “Unmounting a Cache Filesystem”.

For more information on the fsck_cachefs command of CacheFS, see fsck_cachefs(1M).

Updating Resource Parameters

Each cache has a set of parameters that determines its structure and how it behaves. When a cache directory is created, it gets created with default values for the resource parameters. Table 4-1 lists the various resource parameters and their default values.

Table 4-1 CacheFS Resource Parameters

CacheFS Resource ParameterDefault Value
maxblocks90
minblocks0
threshblocks85
maxfiles90
minfiles0
threshfiles85

 

For more information on the resource parameters, see cfsadmin(1M).

You can update the resource parameters using the -u option of the cfsadmin command.

NOTE: All filesystems in the cache directory must be unmounted when you use the -u option. Changes will be effective the next time you mount any filesystem in the specified cache directory.

For example, to update the resource parameter, maxblocks, you must first create the cache, and then modify the parameter as follows:

cfsadmin -c /cache
cfsadmin -u -o maxblocks=95 /cache

This updates the value of maxblocks from 90 which is the default value to 95.

Deleting a Cache Directory

To delete a cache directory that is no longer required you must use the cfsadmin command. The syntax to delete the cache directory is as follows:

cfsadmin -d {cacheID | all} cache-directory

where:

cacheID

Specifies the name of the cache filesystem.

all

Specifies that all cached filesystems in the cache-directory are to be deleted.

cache-directory

Specifies the name of the cache directory where the cache resides.

NOTE: The cache directory must not be in use when attempting to delete a cached filesystem or the cache directory.

To delete the cache directory, follow these steps:

  1. To identify the Cache ID of each of the cached filesystems, enter the following command:

    cfsadmin -l cache-directory

    An output similar to the following is displayed:

    cfsadmin: list cache FS information
    maxblocks     90%
    minblocks      0%   
    threshblocks  85%   
    maxfiles      91%   
    minfiles       0%   
    threshfiles   85%   
    maxfilesize    3MB
    srv01:_tmp:_mnt
    srv01:_tmp:_mnt1

    At the end of the output, the Cache IDs of all the cached filesystems that are using this cache directory are displayed. In this example, the/tmp directory of srv01 is mounted on mnt and mnt1.

  2. To list the CacheFS mount-points that are using the cache directory, enter the following command:

    mount | grep -w "cachedir=/disk2/cache" | awk '{print $1}'

    An output similar to the following is displayed if CacheFS mount-points are using the cache directory:

    /mnt
    /mnt1
  3. To unmount the CacheFS mount-points, /_mnt, and /_mnt1, enter the following commands:

    umount /mnt
    umount /mnt1
  4. To delete the CacheFS filesystem corresponding to the Cache ID from the specified cache directory, enter the following command:

    cfsadmin -d CacheID cache-directory

  5. To verify if the CacheFS filesystem is deleted, enter the following command:

    cfsadmin -l cache-directory

    An output similar to the following is displayed:

    cfsadmin: list cache FS information
    maxblocks     90% 
    minblocks      0%
    threshblocks  85%
    maxfiles      91%  
    minfiles       0%   
    threshfiles   85%   
    maxfilesize    3MB
    srv01:_tmp:_mnt1

    In this example, the filesystem with CacheID srv01:_tmp:_mnt filesystem has been deleted.

To delete a cache directory and all the CacheFS filesystems in that directory, enter the following command:

cfsadmin -d all cache-directory

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 2008 Hewlett-Packard Development Company, L.P.