[ Team LiB ] Previous Section Next Section

Cache File Systems

You can use CacheFS to improve NFS server performance and scalability by reducing server and network load. CacheFS is designed as a layered file system that enables the system to cache one file system on another. In an NFS environment, CacheFS enables you to have more NFS clients for each NFS server because each client can cache NFS information, thus reducing the load on the NFS server. CacheFS improves performance for clients on slow links such as Point-to-Point Protocol (PPP).

Understanding CacheFS

With CacheFS you can enable a client system to cache a file system from a server. Initial access to the file system may seem slow, but subsequent uses of the same file by the user are faster. Typically, you would cache an NFS or HSFS file system. You create cache file systems individually on each client system that needs improved NFS performance.

NOTE. CacheFS does not support caching of the root (/) and /usr file systems.


  1. On the client system, use the cfsadmin(1M) command to create a cache so that file systems you specify to be mounted in the cache can be accessed by the user locally instead of across the network. To prevent conflicts within the CacheFS software, after you have created the cache you should not perform any operations within the cache directory on the client system.

  2. On the client, create a mount point at which the file system from the server—called the back file system—is mounted.

  3. Note the name of the server and path to the back file system you want to cache. The format is server: back-filesystem.

  4. Mount a file system in a cache by using the mount command on the client, adding an entry to the client's /etc/vfstab file, or using the automounter to automount the file system.

After you have completed the setup of the CacheFS, files are dynamically placed in the cache as the user accesses them.

NOTE. You can mount only file systems that are shared from the server in question. Refer to the share (1M) manual page for more information or see "Sharing Files from a Server" on page 207.


Creating a Cache

Use the following steps on a client system to create a cache.

  1. Decide what name you want to use for the cache directory.

  2. On the client system, become superuser.

  3. Type cfsadmin -c cache-directory and press Return.

In the following example, a cache directory named cachefile is created in the /local directory.


oak% su
# cfsadmin -c /local/cachedir
#



Specifying a File System to Be Mounted in the Cache

You can specify file systems to be mounted through the cache so that users can locally access files in the cache file system you create. You can specify the file systems to be cached in three ways.

  • Using the mount(1M) command on the client system. When you use the mount command, the files must be mounted from the command line every time the system is rebooted.

  • Editing the /etc/vfstab file on the client system. When you add an entry to the /etc/vfstab file, the specified files are available for caching even when the system is rebooted.

  • Using the automounter. When you modify automounter maps, the specified files are available for caching even when the system is rebooted.

Creating a Mount Point

Regardless of the mechanism you choose to mount the file system, you need to create a mount point on the client system where CacheFS mounts the files. The mounted files are then cached in the cache directory that you created.

Type mkdir mount-point and press Return. In the following example, a mount point named /cachemount is created.


# mkdir /cachemount
#


Specifying a File System (mount)

You provide the following parameters for the mount command.

  • The file system type of the back file system on the server: backfstype= fstype. The value for fstype can be either nfs or hsfs.

  • The name of the cache directory on the client system: cachedir= cache-directory.

  • The name of the back file system on the server: server: back-filesystem.

  • The mount point on the client system: mount-point.

Use the following steps to mount a cache file system from a command line.

  1. On the client system, become superuser.

  2. All on one line, type mount -F cachefs -o backfstype= fstype, cachedir= cache-directory [ , options] back-file-system mount-point and press Return.

  3. Type cachefsstat mount-point and press Return.

    The output from this command verifies that the cache you created was mounted.

The following example creates a cache directory named /local/cachedir, creates a mount point named /usr/local, and mounts the NFS file system castle:/export/local as a cached file system named /usr/local in the cache named /local/cachedir.


paperbark% su
Password:
# mkdir /usr/local
# mkdir /local
# cfsadmin -c /local/cachedir
# mount -F cachefs -o backfstype=nfs,cachedir=/local/cachedir castle:/export/local
  /usr/local
# cachefsstat /usr/local

   /usr/local

              cache hit rate:  100%   (0 hits, 0 misses)
          consistency checks:    0    (0 pass, 0 fail)
                    modifies:    0
          garbage collection:    0
#

If the file system was not mounted in the cache, an error message similar to the following is displayed.


# cachefsstat /local
cachefsstat: /local not a cachefs mountpoint
#


Specifying a File System (/etc/vfstab File)

When you add a cache file system to the /etc/vfstab file on the client system, the back file system remains available to users as a cached file system.

When you have created the cache directory and the mount point, use the following steps to mount a cache file system from the /etc/vfstab file.

  1. On the client system, become superuser.

  2. Using an editor, add the following line to the /etc/vfstab file.

    
    
    /dev/dsk/device-name /dev/rdsk/ device-name/mount-pointcachefs 2 yes -
    
    
    
  3. Type mount mount-point and press Return or reboot the system to mount the file system.

graphics/new.gif

The following example mounts the /export /local directory from the remote system castle with the back file system /local/cachedir on the cache directory /usr/local.


castle:/export/local /local/cachedir /usr/local 7 yes
   local-access,bg,nosuid,demandconst,backfstype=nfs,cachedir=/usr/local


Specifying a File System (Automounter Map)

You add a cache file system to the auto_direct automounter map by specifying the -fstype=cachefs option to mount. Note that you also specify the CacheFS mount options (for example, backfstype and cachedir). Refer to the automount(1M) manual page for more information about automount maps or to the Solaris Advanced System Administrator's Guide, available from Sun Microsystems Press.

Use the following steps to specify a cache file system in the automounter map.

  1. Become superuser.

  2. Using an editor, add the following line to the auto_direct map.

    
    
    /mount-point -fstype=cachefs,cachedir=/ directory, backfstype=nfs
      server:/ file-system
    
    
    
  3. graphics/new.gif Using an editor, add /- to the auto_master map.

    The /- entry is a pointer to check the auto_direct map.

  4. Reboot the system.

  5. Type cd files-system and press Return.

  6. Type ls files-system and press Return.

    Review the output of the ls command to verify that the entry was made correctly.

Maintaining Caches

After you set up cache file systems, you can perform the following maintenance tasks on them.

  • Modify file systems in the cache by unmounting, deleting, re-creating, and remounting the cache.

  • Display cache information.

  • Check cache consistency.

  • Delete a file system from the cache.

  • Check cached file system integrity.

If you are using the /etc/vfstab file to mount file systems, you modify the cache by editing the file system options in the /etc/vfstab file. If you are using the automounter, you modify the cache by editing the file system options in the automounter maps.

Table 52 lists the commands that you can use to perform cache maintenance. Refer to the appropriate manual page for more details.

Table 52. Commands for Maintaining Cache File Systems

Command

Description

cfsadmin

Display information about cached file systems, delete a cached file system from a specified cache, and specify consistency checking on demand. See the cfsadmin(1M) manual page for more information.

cachefspack

Create packing lists that specify individual files and directories that you want packed in the cache. A packing list contains files or directories to be packed in the cache. If a directory is in the packing list, all its subdirectories and files are also packed. See the cachefspack(1M) manual page for more information.

cachefslog

Specify the location of a CacheFS log file. This command also displays where statistics are currently being logged and enables you to halt logging. See the cachefslog(1M) manual page for more information.

cachefswssize

Interpret the log file to give a recommended cache size. See the cachefsswsize(1M) manual page for more information.

cachefsstat

Display statistical information about a specific file system or all cached file systems. The information provided in the output of this command is taken directly from the cache. See the cachefsstat(1M) manual page for more information.

fsck -F cachefs {-m} {-o noclean} cache-directory

 

Check the integrity of cached file systems and automatically correct problems without requiring user interaction. See the fsck_cachefs(1M) manual page for more information.

    [ Team LiB ] Previous Section Next Section