完整配置示例

完整配置示例

TS 配置文件路径在/etc/trafficserver/,分功能配置不同配置文件,常用的配置文件如下:

  • records.config 主功能参数配置文件
  • remap.config 业务域名规则配置文件
  • storage.config Cache 存储配置文件

squid 配置转TS配置参考

配置示例

Storage.config

ATS 支持目录配置,也支持裸盘配置,无需文件系统支持

  • 目录配置方式

    1. 1. #cat /etc/trafficserver/storage.config
    2. 2. /var/cache/trafficserver 256M
  • 裸盘配置方式

    1. 1. #cat /etc/trafficserver/storage.config
    2. 2. /dev/sdb
    3. 3. /dev/sdc
    4. 4. /dev/sdd
  • 初始化磁盘目录

    1. 1. traffic_server -Cclear

Records.config

records.config 大多保持默认配置就好

注意: traffic_line 模式修改配置需要保证ATS是运行的

  1. 1. #用于标识名称,Cluster模式下同一集群必须保持一致才能建立集群
  2. 2. traffic_line -s proxy.config.proxy_name -v test
  3. 4. #配置cluster 模式
  4. 5. - 1 cluster 模式,有7层代理功能和集群配置同步
  5. 6. - 2 仅做配置管理
  6. 7. - 3 单机模式
  7. 8. traffic_line -s proxy.local.cluster.type -v 1
  8. 10. #自动配置线程数,多少个CPU配置多少个线程,可调整
  9. 11. traffic_line -s proxy.config.exec_thread.autoconfig -v 1
  10. 12. traffic_line -s proxy.config.exec_thread.autoconfig.scale -v 1
  11. 14. #监听8080、80端口,8080 一般用于管理端口,80为服务端口
  12. 15. traffic_line -s proxy.config.http.server_ports -v 8080 80
  13. 17. #Cache内存大小,-1 为不限制,具体大小结合业务调整,内存命中越高磁盘IO越小
  14. 18. traffic_line -s proxy.config.cache.ram_cache.size -v 25769803776
  15. 20. #Cache内存淘汰算法,采用CLFUS,LRU 模式有问题
  16. 21. traffic_line -s proxy.config.cache.ram_cache.algorithm -v 1
  17. 23. #传输超时时间,默认900s,传输大文件容易触发超时,改成不限制
  18. 24. traffic_line -s proxy.config.http.transaction_active_timeout_in -v 0
  19. 26. #negative TTL 功能开启
  20. 27. traffic_line -s proxy.config.http.negative_caching_enabled -v 1
  21. 29. #忽略判断Accept头,默认会根据Accept头做多副本缓存
  22. 30. traffic_line -s proxy.config.http.cache.ignore_accept_mismatch -v 1
  23. 32. #忽略判断Accept-Language头,默认会根据Accept-Language头做多副本缓存
  24. 33. traffic_line -s proxy.config.http.cache.ignore_accept_language_mismatch -v 1
  25. 35. #忽略判断Accept-Charset头,默认会根据Accept-Charset头做多副本缓存
  26. 36. traffic_line -s proxy.config.http.cache.ignore_accept_charset_mismatch -v 1
  27. 38. #忽略client max-age
  28. 39. traffic_line -s proxy.config.http.cache.ignore_client_cc_max_age -v 1
  29. 41. #忽略HTTP认证头,默认带Authentication是不做缓存的
  30. 42. traffic_line -s proxy.config.http.cache.ignore_authentication -v 1
  31. 44. #开启vary 功能
  32. 45. traffic_line -s proxy.config.http.cache.enable_default_vary_headers -v 1
  33. 47. #开启回源合并
  34. 48. traffic_line -s proxy.config.cache.enable_read_while_writer -v 1
  35. 50. #平均object 大小,结合业务配置
  36. 51. traffic_line -s proxy.config.cache.min_average_object_size -v 16384
  37. 53. #开启HTTP UI
  38. 54. traffic_line -s proxy.config.http_ui_enabled -v 3

remap.config

  1. 1. #HTTP UI 接口
  2. 2. http localhost:8080 {
  3. 3. map /cache-internal/ http://{cache-internal}
  4. 4. map /cache/ http://{cache}
  5. 5. map /stat/ http://{stat}
  6. 6. map /test/ http://{test}
  7. 7. map /hostdb/ http://{hostdb}
  8. 8. map /net/ http://{net}
  9. 9. map /http/ http://{http}
  10. 10. map /migrate/ http://{migrate}
  11. 11. }
  12. 13. #域名规则
  13. 14. http www.taobao.com {
  14. 15. map / http://www.taobao.com/
  15. 16. }