squid 版本squid-2.7.STABLE9

系统:centos5.5  64位

编译选项如下:

./configure --prefix=/a8root/bin/squid2.7/ --with-pthreads --enable-forward-log --enable-follow-x-forwarded-for --enable-dlmalloc --enable-xmalloc-statistics --enable-large-cache-files --with-large-files --enable-epoll --enable-snmp --with-maxfd=65535 --enable-removal-policies=heap,lru --libdir=/usr/lib64 --includedir=/usr/include -enable-cache-digests --enable-cachemgr-hostname --enable-icmp --enable-storeio=aufs,ufs,diskd,coss   --enable-async-io=40
make
make install
make install-pinger

部分配置如下:

cache_swap_low 90
cache_swap_high 95
cache_mem 10240 MB
maximum_object_size 20000 KB
maximum_object_size_in_memory 4096 KB
minimum_object_size 0 KB

range_offset_limit -1 KB
quick_abort_min 50 KB
quick_abort_max 100 KB
quick_abort_pct 75

refresh_pattern -i .aac 86400 90% 129600 override-expire override-lastmod reload-into-ims ignore-reload ignore-no-cache ignore-private

 

故障:

运行一段时间,squid自动重启,查看日志报错FATAL: xcalloc: Unable to allocate 1 blocks of 4112 bytes!

原因:编译打开了-enable-dlmalloc这个参数

意思是dlmallocsquid在某些系统本身malloc太烂的情况的代替方案,dlmalloc已经很老,且不支持2G以上内存。

编译时候一定要把--enable-dlmalloc  去掉。

 

=======================================================

安装 tcmalloc

./configure --prefix=/a8root/bin/squid2.7/ --with-pthreads --enable-forward-log --enable-follow-x-forwarded-for --enable-xmalloc-statistics --enable-large-cache-files --with-large-files --enable-epoll --enable-snmp --with-maxfd=65535 --enable-removal-policies=heap,lru --libdir=/usr/lib64 --includedir=/usr/include -enable-cache-digests --enable-cachemgr-hostname --enable-icmp --enable-storeio=aufs,ufs,diskd,coss --enable-async-io=320
 

 

 1,安装tcmalloc所需的libunwind库[32位系统无须安装]

先别make,修改src/Makefile,搜索,在squid_LDADD后面加上-ltcmalloc,在LDADD后面也加上-ltcmalloc:

vi src/Makefile

 squid_LDADD = \

-L../lib \

-ltcmalloc \ <----加入这一行

\

repl/libheap.a repl/liblru.a \

....

....

 

data_DATA = \

mib.txt

 LDADD = -L../lib -lmiscutil -lpthread -lm -lbsd -lnsl -ltcmalloc

EXTRA_DIST = \

 

然后再 

make
make install
make install-pinger

 

wget http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99-alpha.tar.gz

tar zxvf libunwind-0.99-alpha.tar.gz

cd libunwind-0.99-alpha/

CFLAGS=-fPIC

./configure

make CFLAGS=-fPIC

make CFLAGS=-fPIC install

2,安装tcmalloc

wget http://google-perftools.googlecode.com/files/google-perftools-0.97.tar.gz

tar zxvf google-perftools-0.97.tar.gz

cd google-perftools-0.97/

./configure

make && make install

默认安装时,libunwind与tcmalloc库均安装至/usr/local/lib

3,配置动态连接库

echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf

/sbin/ldconfig


4,squid使用tcmalloc的方法

 

 

公司要在分析access_log日志,但怎么样也见不到?后面的url的内容查了很多资料,最后发现.squid的access_log缺省是不记url里”?”后面的内容的原来在squid.conf里有个叫”strip_query_terms“的参数,缺省是打开的(ON) 设成off即可 squid文档里是这么写的:BSD爱好者乐园j-n ixOt%r9T)E/`2g
Tag Name         strip_qury_terms
)@)oB#h?ls3mUsage         strip_query_terms on|offBSD爱好者乐园0{ P4O-zw;S:z U+k
BSD爱好者乐园&\_,R Z.Q8s
Description Squid by default does not log query parameters. These parameters are however forwarded to the server verbatim. If we want to enable logging of query parameters, the strip_query_terms directive can be used . By default, Squid strips query terms from requested URLs before logging. This protects your user’s privacy
BpY2~-}rDefault         strip_query_terms on