#官网 https://trafficserver.apache.org/ 安装环境 yum install 'liblz*' -y yum install net-tools -y yum install gcc gcc-c++ glibc-devel -y yum install autoconf automake pkgconfig libtool -y yum install perl-ExtUtils-MakeMaker perl-URI.noarch -y yum install openssl-devel tcl-devel expat-devel -y yum install pcre pcre-devel zlib-devel xz-devel -y yum install libcap libcap-devel flex hwloc hwloc-devel -y yum install lua-devel curl curl-devel sqlite-devel bzip2 -y 1.安装pcre [root@web_01 pcre-8.36]# wget http://ftp.exim.llorien.org/pcre/pcre-8.36.tar.gz [root@web_01 pcre-8.36]# tar xf pcre-8.36.tar.gz [root@web_01 pcre-8.36]# cd pcre-8.36 [root@web_01 pcre-8.36]# ./configure --prefix=/usr/local/trafficserver/pcre [root@web_01 pcre-8.36]# make && make instal 2.安装trafficserver [root@web_01 ~]# cd /usr/local/src/ [root@web_01 src]# wget https://mirrors.aliyun.com/apache/trafficserver/trafficserver-5.3.2.tar.bz2 [root@web_01 pcre-8.36]# tar xf trafficserver-5.3.2.tar.bz2 [root@web_01 pcre-8.36]# cd trafficserver-5.3.2 [root@web_01 trafficserver-5.3.2]# ./configure --prefix=/usr/local/trafficserver --with-pcre=/usr/local/trafficserver/pcre --enable-example-plugins --enable-experimental-plugins [root@web_01 trafficserver-5.3.2]# make && make install 注:--enable-example-plugins --enable-experimental-plugins 这两条指令是为了安装ATS官方集成的插件 [root@web_01 trafficserver-5.3.2]# cd /usr/local/trafficserver/bin/ [root@web_01 bin]# ./trafficserver start Starting Apache Traffic Server: [ Ok
5、Traffic Server进程管理css
[root@localhost ~]# ps aux|grep traffic root 7469 0.0 0.0 129628 7248 ? Ssl 04:57 0:02 /usr/local/tcacheserver/bin/traffic_cop 176 7472 0.0 0.0 501692 19660 ? Sl 04:57 0:30 /usr/local/tcacheserver/bin/traffic_manager 176 7482 19.8 20.8 15253324 10279168 ? Sl 04:57 118:31 /usr/local/tcacheserver/bin/traffic_server
咱们能够看到ATS服务启动了三个进程(traffic_cop、traffic_manager、traffic_server)来服务ats请求,管理,控制、监控系统的健康状况,以下图1所述:html
若是traffic_manager进程检测到traffic_server进程失败,它不只会当即重启该进程,并且会为全部转入的请求维护一个链接队列。在traffic_server从新启动前的几秒内传入的全部链接将被保存在一个队列,并以FIFO的方式处理,这个链接队列接收任何server故障重启时的链接。c++
traffic_top进程经过抓取合成web页面的心跳请求方式周期性地(每分钟若干次)查询traffic_server和traffic_manager进程。若是失败事件发生(若是在超过期间间隔内没有收到请求或者收到错误的请求)traffic_top重启traffic_server和traffic_manager。web
#修改records.config文件 #25行 CONFIG proxy.config.http.server_ports STRING 80 #29行 CONFIG proxy.config.http.insert_response_via_str INT 2 #添加 CONFIG proxy.config.log.custom_logs_enabled INT 1 #添加 CONFIG proxy.config.log.xml_config_file STRING logs_xml.config #添加 CONFIG proxy.config.diags.show_location INT 1 #修改remap.config文件添加以下: regex_map http://(.*) http://$1 #修改logs_xml.config文件添加以下: <LogFormat> <Name = "ats_access_log"/> <Format = "%<cqtd>/%<cqtt> %<cqhm> \"%<cquuc>\" %<pssc> %<ttms> %<cqhl> %<psql> %<crc> \"%<chi>\" %<pqsn> \"%<{Referer}cqh>\" \"%<psct>\" \"%<{User-agent}cqh>\" %<csssc> %<pqsi>"/> </LogFormat> <LogObject> <Format = "ats_access_log"/> <Filename = "access"/> <Protocols = "http"/> <RollingEnabled = "3"/> <RollingIntervalSec = "7200"/> <RollingSizeMb = "2048"/> </LogObject> #修改storage.config文件 var/trafficserver 4G #重启服务 [root@controller bin]# pwd /usr/local/trafficserver/bin [root@controller bin]# ./trafficserver restart #测试 [root@controller bin]# curl -vx 127.0.0.1:80 -o /dev/null 'http://news.sohu.com/' * About to connect() to proxy 127.0.0.1 port 80 (#0) * Trying 127.0.0.1... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to 127.0.0.1 (127.0.0.1) port 80 (#0) > GET http://news.sohu.com/ HTTP/1.1 > User-Agent: curl/7.29.0 > Host: news.sohu.com > Accept: */* > Proxy-Connection: Keep-Alive > < HTTP/1.1 200 OK < Content-Type: text/html;charset=UTF-8 < Content-Length: 170289 < Server: ATS/5.3.2 < Date: Fri, 01 Dec 2017 03:26:44 GMT < Cache-Control: max-age=120 < X-From-Sohu: X-SRC-Cached < FSS-Cache: EXPIRED from 9206494.16415464.10543436 < Accept-Ranges: bytes < FSS-Proxy: Powered by 3308164.4618894.4645016 < Age: 0 < Proxy-Connection: keep-alive < Via: http/1.1 controller (ApacheTrafficServer/5.3.2 [cSsSfU]) < { [data not shown] 100 166k 100 166k 0 0 152k 0 0:00:01 0:00:01 --:--:-- 152k * Connection #0 to host 127.0.0.1 left intact
查看运行状况:sql
[root@controller bin]# ./traffic_top