Traffic-Server配置(待补充和更新)

Server 5.3.2

测试1.裸盘:
remap.config
map http://192.168.227.131 http://192.168.227.131:8080

#traffic_server ATS 服务器
#traffic_line -r @commmand

#裸盘
/dev/sdb volume=1 还要修改udev.
#缓存查询
proxy.node.cache.bytes_total #存储总大小
proxy.node.cache.bytes_free #空闲大小
proxy.node.cache.percent_free #缓存空间空闲率
proxy.node.cache_hit_ratio #缓存命中率
proxy.node.bandwidth_hit_ratio #ats带宽的命中率
proxy.node.bandwidth_hit_ratio_int_pct #总共命中次数

#ip_allow.conf_PURGE method
src_ip=127.0.0.1 action=ip_allow method=ALL
src_ip=192.168.35.35 action=ip_allow method=PURGE
src_ip=192.168.227.131 action=ip_allow method=PURGE
# Deny PURGE, DELETE, and PUSH for all (this implies allow other methods for all)
src_ip=0.0.0.0-255.255.255.255 action=ip_deny method=PUSH|PURGE|DELETE
#ACL 应该是从上到下顺序读写;

#records.config
#全局配置、为测试CPU线程、内存存储、父层、cluster&集群管理、热点、多级存储 (域名分级、按照热度物理分级)
CONFIG proxy.config.url_remap.remap_required INT 1 # 只开启反向代理
CONFIG proxy.config.http.parent_proxy_routing_enable INT 0 #父层相关 1.代表开启 0.关闭
CONFIG proxy.config.http.parent_proxy.retry_time INT 300 #父层相关
CONFIG proxy.config.http.parent_proxy.connect_attempts_timeout INT 30 #父层相关
CONFIG proxy.config.http.cache.http INT 1 #这里是缓存 0 最保守2 所有都缓存 1 lastmodifi之类
CONFIG proxy.config.http.cache.cache_urls_that_look_dynamic INT 1 #动态都转发
CONFIG proxy.config.http.cache.required_headers INT 1 #1 需要带有:Last-Modified: Expires: Cache-Control: max-age 三个header头中最少一个。这个模式下,允许一个静态文件只带:Last-Modified:头就可以缓存的在ATS中
CONFIG proxy.config.http.insert_age_in_response INT 0 #age 头添加,我要你何用!!
CONFIG proxy.config.cache.ram_cache.size INT -1 #内存缓存大小 --热点
CONFIG proxy.config.http_ui_enabled INT 1 #缓存检查工具开启
CONFIG proxy.config.http.insert_age_in_response INT 0 #age 头添加,http1.1版本的age头影响太小了、要你何用!!!
#隐藏服务器名、版本号
CONFIG proxy.config.http.response_server_str STRING pcs/1.0.1
CONFIG proxy.config.http.response_via_str STRING PCS

#父层配置
CONFIG proxy.config.http.parent_proxy_routing_enable INT 1

dest_domain 指定那些域名可以使用父层缓存、我这里选择了所有
dest_domain=. parent="xxx.com:80

#下面的规则配置了一个一子两父(p1.x.com和p2.x.com)的分级缓存,ATS会转发它不能serve的请求到父服务器p1.x.com和p2.x.com,使用轮询方式
#round_robin=true
#dest_domain=. method=get parent="p1.x.com:8080; p2.y.com:8080" round_robin=true
#round_robin=consistent_hash
#dest_domain=. method=get parent="p1.x.com:8080|1.0; p2.y.com:8080|2.0" round_robin=consistent_hash

缓存规则: cache.config
revalidate
认为还新鲜的时间,超过这个设定时间,需要回源检验对象是否新鲜。会影响http响应头部信息age。
ttl-in-cache
强制缓存的时间,这个选项能够让ats忽略源的cache-control响应头部信息而强制缓存,并且认为对象在这个强制缓存时间里面是新鲜的。会影响http响应头部信息age。经测试发现其比revalidate优先级高。

pin-in-cache
保留在缓存中的时间。为了避免热门对象会被删除,可以设置对象硬性保留在缓存中的时间,在设定的时期内,就算它已经过期了也不删除它。不会影响http响应头部信息age。
ttl-in-cache>revalidate>expires(nginx)
ttl-in-cache 能够单独完成强制对象写入缓存中并保证认为的新鲜期,不需要额外的帮助使对象写入缓存中。
pin-in-cache 只是保证对象在缓存中不被删除,并不影响对象的新鲜度。
自定义日志测试:
<LogFormat>
<Name = "date"/>
<Format = "%<chi> %<ttmsf> %<tts> [%<cqtd>-%<cqtt>] %<cqtx> "%<{user-agent}cqh>" "%<{Referer}cqh>" %<csssc> %<cqbl> %<fsiz> %<crc>/%<cqhm> %<phi>"/>
</LogFormat>
<LogObject>
<Format = "date"/>
<Filename = "date"/>
</LogObject>

192.168.227.131 0.000 0 [2017-02-21-14:28:49] GET http://192.168.227.132:8080/ HTTP/1.0 "Wget/1.12 (linux-gnu)" "http://www.zcmhi.com/archives/71.html" 200 0 499584 TCP_MEM_HIT/GET 192.168.227.131
192.168.227.131 0.000 0 [2017-02-21-14:28:49] GET http://192.168.227.132:8080/ HTTP/1.0 "Wget/1.12 (linux-gnu)" "http://www.zcmhi.com/archives/71.html" 200 0 499584 TCP_MEM_HIT/GET 192.168.227.131

<LogFormat>
<Name = "welf"/>
<Format = "id=firewall time="%<cqtd> %<cqtt>" fw=%<phn> pri=6 proto=%<cqus> duration=%<ttmsf> sent=%<psql> rcvd=%<cqhl> src=%<chi> dst=%<shi> dstname=%<shn> user=%<caun> op=%<cqhm> arg="%<cqup>" result=%<
pssc> ref="%<{Referer}cqh>" agent="%<{user-agent}cqh>" cache=%<crc>"/>
</LogFormat

原文地址:https://www.cnblogs.com/sean-yao/p/7707520.html