代理服务器自带若干个命令行实用程序,可以通过它们配置、更改、生成和修复高速缓存目录结构。这些实用程序中的大多数都与 Server Manager 页面的功能完全相同,但在需要进行维护调度时可能需要使用这些实用程序(例如,作为计时程序作业)。所有这些实用程序都位于 extras 目录中。
cbuild 代理实用程序是一个脱机高速缓存数据库管理器。可以通过该实用程序使用命令行界面来创建新的高速缓存结构或修改现有的高速缓存结构。可以使用 Server Manager 页面来使代理服务器能够使用新创建的高速缓存。
该实用程序不更新 server.xml 文件。cbuild 不能调整具有多个分区的高速缓存的大小。通过 cbuild 创建或修改高速缓存时,应在 server.xml 文件中手动更新 cachecapacity 参数。
<PARTITION partitionname="part1" partitiondir="/home/build/install9 /proxy-server1/cache" maxsize="1600" minspace="5" enabled="true"/> <CACHE enabled="true" cachecapacity="2000" cachedir="/tmp/cache">
可以在两种模式下调用 cbuild 实用程序。第一种模式为:
cbuild -d conf-dir -c cache-dir -s cache size cbuild -d conf-dir -c cache-dir -s cache size -r
例如:
cbuild -d server_root/proxy-serverid/config -c server_root/proxy-serverid/cache -s 512 cbuild -d server_root/proxy-serverid/config -c server_root/proxy-serverid/cache -s 512 -r
其中,
conf-dir 是代理服务器实例的配置目录,它位于 server_root/proxy-serverid/config 目录中。
cache-dir 是高速缓存结构的目录。
cache size 是高速缓存可以增长到的最大大小。此选项不能与 cache-dim 参数一起使用。最大大小为 65135 MB。
-r 调整现有高速缓存结构的大小(前提是它只有一个分区)。创建新高速缓存时此参数不是必需的。
第二种模式为:
cbuild -d conf-dir -c cache-dir -n cache-dim cbuild -d conf-dir -c cache-dir -n cache-dim -r
例如:
cbuild -d server_root/proxy-serverid/config -c server_root/proxy-serverid/cache -n 3 cbuild -d server_root/proxy-serverid/config -c server_root/proxy-serverid/cache -n 3 -r
其中,
conf-dir 是代理服务器实例的配置目录,它位于 server_root/proxy-serverid/config 目录中。
cache-dir 是高速缓存结构的目录。
cache-dim 用于确定段数。例如,在图 12–2 中,段显示为 s3.4,3 表示大小。cache-dim 的默认值是 0,最大值是 8。
-r 调整现有高速缓存结构的大小(前提是它只有一个分区)。创建新高速缓存时此参数不是必需的。
代理实用程序 urldb 用于管理高速缓存中的 URL 列表。可以使用此实用程序列出高速缓存的 URL。也可以有选择地废止和删除高速缓存数据库中高速缓存的对象。
可以根据 -o 选项将 urldb 命令分为三个组:
域
站点
URL
要列出域,请在命令行中键入以下命令:
urldb -o matching_domains -e reg-exp -d conf-dir
例如:
urldb -o matching_domains -e “.*phoenix.*” -d server-root/proxy-serverid/config
其中,
matching_domains 列出与正则表达式匹配的域
reg-exp 是所使用的正则表达式
conf-dir 是代理服务器实例的配置目录,它位于 server-root/proxy-serverid/config 目录中。
要列出域中的所有匹配站点,请在命令行中键入以下命令:
urldb -o matching_sites_in_domain -e reg-exp -m domain_name -d conf-dir
例如:
urldb -o matching_sites_in_domain -e “.*atlas” -m phoenix.com -d server-root/proxy-serverid/config
其中,
matching_sites_in_domain 列出域中所有与正则表达式匹配的站点
reg-exp 是所使用的正则表达式
domain_name 是域的名称
conf-dir 是代理服务器实例的配置目录,它位于 server-root/proxy-serverid/config 目录中。
要列出所有匹配站点,请在命令行中键入以下命令:
urldb -o all_matching_sites -e reg-exp -d conf-dir
例如:
urldb -o all_matching_sites -e “.*atlas.*” -d server-root/proxy-serverid/config
其中,
all_matching_sites 列出所有与正则表达式匹配的站点
reg-exp 是所使用的正则表达式
conf-dir 是代理服务器实例的配置目录,它位于 server-root/proxy-serverid/config 目录中。
要列出站点中的匹配 URL,请在命令行中键入以下命令:
urldb -o matching_urls_from_site -e reg-exp -s site_name -d conf-dir
例如:
urldb -o matching_urls_from_site -e “http://.*atlas.*” -s atlas.phoenix.com -d server-root/proxy-serverid/config
其中,
matching_urls_from_site 列出站点中所有与正则表达式匹配的 URL
reg-exp 是所使用的正则表达式
site_name 是站点的名称
conf-dir 是代理服务器实例的配置目录,它位于 server-root/proxy-serverid/config 目录中。
要废止或删除站点中的匹配 URL,请在命令行中键入以下命令:
urldb -o matching_urls_from_site -e reg-exp -s site_name -x e -d conf-dir urldb -o matching_urls_from_site -e reg-exp -s site_name -x r -d conf-dir
例如:
urldb -o matching_urls_from_site -e “http://.*atlas.*” -s atlas.phoenix.com -x e -d server-root/proxy-serverid/config
其中,
matching_urls_from_site 列出站点中所有与正则表达式匹配的 URL
reg-exp 是所使用的正则表达式
site_name 是站点的名称
-x e 是用于废止高速缓存数据库中匹配的 URL 的选项。此选项不能用于域模式和站点模式
-x r 是用于删除高速缓存数据库中匹配的 URL 的选项
conf-dir 是代理服务器实例的配置目录。它位于 server-root/proxy-serverid/config 目录中。
要列出所有匹配的 URL,请在命令行中键入以下命令:
urldb -o all_matching_urls -e reg-exp -d conf-dir
例如:
urldb -o all_matching_urls -e “.*cgi-bin.*” -d server-root/proxy-serverid/config
其中,
all_matching_urls 列出所有与正则表达式匹配的 URL
reg-exp 是所使用的正则表达式
conf-dir 是代理服务器实例的配置目录,它位于 server-root/proxy-serverid/config 目录中。
要废止或删除所有匹配的 URL,请在命令行中键入以下命令:
urldb -o all_matching_urls -e reg-exp -x e -d conf-dir urldb -o all_matching_urls -e reg-exp -x r -d conf-dir
例如:
urldb -o all_matching_urls -e “.*cgi-bin.*” -x e -d server-root/proxy-serverid/config
其中,
all_matching_urls 列出所有与正则表达式匹配的 URL
reg-exp 是所使用的正则表达式
-x e 是用于废止高速缓存数据库中匹配的 URL 的选项
-x r 是用于删除高速缓存数据库中匹配的 URL 的选项
conf-dir 是代理服务器实例的配置目录,它位于 server-root/proxy-serverid/config 目录中。
要废止或删除 URL 列表,请在命令行中键入以下命令:
urldb -l url-list -x e -e reg-exp -d conf-dir urldb -l url-list -x r -e reg-exp -d conf-dir
例如:
urldb -l url.lst -x e -e “.*cgi-bin.*” -d server-root/proxy-serverid/config
其中,
url-list 是需要废止的 URL 列表。此选项可用于提供 URL 列表。
-x e 是用于废止高速缓存数据库中匹配的 URL 的选项。
-x r 是用于删除高速缓存数据库中匹配的 URL 的选项。
reg-exp 是所使用的正则表达式
conf-dir 是代理服务器实例的配置目录,它位于 server-root/proxy-serverid/config 目录中。
通过 cachegc 实用程序,您可以将可能已过期或因存在时间过久而不能高速缓存(由于受到高速缓存大小约束)的对象从高速缓存数据库删除。
请确保在使用 cachegc 实用程序时,代理服务器实例中没有运行 CacheGC。
可以按以下方式使用 cachegc 实用程序:
cachegc -f leave-fs-full-percent -u gc-high-margin-percent -l gc-low-margin-percent -e extra-margin-percent -d conf-dir
例如:
cachegc -f 50 -u 80 -l 60 -e 5 -d server-root/proxy-serverid/config
其中,
leave-fs-full-percent 确定高速缓存分区大小的百分比,低于该值时将不进行垃圾收集
gc-high-margin-percent 控制最大高速缓存大小的百分比,达到此百分比时即会触发垃圾收集
gc-low-margin-percent 控制作为垃圾收集器目标的最大高速缓存大小的百分比
extra-margin-percent 由垃圾收集器用于确定要删除高速缓存的百分比。
conf-dir 是代理服务器实例的配置目录,它位于 server-root/proxy-serverid/config 目录中。
bu 实用程序用于更新高速缓存,它在两种模式下工作。在第一种模式下,该实用程序循环遍历高速缓存数据库并通过发送对每个 URL 的 HTTP 请求更新高速缓存中存在的所有 URL。在第二种模式下,它从给定 URL 开始,对从该 URL 到您指定的深度的 URL 的所有链接执行广度优先遍历,获取页面并将其置于高速缓存中。bu 是符合 RFC 标准的爬虫程序 (robot)。
bu -n hostname -p port -t time-lmt -f contact-address -s sleep-time -o object -r n -d conf-dir
例如:
bu -n phoenix -p 80 -t 3600 -f admin@phoenix.com -s 60 -o nova -r n -d server-root/proxy-serverid/config
其中,
hostname 是运行代理服务器的计算机的主机名。默认值为 localhost。
port 是运行代理服务器的端口。默认端口为 8080。
time-lmt 是实用程序运行的时间限制
contact-address 确定将在从 bu 发送来的 HTTP 请求中发送的联系地址。默认值为 worm@proxy-name。
sleep-time 是两次连续请求之间的休眠时间。默认值为 5 秒。
object 是在当前正在执行的 bu.conf 中指定的对象。
-r n 选项确定是否遵循 robot.txt 策略。默认值为 y。
conf-dir 是代理服务器实例的配置目录,它位于 server-root/proxy-serverid/config 目录中。