歡迎您光臨本站 註冊首頁

traffic server 安裝配置

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

traffic server 安裝配置

traffic server 是yahoo一直在使用的一套cache軟體,據稱效率很高,最近開源,作為測試使用,寫下文檔,供大家參考
如果有任何問題請到
http://www.opensolution.org.cn/archives/521.html
討論

轉帖請標明出於 http://www.opensolution.org.cn/archives/521.html

traffic server 安裝配置

作者: <ljh1405@gmail.com>
Last Updated: 11/18/09 15:08:39

安裝軟體
1.1. 依賴系統安裝以下軟體 必須是32位的
1.2. 新建代碼下載目錄
1.3. checkout 代碼
1.4. 生成configure文件,build 代碼,安裝
1.5. 修正存在問題
配置軟體,主要配置文件有3個
2.1. 主配置文件 records.config
2.2. proxy 代理配置remap.conf
2.3. cache 存儲空間配置文件 storage.config
2.3.1. 用mknod 創建虛擬raw 設備
2.3.2. 綁定物理磁碟到raw 設備
2.3.3. 查詢設備綁定情況
2.3.4. 計算raw空間
2.3.5. 修改 storage.config 輸入
管理軟體
3.1. 啟動manager
3.2. 管理
3.2.1. traffic_line
3.2.2. start_traffic_shell
3.2.3. logstats
3.2.4. traffic_server
1. 安裝軟體

1.1. 依賴系統安裝以下軟體 必須是32位的

gcc-c++ glibc-devel.i586 db4-devel.i586 openssl-devel.i586 tcl-devel.i586 expat-devel.i586

1.2. 新建代碼下載目錄

  mkdir /tmp/ts
1.3. checkout 代碼

  cd /tmp/ts
  svn checkout   http://svn.apache.org/repos/asf/incubator/trafficserver/traffic/trunk   traffic-trunk.svn
1.4. 生成configure文件,build 代碼,安裝

  cd /tmp/traffic-trunk.svn;
  autoreconf -i  ;./configure --prefix=/home/ts -;make -j32;make install
  
1.5. 修正存在問題

由於代碼問題,安裝好后需要做一些link,才能讓軟體正常運行(可能是代碼從yahoo遷移過來,還有yahoo的痕迹沒改徹底)

    mkdir /home/ts/conf ;cd /home/ts/conf ;ln -s /home/ts/etc/trafficserver yts
    mkdir /home/ts/conf/yts/internal/
    代碼里有一個相對路徑寫錯了,同樣需要做一個link來解決
    mkdir /home/ts/home ;cd /home/ts/home ;ln -s /home/ts ts
至此,安裝完成

2. 配置軟體,主要配置文件有3個

配置文件都在 /home/ts/etc/trafficserver 主要有3個需要修改

2.1. 主配置文件 records.config

  CONFIG proxy.config.proxy_name STRING cache1 ### 修改成cache的server name即可
  CONFIG proxy.config.cluster.ethernet_interface STRING eth0 ### 修改成需要偵聽的interface名稱,默認是 null
  CONFIG proxy.config.admin.user_id STRING root ### 用來運行 traffic server 的用戶,默認是nobody
  CONFIG proxy.config.http.server_port INT 80 ### traffic server 偵聽的埠,默認是8080
其他配置可自習根據情況修改

2.2. proxy 代理配置remap.conf

如果要對 www.example.com加速 則寫為

  map http://www.example.com http://ip(或者域名)
       |                             |_____ 代理伺服器需要訪問的源站點的ip或者域名
       |__用戶最終訪問的域名
2.3. cache 存儲空間配置文件 storage.config

使用raw deivces,將物理磁碟綁定到raw device

2.3.1. 用mknod 創建虛擬raw 設備

   mknod /dev/rawctl c 162 0
    chmod 600 /dev/rawctl  這個很重要,還需要給與運行traffice server的屬主,我是用root運行,所有這樣就可以了
        mknod /dev/raw_sdb c 162 1
        mknod /dev/raw_sdc c 162 2
2.3.2. 綁定物理磁碟到raw 設備

    /usr/bin/raw /dev/raw_sdb /dev/sdb
    /usr/bin/raw /dev/raw_sdc /dev/sdc
2.3.3. 查詢設備綁定情況

    /usr/bin/raw -q /dev/raw/raw_sdb
   或者
   /usr/bin/raw -a
2.3.4. 計算raw空間

    blockdev --getsize /dev/raw_sdb
    blockdev --getss /dev/raw_sdb
讓后將這2個值相乘得到 raw最終值 即下面的 300000000000

2.3.5. 修改 storage.config 輸入

  /dev/raw_sdb   300000000000
  /dev/raw_sdc   300000000000
3. 管理軟體

3.1. 啟動manager

  nohup  /home/ts/bin/traffic_manager  >../var/log/trafficserver/ts.log  2>&1 &
  
查看進程情況

  ps -ef
應該能看到

  bin/traffic_server -M -A8:X ##server 服務進程
  #netstat -npa |grep traff
  tcp        0      0 0.0.0.0:20098               0.0.0.0:*                   LISTEN      18117/traffic_manag
  tcp        0      0 0.0.0.0:9898                0.0.0.0:*                   LISTEN      18117/traffic_manag
  tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      18117/traffic_manag
  tcp        0      0 0.0.0.0:8083                0.0.0.0:*                   LISTEN      18117/traffic_manag
  tcp        0      0 0.0.0.0:8084                0.0.0.0:*                   LISTEN      18148/traffic_serve
  tcp        0      0 0.0.0.0:8088                0.0.0.0:*                   LISTEN      18117/traffic_manag
  udp        0      0 172.22.26.91:29611          172.22.5.128:53             ESTABLISHED 18148/traffic_serve
  unix  2      [ ACC ]     STREAM     LISTENING     738846890 18117/traffic_manag ./conf/yts//process_server
  unix  2      [ ACC ]     STREAM     LISTENING     738846893 18117/traffic_manag /home/ts/etc/trafficserver/mgmtapisocket
  unix  2      [ ACC ]     STREAM     LISTENING     738846895 18117/traffic_manag /home/ts/etc/trafficserver/eventapisocket
  unix  2      [ ACC ]     STREAM     LISTENING     738847082 18117/traffic_manag /home/ts/etc/trafficserver/cli
  unix  2      [ ]         DGRAM                    738846975 18148/traffic_serve
  unix  3      [ ]         STREAM     CONNECTED     738846917 18117/traffic_manag ./conf/yts//process_server
  unix  3      [ ]         STREAM     CONNECTED     738846916 18148/traffic_serve
  unix  2      [ ]         DGRAM                    738846880 18117/traffic_manag
3.2. 管理

3.2.1. traffic_line

- /home/ts/bin/traffic_line -x 生效,不需要重啟應用

3.2.2. start_traffic_shell

/home/ts/bin/start_traffic_shell
  %提示符
  %show
  % show:cache  ###cache 基本配置
  FTP Caching ---------------------------- off
  NNTP Caching --------------------------- on
  Ignore User Requests To Bypass Cache --- on
  Maximum HTTP/FTP Object Size ----------- 1024000
  Freshness
    Verify Freshness By Checking --------- When The Object Has Expired
    Minimum Information to be Cacheable -- A Last Modified Time
    If Object has no Expiration Date:
      Leave it in Cache for at least ----- 86400 s
      but no more than ------------------- 86400 s
    FTP Cached Objects Expire After ------ 259200 s
  Variable Content
    Cache Responses to URLs that contain
      "?",";","cgi" or end in ".asp" ----- on
    Alternates Enabled ------------------- off
    Vary on HTTP Header Fields:
      Text ------------------------------- NULL
      Images ----------------------------- NULL
      Other ------------------------------ NULL
    Cache responses to requests containing cookies for:
      All Content-types
  
  % show:cache-stats
  
  Bytes Used --- 74 GB
  Cache Size --- 1395 GB
  --RAM Cache--
  Total Bytes -- 1497216000
  Bytes Used --- 950272
  Hits --------- 34
  Misses ------- 88
  
  % show:proxy-stats
  
  Document Hit Rate -------- 58.490568 %   *
  Bandwidth Saving --------- 10.361657 %   *
  Cache Percent Free ------- 94.634068 %
  Open Server Connections -- 0
  Open Client Connections -- 0
  Open Cache Connections --- 0
  Client Throughput -------- 0.000000 MBit/Sec
  Transaction Per Second --- 0.000000
  
  * Value represents 10 second average.
其他請大家參考幫助或者自己測試使用

3.2.3. logstats

/home/ts/bin/logstats --help
  
  Usage: logstats [-l logfile] [-o origin[,...]] [-O originfile] [-m minhits] [-inshv]
    switch__________________type__default___description
    -h, --help              tog   true      Give this help
    -f, --log_file          str   (null)    Specific logfile to parse
    -o, --origin_list       str   (null)    Only show stats for listed Origins
    -O, --origin_file       str   (null)    File listing Origins to show
    -i, --incremental       tog   false     Incremental log parsing
    -S, --statetag          str   (null)    Name of the state file to use
    -t, --tail              int   0         Parse the last <sec> seconds of log
    -s, --summary           tog   false     Only produce the summary
    -y, --ymon              tog   false     Output is formatted for YMon/Nagios
    -Y, --ysar              tog   false     Output is formatted for YSAR
    -m, --min_hits          i64   0         Minimum total hits for an Origin
    -a, --max_age           int   0         Max age for log entries to be considered
    -l, --line_len          int   78        Output line length
    -T, --debug_tags        str   (null)    Colon-Separated Debug Tags
    -V, --version           tog   false     Print Version Id
  
例如

  logstats -i www.example.com
會根據日誌分析cache的命中等情況

3.2.4. traffic_server

如果伺服器down掉,默認會生成core文件,在/home/ts 使用

  /home/ts/bin/traffic_server -c core.1234
來閱讀coredump文件

[ 本帖最後由 ljh1405 於 2009-11-21 22:04 編輯 ]
《解決方案》

沒用過,學習一下!
《解決方案》

這個很早就有了,不過最近才被人們想起來

不知道與squid和varnish相比有何優勢~
《解決方案》

有是早有了,但是被yahoo收購后就成了yahoo專有的cache了。
上月yahoo才將其開源
《解決方案》

很不錯,我按照你的文檔配置成功了。

有個問題,在配置traffic server時,必須要配置remap.config 文件嗎?

如果不配置remap.config會怎樣。
《解決方案》

老兄,性能如何呀? 適合哪些環境下使用呢?
《解決方案》

如此龐大的軟體,擁有這麼多過時的功能,很難想象它的性能會好到哪去~

[火星人 ] traffic server 安裝配置已經有707次圍觀

http://coctec.com/docs/service/show-post-19245.html