半只蚂蚁 发表于 2018-12-27 12:42:05

Squid 开启大内存导致进程内存溢出解决方法

  squid 版本squid-2.7.STABLE9
  系统:centos5.564位
  编译选项如下:
./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这个参数
  意思是dlmalloc是squid在某些系统本身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库
  先别make,修改src/Makefile,搜索,在squid_LDADD后面加上-ltcmalloc,在LDADD后面也加上-ltcmalloc:

vi src/Makefile

squid_LDADD = \
-L../lib \
-ltcmalloc \ /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爱好者乐园&\_,RZ.Q8s
Description Squid by default does not log query parameters.These parameters are however forwarded to the server verbatim. If we want toenable logging of query parameters, the strip_query_terms directive can be used. By default, Squid strips query terms from requested URLs before logging. Thisprotects your user’s privacy
BpY2~-}rDefault         strip_query_terms on




页: [1]
查看完整版本: Squid 开启大内存导致进程内存溢出解决方法