• Squid升级到2.7 - [技术笔记]

    2009-04-08

    分类: 技术笔记

    版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
    http://iyubo.blogbus.com/logs/37616762.html

    图片缓存换成squid以后仍然会出现子进程因为out of memory问题重启的现象,严重的是squid子进程重启以后会重建缓存,虽然这段时间只有不到1分钟,但是重建的时候还是会影响线上服务。在查询了官方文档后决定将squid升级到2.7再观察观察。

    有了2.6的经验,这次安装配置的时候详细了许多,2.7跟2.6的主要不同可以参考2.7的Release Notes

    具体的安装配置方法(只说跟2.6不同的地方,之前的安装过程请参考这里

    #./configure --prefix=/usr/local/squid2.7 --enable-dlmalloc --enable-xmalloc-statistics --enable-useragent-log --enable-referer-log --enable-epoll --enable-large-cache-files --disable-internal-dns --enable-linux-netfilter --enable-truncate --enable-x-accelerator-vary --enable-follow-x-forwarded-for --with-large-files

    #make && make install

    配置文件(squid.conf),只把新增的配置文件用红色标注出来了,2.7的配置可以参考官方的cfgman

    acl all src 0.0.0.0/0.0.0.0
    acl manager proto cache_object
    acl localhost src 127.0.0.1/255.255.255.255
    acl to_localhost dst 127.0.0.0/8
    acl SSL_ports port 443
    acl Safe_ports port 80
    acl safeprotocol protocol HTTP
    acl allowmethod method GET POST HEAD
    acl CONNECT method CONNECT
    acl mtime dstdomain .test.com
    acl has_referer referer_regex .
    acl allow_referer referer_regex -i 10\.10\.10\.*
    acl allow_referer referer_regex -i baidu\.com
    acl allow_referer referer_regex -i google\.com
    acl allow_referer referer_regex -i google\.cn

    http_access allow !has_referer
    http_access deny !allow_referer
    deny_info http://img1.test.com/images/default/noposter.jpg allow_referer

    http_access allow manager localhost
    http_access deny manager
    http_access allow safeprotocol Safe_ports allowmethod mtime
    http_access deny !allowmethod
    http_access deny !Safe_ports
    http_access deny CONNECT !SSL_ports
    #http_access deny to_localhost
    http_access deny all
    icp_access allow all

    http_port 10.10.10.25:80 accel defaultsite=59.151.32.58 vhost act-as-origin http11
    always_direct allow all

    cache_peer 10.10.10.8 parent 3080 0 no-query originserver name=imgserver http11
    cache_peer_domain imgserver img.test.com img3.test.com

    hierarchy_stoplist cgi-bin ?

    cache_mem 1845 MB
    maximum_object_size_in_memory 2 KB
    memory_replacement_policy lru

    cache_replacement_policy lru
    cache_dir ufs /srv/scache_new 40000 16 256
    minimum_object_size 0 KB
    maximum_object_size 2048 KB

    cache_swap_low 90
    cache_swap_high 95

    via off

    logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st "%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh

    access_log /var/log/squid/access.log squid
    cache_log /var/log/squid/cache.log
    cache_store_log /var/log/squid/store.log

    logfile_rotate 24
    emulate_httpd_log on

    #acl QUERY urlpath_regex cgi-bin \?
    #cache deny QUERY

    refresh_pattern -i \.jpg 60 90% 1440
    refresh_pattern -i \.png 60 90% 1440
    refresh_pattern -i \.gif 60 90% 1440

    quick_abort_min 16 KB
    quick_abort_max 16 KB
    quick_abort_pct 95

    request_header_max_size 10 KB
    reply_header_max_size 10 KB

    #去掉Response Header中的X-Origin-Date字段
    header_access X-Origin-Date deny all

    #支持HTTP1.1
    server_http11 on

    #相当于设定ulimit
    max_filedescriptors 65535

    #此值越小squid越频繁的接受新的连接请求
    incoming_rate 30

    forward_timeout 4 minutes
    connect_timeout 3 minutes
    peer_connect_timeout 30 seconds
    read_timeout 15 minutes
    request_timeout 1 minute
    persistent_request_timeout 3 minutes
    half_closed_clients off
    pconn_timeout 1 minute

    cache_mgr flyincat@gmail.com

    cache_effective_user squid
    cache_effective_group squid

    visible_hostname img-squid-server

    coredump_dir /var/log/squid/cache

    参考文档

    http://www.squid-cache.org/Versions/v2/2.7/squid-2.7.STABLE6-RELEASENOTES.html

    http://www.squid-cache.org/Versions/v2/2.7/cfgman/


    历史上的今天:


    收藏到:Del.icio.us




    评论

  • 博主,怎么联系你呢,我给你发了EMAIL
  • 想问问博主squid2.7中squid.conf的具体配置,生产环境中的squid想升级到2.7 先测试下
    Kevin回复mdnght说:
    如果是小图片或者js/css的话推荐用Varnish吧,真的很好
    2009-04-27 18:17:38
  • MSN: white_sail@hotmail.com

    我在测试2.7的新特性
    现在生产环境中使用的是2.6

    想请教下2.7比2.6有多少性能的提升

    谢谢
    Kevin回复mdnght说:
    其实我自己的个人体验是性能上没多少差别,主要的一个功能是2.7支持了3.0都没支持的http1.1
    2009-04-27 18:14:23
  • 关于squid2.7 我有些问题想请教下
    能联系我么
    谢谢


    Kevin回复mdnght说:
    呵呵,就在这里说呗:)
    而且你联系方式都没有
    2009-04-21 09:19:06
  • 关于squid2.7 我有些问题想请教下
    能联系我么
    谢谢