编译安装Apache Traffic Server
编译安装
Centos下编译安装
yum update -y && yum install wget gcc g++ gcc-c++ glibc-headers perl openssl openssl-devel tcl-devel libxml2-devel pcre-devel
wget http://apache.fayea.com/trafficserver/trafficserver-6.1.1.tar.bz2
tar xvjf trafficserver-6.1.1.tar.bz2
cd trafficserver-6.1.1
./configure
make && make install
useradd -s /sbin/nologin trafficserver
Apache镜像http://archive.apache.org/dist/
国内Apache镜像http://apache.fayea.com/
编译完成后,就可以使用了,默认是安装在/usr/local/bin
,编译后是比较大
total 98M
-rwxr-xr-x 1 root root 692K May 9 14:30 header_rewrite_test
-rwxr-xr-x 1 root root 520K May 9 14:30 traffic_cop
-rwxr-xr-x 1 root root 1.9M May 9 14:30 traffic_crashlog
-rwxr-xr-x 1 root root 259K May 9 14:30 traffic_ctl
-rwxr-xr-x 1 root root 1.9M May 9 14:30 traffic_layout
-rwxr-xr-x 1 root root 41K May 9 14:30 traffic_line
-rwxr-xr-x 1 root root 4.4M May 9 14:30 traffic_logcat
-rwxr-xr-x 1 root root 5.0M May 9 14:30 traffic_logstats
-rwxr-xr-x 1 root root 4.7M May 9 14:30 traffic_manager
-rwxr-xr-x 1 root root 37M May 9 14:30 traffic_sac
-rwxr-xr-x 1 root root 43M May 9 14:30 traffic_server
-rwxr-xr-x 1 root root 42K May 9 14:30 traffic_via
-rwxr-xr-x 1 root root 18K May 9 14:30 trafficserver
-rwxr-xr-x 1 root root 2.1K May 9 14:30 tspush
-rwxr-xr-x 1 root root 5.7K May 9 14:30 tsxs
运行traffic_server -R 1
执行测试,经过一系列测试后,显示
Tests Passed: 177
Tests Failed: 0
REGRESSION_RESULT PARENTSELECTION: PASSED
REGRESSION_TEST DONE: PASSED
全部测试通过
使用
默认的配置文件存放在/usr/local/etc/trafficserver
drwxr-xr-x 3 nobody nobody 1.0K May 9 14:30 body_factory
-rw-r--r-- 1 nobody nobody 1.7K May 9 14:30 cache.config
-rw-r--r-- 1 nobody nobody 657 May 9 14:30 cluster.config
-rw-r--r-- 1 nobody nobody 1.9K May 9 14:30 congestion.config
-rw-r--r-- 1 nobody nobody 746 May 9 14:30 hosting.config
-rw-r--r-- 1 nobody nobody 1.8K May 9 14:30 icp.config
-rw-r--r-- 1 nobody nobody 1.2K May 9 14:30 ip_allow.config
-rw-r--r-- 1 nobody nobody 328 May 9 14:30 log_hosts.config
-rw-r--r-- 1 nobody nobody 17K May 9 14:30 logs_xml.config
-rw-r--r-- 1 nobody nobody 1.4K May 9 14:30 parent.config
-rw-r--r-- 1 nobody nobody 261 May 9 14:30 plugin.config
-rw-r--r-- 1 nobody nobody 13K May 9 14:30 records.config
-rw-r--r-- 1 nobody nobody 8.6K May 9 14:30 remap.config
-rw-r--r-- 1 nobody nobody 1.7K May 9 14:30 socks.config
-rw-r--r-- 1 nobody nobody 2.1K May 9 14:30 splitdns.config
-rw-r--r-- 1 nobody nobody 2.7K May 9 14:30 ssl_multicert.config
-rw-r--r-- 1 nobody nobody 76K May 9 14:30 stats.config.xml
-rw-r--r-- 1 nobody nobody 1.9K May 9 14:30 storage.config
-rw-r--r-- 1 root root 19 May 9 14:30 trafficserver-release
-rw-r--r-- 1 nobody nobody 649 May 9 14:30 vaddrs.config
-rw-r--r-- 1 nobody nobody 1.3K May 9 14:30 volume.config
records.config
负责大部分全局的选项设置,即主要配置文件
CONFIG proxy.config.reverse_proxy.enabled INT 1 # 开启反向代理
CONFIG proxy.config.url_remap.remap_required INT 1 # 1 代理反向代理,0代表正向+反向代理
CONFIG proxy.config.http.cache.http INT 1 # 打开http缓存功能
CONFIG proxy.config.cache.ram_cache.size INT 512M # RAM 缓存大小
CONFIG proxy.config.http.keep_alive_no_activity_timeout_out INT 120 # 当一个事务结束后同原服务器保持连接的时间
CONFIG proxy.config.cluster.ethernet_interface STRING eth0 # 修改成需要侦听的interface名称
remap.config
定义映射规则,用于请求的重定向(rewrite),反向代理即在此配置
storage.config
用于指定磁盘存储
启动trafficserver start
varnish编译
alpine中编译
apk update && apk upgrade
apk --update add gcc g++ make wget curl m4 automake autoconf libtool linux-headers py-docutils ncurses-dev pcre-dev libedit-dev
cd /tmp
VARNISH_VERSION=varnish-4.1.3
CPU_NUM=`cat /proc/cpuinfo | grep processor | wc -l`
wget https://repo.varnish-cache.org/source/${VARNISH_VERSION}.tar.gz
tar xzf ${VARNISH_VERSION}.tar.gz
cd ${VARNISH_VERSION}
./configure
make CFLAGS="-Os" CPPFLAGS=-D__NEED_mode_t -j$CPU_NUM && make install
strip -s /usr/local/bin/* /usr/local/sbin/* /usr/local/lib/varnish/*.so /usr/local/lib/varnish/vmods/*.so
varnishd -V
varnish基本使用
varnish / squid / nginx 优缺点讨论 见 http://www.zhihu.com/question/20143441
https://github.com/jiangwenyuan/nuster/wiki/Performance-benchmark:-nuster-vs-nginx-vs-varnish