1. 程式人生 > >Traffic-Server配置(待補充和更新)

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

exp onf 存儲 空間 時間 cache 1-1 byte conn

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="www.colinmaomao.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

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