- 论坛徽章:
- 0
|
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/ ... erver/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 编辑 ] |
|