零.前言
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. Socket通信(二)

    程序下载地址: http://download.csdn.net/detail/u010312811/9683748 1.基本流程 服务器:(1)用指定的端口号和服务器的IP建立一个EndPoint对 ...

  2. OC编程之道-创建对象之单例模式

    一 何为单例singleton模式?(what) 保证一个类只有一个实例,并提供一个访问它的全局访问点. 二 何时使用单例模式?(where) 1类只能有一个实例,而且必须从一个为人熟知的访问点对其访 ...

  3. ajax实例2

    前台: function save() { var username = document.getElementById("username").value; var id = d ...

  4. EXPORT_SYMBOL的使用

    转自:http://blog.csdn.net/cailiwei712/article/details/7998525 在查看内核驱动代码的时候会经常看到在一些函数后面总会跟EXPORT_SYMBOL ...

  5. Intent传递list<bean>集合

    首先你定义的bean需要继承Serializable接口 //传递list<bean>集合Intent intent = new Intent(ViolationOfTheQueryAct ...

  6. 2015年ACM长春网络赛(准备做掉7道:已经更新到6道)

    总结汇总:模板 int getmax_min(char s[]) {//字符串的最大表示法:返回最小数组下标 , j = , k = ; while(i < len && j & ...

  7. 2015年ACM沈阳网络赛(准备做掉4道:)

    Traversal Best Solver Minimum Cut Dividing This Product Excited Database Fang Fang Matches Puzzle Ga ...

  8. CodeForces 444C 分块

    题目链接:http://codeforces.com/problemset/problem/444/C 题意:给定一个长度为n的序列a[].起初a[i]=i,然后还有一个色度的序列b[],起初b[i] ...

  9. Linux 计划任务

    实例: 每5分钟定时访问一个url # crontab -e #*/5 * * * * /usr/bin/curl http://aa.com:8080/tools/sitemap.php >& ...

  10. Leetcode Simplify Path

    Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", ...