系统管理指南:设备和文件系统

压缩 CacheFS 文件系统

对于常规用途,CacheFS 软件在设置后自动运行,而不要求用户执行任何操作。仅对最新使用的文件进行高速缓存。利用压缩功能,通过确保始终在高速缓存中更新某些文件或目录,可以在管理高速缓存方面承担更主动的角色。

使用 cachefspack 命令可以指定要在高速缓存中装入的文件和目录。此命令确保这些文件的最新副本在高速缓存中是可用的。

压缩列表包含特定文件和目录的名称。压缩列表也可以包含其他压缩列表。需要在高速缓存中压缩多个项时,利用此功能就不必指定单独的文件和目录。

使用 -h 选项可以输出所有 cachefspack 选项的简短帮助摘要,如下所示:


$ cachefspack -h

Must select 1 and only 1 of the following 5 options

-d Display selected filenames

-i Display selected filenames packing status

-p Pack selected filenames

-u Unpack selected filenames

-U Unpack all files in directory 'dir'

-f Specify input file containing rules

-h Print usage information

-r Interpret strings in LIST rules as regular expressions

-s Strip './' from the beginning of a pattern name

-v Verbose option

files - a list of filenames to be packed/unpacked

Procedure如何在高速缓存中压缩文件

    在高速缓存中压缩文件。


    $ cachefspack -p filename
    
    -p

    指定要压缩一个或多个文件。此选项也是缺省选项。

    filename

    指定要在高速缓存中压缩的文件或目录的名称。指定目录时,也将压缩该目录的所有子目录。有关更多信息,请参见 cachefspack(1M)


示例 20–8 示例-在高速缓存中压缩文件

以下示例说明在高速缓存中压缩 projects 文件。


$ cachefspack -p projects

以下示例说明在高速缓存中压缩三个文件。


$ cachefspack -p projects updates master_plan

以下示例说明在高速缓存中压缩一个目录。


$ cachefspack -p /data/abc/bin

Procedure如何显示已压缩文件的信息

    显示已压缩文件的信息。


    $ cachefspack -i[v] cached-filename-or-directory
    
    -i

    指定希望查看有关已压缩文件的信息。

    -v

    是详细选项。

    cached-filename-or-directory

    指定要显示其信息的文件或目录的名称。


示例 20–9 显示已压缩文件的信息

以下示例说明已成功压缩 doc_file 文件。


$ cachefspack -i doc_file

cachefspack: file doc_file marked packed YES, packed YES

在以下示例中,/data/abc 目录包含 bin 子目录。bin 子目录包含以下三个文件:bigmedium small。虽然指定要压缩 bigsmall 文件,但是未压缩它们。成功压缩了 medium 文件。


$ cd /data/abc

$ cachefspack -i bin

.

.

.

cachefspack: file /bin/big marked packed YES, packed NO

cachefspack: file /bin/medium marked packed YES,

packed YES

cachefspack: file /bin/small marked packed YES,

packed NO

.

.

.

如果一起使用 -iv 选项,则可以获取有关是否已从高速缓存中清除指定的文件或目录的其他信息。例如:


$ cd /data/bin

FSCACHEPACK-4$ cachefspack -iv bin

.

.

.

cachefspack: file /bin/big marked packed YES, packed NO,

nocache YES

cachefspack: file /bin/medium marked packed YES,

packed YES, nocache NO

cachefspack: file /bin/small marked packed YES,

packed NO

nocache NO

.

.

.

此示例的最后一行说明,未从高速缓存中清除该目录的内容。


使用压缩列表

cachefspack 命令的一项功能是能够创建压缩列表。

压缩列表包含要在高速缓存中压缩的文件或目录。如果一个目录包含在压缩列表中,则也将压缩它的所有子目录和文件。

利用此功能,就可以节省必须指定要在高速缓存中压缩的每个单独文件的时间。

Procedure如何创建压缩列表

    使用 vi 创建压缩列表文件。

    压缩列表文件使用的格式与 filesync 命令的格式相同。有关更多信息,请参见 filesync(1)

    以下是压缩列表的两项功能:

    • 可以将压缩列表中的文件标识为正则表达式而不是字面上的文件名,便可不必指定每个单独的文件名。

    • 通过确保仅压缩您所拥有的那些文件,可以压缩共享目录中的文件。

    有关使用这些功能的更多信息,请参见 cachefspack(1M)


示例 20–10 创建压缩列表

以下示例说明压缩列表文件的内容:


BASE /home/ignatz

LIST plans

LIST docs

IGNORE *.ps

Procedure如何使用压缩列表在高速缓存中压缩文件

    对压缩列表中的文件进行压缩。


    $ cachefspack -f packing-list
    
    -f

    指定希望使用压缩列表。

    packing-list

    指定压缩列表的名称。


示例 20–11 使用压缩列表在高速缓存中压缩文件

此示例将 list.pkg 文件用作 cachefspack 命令的压缩列表。


$ cachefspack -f list.pkg

从高速缓存中解压缩文件或压缩列表

可能需要从高速缓存中删除或解压缩文件。也许一些文件或目录的优先级高于其他文件或目录,因此需要解压缩不太关键的文件。例如,已完成一个项目,并归档了与该项目关联的文件。现在正从事一个新项目,因此使用一组新文件。

Procedure如何从高速缓存中解压缩文件或压缩列表

    从高速缓存中解压缩文件或压缩列表。


    $ cachefspack -u filename | -U cache-directory
    
    -u

    指定要解压缩的一个或多个文件。必须使用此选项指定一个文件名。

    filename

    指定要在高速缓存中解压缩的文件或压缩列表的名称。

    -U

    指定希望解压缩高速缓存中的所有文件。

    有关更多信息,请参见 cachefspack(1M)


示例 20–12 从高速缓存中解压缩文件或压缩列表

以下示例说明从高速缓存中解压缩文件 /data/abc/bin/big


$ cachefspack -u /data/abc/bin/big

以下示例说明从高速缓存中解压缩三个文件。


$ cd /data/abc/bin/big

$ cachefspack -u big small medium

以下示例说明如何对压缩列表进行解压缩。压缩列表是一个包含目录(包含若干文件)路径的文件:


$ cachefspack -uf list.pkg

以下示例使用 -U 选项指定对高速缓存目录中的所有文件进行解压缩。


$ cachefspack -U /local/mycache

无法解压缩未挂载任何文件系统的高速缓存。使用 -U 选项时,如果指定的高速缓存不包含已挂载的文件系统,则显示与以下内容类似的输出:


$ cachefspack -U /local/mycache

cachefspack: Could not unpack cache /local/mycache, no mounted

filesystems in the cache.

cachefspack 错误进行疑难解答

使用 cachefspack 命令时,可能会看到以下错误消息。


cachefspack: pathname - can't open directory: permission denied
原因

可能没有访问文件或目录的正确权限。

操作

设置正确的权限。


cachefspack: pathname - can't open directory: no such file or

directory
原因

指定的文件或目录可能不正确。

操作

检查是否存在可能的键入错误。


cachefspack: pathname - can't open directory: stale NFS file handle
原因

在尝试访问文件或目录时,该文件或目录可能已从服务器中移走或删除。

操作

验证服务器上的该文件或目录是否仍然可访问。


cachefspack: pathname - can't open directory: interrupted system

call
原因

在发出命令时,可能无意中按了 Ctrl-C 组合键。

操作

重新发出命令。


cachefspack: pathname - can't open directory: I/O error
原因

可能存在硬件问题。

操作

检查硬件连接。


cachefspack: error opening dir
原因

指定的文件或目录可能不正确。在文件格式中 BASE 命令之后标识的路径可能是文件,而不是目录。指定的路径必须是目录。

操作

检查是否存在可能的键入错误。检查在文件格式中 BASE 命令之后标识的路径。确保该路径标识的是目录而不是文件。


cachefspack: unable to get shared objects
原因

可执行文件可能已损坏,或者其格式无法识别。

操作

替换可执行文件。


cachefspack: filename - can't pack file: permission denied
原因

可能没有访问文件或目录的正确权限。

操作

设置正确的权限。


cachefspack: filename - can't pack file: no such file or directory
原因

指定的文件或目录可能不正确。

操作

检查是否存在可能的键入错误。


cachefspack: filename- can't pack file: stale NFS file handle
原因

在尝试访问文件或目录时,该文件或目录可能已从服务器中移走或删除。

操作

验证服务器上的该文件或目录是否仍然可访问。


cachefspack: filename- can't pack file: interrupted system call
原因

在发出命令时,可能无意中按了 Ctrl-C 组合键。

操作

重新发出命令。


cachefspack: filename- can't pack file: I/O error
原因

可能存在硬件问题。

操作

检查硬件连接。


cachefspack: filename- can't pack file: no space left on device.
原因

高速缓存的磁盘空间不足。

操作

需要通过增加磁盘空间来增加高速缓存的大小。


cachefspack: filename - can't unpack file: permission denied
原因

可能没有访问文件或目录的正确权限。

操作

设置正确的权限。


cachefspack: filename - can't unpack file: no such file or directory
原因

指定的文件或目录可能不正确。

操作

检查是否存在可能的键入错误。


cachefspack: filename- can't unpack file: stale NFS file handle
原因

在尝试访问文件或目录时,该文件或目录可能已从服务器中移走或删除。

操作

验证服务器上的该文件或目录是否仍然可访问。


cachefspack: filename- can't unpack file: interrupted system call
原因

在发出命令时,可能无意中按了 Ctrl-C 组合键。

操作

重新发出命令。


cachefspack: filename- can't unpack file I/O error
原因

可能存在硬件问题。

操作

检查硬件连接。


cachefspack: only one `d', `i', `p', or `u' option allowed
原因

在一个命令会话中指定了其中的多个选项。

操作

为命令会话选择一个选项。


cachefspack: can't find environment variable.
原因

忘记设置对应的环境变量,以使其与配置文件中的 $ 匹配。

操作

在正确的位置定义该环境变量。


cachefspack: skipping LIST command - no active base
原因

在配置文件中存在 LIST 命令,但该命令没有对应的 BASE 命令。

操作

定义 BASE 命令。