零.前言
1.官网 http://trafficserver.apache.org/
2.国内社区 https://blog.zymlinux.net
3.简洁明了的配置:http://blog.csdn.net/tiantiandjava/article/details/50327855

一.ats安装
1.安装依赖包

#yum install pkgconfig libtool gcc make openssl tcl expat pcre pcre-devel libcap flex hwloc lua curses curl tcl-devel

  

2.下载安装包
下载trafficserver-5.3.2

#wget http://apache.fayea.com/trafficserver/trafficserver-5.3.2.tar.bz2

  

3.安装ats

#tar xvf trafficserver-5.3.2.tar.bz2
#cd trafficserver-5.3.2
#./configure --prefix=/usr/local/ats
#make && make install

  

二.配置
1.ats的配置文件都在安装目录下的etc/trafficserver,此处为/usr/local/ats/etc/trafficserver

2.重要配置文件:
(1).records.config 主要配置文件,配置ats的各项参数
安装完后该项保持默认配置

(2).remap.config 配置访问域名和源
如,在该文件最后增加

map http://domain.com http://113.7.1.126:8111/

前者为绑定域名,后者为源

(3).storage.config 配置磁盘缓存
在其最后增加

/ats_cache 20G

该配置是将磁盘缓存缓存在/ats_cache目录下,大小为20G

(4).cache.config 缓存配置
该文件决定了ats对缓存的配置

url_regex=192.168.2.105:8112/news.php\?id=.* ttl-in-cache=2h cache-responses-to-cookies=4

  

cache-responses-to-cookies取值介绍
0 不缓存任何带cookie的源服务器返回结果
1 缓存任何结果
2 只缓存图片类型的结果
3 缓存除了text类型的所有结果
4 缓存所有的非text类型的返回结果,以及不带 Set-Cookie 头或带 Cache-Control: public的text类型的源服务器返回结果

以上url正则表示缓存源网址为192.168.2.105:8112/news.php?id=任意结果的相应数据,缓存两小时,前提是该网址不带有Set-Cookie

dest_ip=127.0.0.1 suffix=gif ttl-in-cache=60d
dest_ip=127.0.0.1 suffix=jpg ttl-in-cache=60d
dest_ip=127.0.0.1 suffix=jpeg ttl-in-cache=60d
dest_ip=127.0.0.1 suffix=png ttl-in-cache=60d
dest_ip=127.0.0.1 suffix=bmp ttl-in-cache=60d
dest_ip=127.0.0.1 suffix=swf ttl-in-cache=60d
dest_ip=127.0.0.1 suffix=ico ttl-in-cache=60d
dest_ip=127.0.0.1 suffix=js ttl-in-cache=60d
dest_ip=127.0.0.1 suffix=css ttl-in-cache=60d

 以上将标示缓存127.0.0.1的静态文件,缓存60天

(5).logs_xml.config 配置日志

三.常用配置

1.配置http ui

(1).在recoreds.config最后增加

CONFIG proxy.config.http_ui_enabled INT 3
CONFIG proxy.config.http.enable_http_info INT 1

  

(2).在remap.config中增加

map http://localhost/cache-internal/ http://{cache-internal}
map http://localhost/cache/ http://{cache} @action=allow @src_ip=127.0.0.1
map http://localhost/stat/ http://{stat} @action=allow @src_ip=127.0.0.1
map http://localhost/test/ http://{test} @action=allow @src_ip=127.0.0.1
map http://localhost/hostdb/ http://{hostdb} @action=allow @src_ip=127.0.0.1
map http://localhost/net/ http://{net} @action=allow @src_ip=127.0.0.1
map http://localhost/http/ http://{http} @action=allow @src_ip=127.0.0.1

  

(3).通过以上配置,即可通过http协议来访问http ui

2.配置日志
(1).ats默认的日志是squid格式并不符合要求
(2).配置自定义日志
a.在logs_xml.config中增加

<LogFormat>
<Name = "access"/>
<Format = "%<chi> %<cqtq> %<ttms> %<{X-Forwarded-For}cqh> %<crc>/%<pssc> %<pscl> %<cqhm> %<cquuc> %<cqhv> %<phr>/%<pqsi> %<psct> \"%<{Referer}cqh>\" \"%<{User-Agent}cqh>\" %<shn> %<sscl>"/>
</LogFormat> <LogObject>
<Format = "access"/>
<Filename = "access"/>
</LogObject>

  

*format每项代表的意思,可以通过 https://docs.trafficserver.apache.org/en/5.3.x/admin/working-log-files.en.html 来查看

b.修改或增加records.config中的如下配置

CONFIG proxy.config.log.squid_log_enabled INT 0
CONFIG proxy.config.log.custom_logs_enabled INT 1

  

c.重载配置,后面会介绍

3.配置via标示,来快速确认文件缓存状态
a.

CONFIG proxy.config.http.insert_response_via_str INT 2

  

b.然后查看头部,可以看到
Via:http/1.1 localhost.localdomain (ApacheTrafficServer/5.3.2 [cRs f ])

c.查看[cRs f ],可以通过网址
http://trafficserver.apache.org/tools/via#cSsSfD
来查看
也可以通过命令来解释,后面会介绍

四.常用命令

1.命令通常在安装目录下的bin目录下,本文为/usr/local/ats/bin/

2./usr/local/ats/bin/trafficserver start #启动
/usr/local/ats/bin/trafficserver stop #停止
/usr/local/ats/bin/trafficserver restart #停止

3.重载配置
/usr/local/ats/bin/traffic_ctl config reload

4.查看squid日志
/usr/local/ats/bin/traffic_logcat filename #查看squid日志

5./usr/local/ats/bin/traffic_logstats #查看状态

6./usr/local/ats/bin/traffic_via [cRs f ] #查看via头状态

Apache Traffic Server(ats)的更多相关文章

  1. 安装ATS(apache traffic server)正向代理

    一 traffic server简介 Traffic Server是一种高性能Web代理缓存,可通过在网络边缘缓存频繁访问的信息来提高网络效率和性能.这使内容在物理上更接近最终用户,同时实现更快的交付 ...

  2. Apache Traffic Server服务搭建

    一.简介 Apache Traffic Server(ATS或TS)是一个高性能的.模块化的HTTP代理和缓存服务器,与 Nginx 和 Squid 类似.它通过将频繁访问的信息缓存在网络的边缘来改善 ...

  3. Apache Traffic Server

    1. ats 安装 参考:https://docs.trafficserver.apache.org/en/latest/getting-started/index.en.html#installat ...

  4. Apache Traffic Server 5.3.1公布

    本文来源于我在InfoQ中文站翻译的文章,原文地址是:www.infoq.com/cn/news/2015/07/traffic-server-5.3.1-release 近日,Apache软件基金会 ...

  5. ATS (apache traffic server) http_ui 设置与使用

    参考官方FAQ进行设置: https://cwiki.apache.org/confluence/display/TS/FAQ#FAQ-http_ui 这里也有一篇: https://blog.zym ...

  6. apache traffic server安装

    wget http://mirrors.hust.edu.cn/apache/trafficserver/trafficserver-7.1.1.tar.bz2 tar -jxvf trafficse ...

  7. Using Apache Web Server with Jboss AS 7

    In real-world projects, it's common to find Apache web server as a front door to your application se ...

  8. traffic server文件目录

    功能: Trafficserver的主要功能是缓存,当然你也可以用它来做纯粹的反向代理(像通常用nginx那样).通常切入一个庞大的系统的最好方式是看如何使用,使用traffic server的主要入 ...

  9. tomcat集群学习记录1--初识apache http server

    起因 平时开发的时候我都是用eclipse把代码部署到本地tomcat的,当然只会去跑1台tomcat啦... 偶尔有时候解决问题需要去公司测试环境找日志.连上公司测试环境以后发现竟然有2台weblo ...

随机推荐

  1. Sublime Text3中Autoprefixer失效解决方法

    进入CSS文件,默认配置在按下快捷键(Ctrl+Shift+P)后输入Autoprefix,你会发觉它什么事也没干,然后--这什么鬼?抓狂ing-- 原来是因为这玩意还要配置下,以下为配置方法: Pr ...

  2. mapReduce编程之auto complete

    1 n-gram模型与auto complete n-gram模型是假设文本中一个词出现的概率只与它前面的N-1个词相关.auto complete的原理就是,根据用户输入的词,将后续出现概率较大的词 ...

  3. Mac键盘图标与对应快捷按键标志汇总

    Mac键盘图标与对应快捷按键 ⌘--Command () win键 ⌃ --Control ctrl键 ⌥--Option (alt) ⇧--Shift ⇪--Caps Lock fn--功能键就是 ...

  4. loadrunner11录制无法打开IE浏览器

    安装loadrunner折腾了很久,后来发现是ghost系统问题.重装了系统,再重装了自己需要用的工具~ 接着学习loadrunner,一边看帮助文档一遍学.可是为嘛按照帮助文档的步骤来,就是会碰到一 ...

  5. Xtrabackup 安装使用

    一 简介:      Xtrabackup是一个对InnoDB做数据备份的工具,支持在线热备份(备份时不影响数据读写),是商业备份工具InnoDB Hotbackup的一个很好的替代品.它能对Inno ...

  6. c# ContinueWith 用法

    通过任务,可以指定在任务完成之后,应开始运行之后另一个特定任务.例如,一个使用前一个任务的结果的新任务,如果前一个任务失败了,这个任务就应执行一些清理工作.任务处理程序都不带参数或者带一个对象参数,而 ...

  7. 【XLL 框架库函数】 QuitFramework

    去初使化框架库,简问题是才的重新初使化 XLOPER/XLOPER12. 参数 这个函数没有参数 属性值/返回值 这个函数没有返回值.

  8. php面试题2

    php面试题及答案(原创)收藏 基础题: 1.表单中 get与post提交方法的区别? 答:get是发送请求HTTP协议通过url参数传递进行接收,而post是实体数据,可以通过表单提交大量信息. 2 ...

  9. singleton pattern的推荐实现

    一.单例模式的C#实现: (1)使用double-checked locking的方式: public sealed class Singleton { private static volatile ...

  10. C之按位运算符

    http://www.cnblogs.com/Kazaf/archive/2012/03/19/2406006.html