#官網 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