linux中squid3(高命中率)缓存服务器配置
quid cache(简称为Squid)是一个流行的自由软件(GNU通用公共许可证)的代理服务器和Web缓存服务器。Squid有广泛的用途,从作为网页服务器的前置cache服务器缓存相关请求来提高Web服务器的速度,到为一组人共享网络资源而缓存万维网,域名系统和其他网络搜索,到通过过滤流量帮助网络安全,到局域网通过代理上网。Squid主要设计用于在Unix一类系统运行,下面我们来看看squid3(高命中率)缓存服务器配置教程。
今天对我的varnish进行了下小小的压力测试,40s里的8000并发,没有失败一个,估计还可以承受更大的并发,先不说varnish了,我最近找到个命中率很高的squid的配置文件,当然是squid3.0的配置文件,有需要的可以copy回去自己改.
系统:centos 5.x
需要的软件:squid-3.0.STABLE25.tar.gz
1.下载squid
- wgethttp://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE25.tar.gz
- tarzxfsquid-3.0.STABLE25.tar.gz&&cdsquid-3.0.STABLE25
2.编译squid,代码如下:
- ./configure--prefix=/usr/local/squid
- --enable-async-io=100
- --with-pthreads
- --enable-storeio="aufs,diskd,ufs"
- --enable-removal-policies="heap,lru"
- --enable-icmp
- --enable-delay-pools
- --enable-useragent-log
- --enable-referer-log
- --enable-kill-parent-hack
- --enable-arp-acl
- --enable-default-err-language=Simplify_Chinese
- --enable-err-languages="Simplify_ChineseEnglish"
- --disable-poll
- --disable-wccp
- --disable-wccpv2
- --disable-ident-lookups
- --disable-internal-dns
- --enable-basic-auth-helpers="NCSA"
- --enable-stacktrace
- --with-large-files
- --disable-mempools
- --with-filedescriptors=65536
- --enable-ssl
- --enable-x-accelerator-var
- make
- makeinstall
- makeinstall-pinger
3.配置squid,代码如下:
- cp/usr/local/squid/etc/squid.conf/usr/local/squid/etc/squid.conf.old
- >/usr/local/squid/etc/squid.conf
- ln-s/usr/local/squid/etc/squid.conf/etc/squid.conf
squid.conf里的内容,代码如下:
- #accellistenport
- http_port80accelvhostvport
- #acceldomain
- cache_peerxx.xx.xx.xxparent800no-queryoriginserverno-digestname=a
- cache_peer_domainawww.phpfensi.com
- #acl
- aclmanagerprotocache_object
- acllocalhostsrc127.0.0.1/255.255.255.255
- aclSSL_portsport443563
- aclSafe_portsport80#http
- aclSafe_portsport8080
- aclLanSrcsrcall
- aclLanDstdstall
- aclLanDstDMdstdomainwww.phpfensi.com
- aclCONNECTmethodCONNECT
- http_accessallowmanagerlocalhost
- http_accessdenymanager
- http_accessdeny!Safe_ports
- http_accessdenyCONNECT!SSL_ports
- http_accessallowLanSrc
- http_accessallowLanDst
- http_accessallowLanDstDM
- http_accessdenyall
- #base
- visible_hostnamewww.phpfensi.com
- cache_mgrrocdk890@gmail.com
- cache_effective_usersquid
- cache_effective_groupsquid
- error_directory/usr/local/squid/share/errors/Simplify_Chinese
- icon_directory/usr/local/squid/share/icons
- mime_table/usr/local/squid/etc/mime.conf
- cache_replacement_policylru
- #cache_dir
- cache_diraufs/var/cache1327686464
- cache_diraufs/var/cache2327686464
- cache_mem2048MB
- max_open_disk_fds0
- #maximum_object_size512KB
- #maximum_object_size_in_memory256KB
- maximum_object_size20MB
- maximum_object_size_in_memory8MB
- #keepalived
- client_persistent_connectionsoff
- server_persistent_connectionson
- #persistent_request_timeout60seconds
- #memory_poolson
- #memory_pools_limit64MB
- forwarded_foron
- log_icp_queriesoff
- viaoff
- httpd_suppress_version_stringoff
- ie_refreshoff
- tcp_recv_bufsize32KB
- #aclwebservicesrep_headerServer-i^linuxtoneWS^Apache^nginx
- #broken_vary_encodingallowwebservices
- #hiddenthesquidheader
- #reply_header_accessServerdenyall
- #reply_header_accessX-Cachedenyall
- #reply_header_accessWarningdenyall
- #reply_header_accessExpiresdenyall
- #reply_header_accessCache-Controldenyall
- #reply_header_accessagedenyall
- #reply_header_accessAlldenyall
- ipcache_size1024
- ipcache_low90
- ipcache_high95
- memory_replacement_policylru
- hosts_file/etc/hosts
- request_header_max_size128KB
- #denycache
- hierarchy_stoplistcgi-bin?.php
- aclQUERYurlpath_regexcgi-bin?.php
- cachedenyQUERY
- #request_body_max_size0KB
- refresh_pattern^ftp:6020%10080
- refresh_pattern^gopher:600%1440
- refresh_pattern.020%1440
- refresh_pattern-i.css$36050%2880reload-into-ims
- refresh_pattern-i.js$144050%2880reload-into-ims
- refresh_pattern-i.html$72050%1440reload-into-ims
- refresh_pattern-i.jpg$144090%2880ignore-reload
- refresh_pattern-i.gif$144090%2880ignore-reload
- refresh_pattern-i.swf$144090%2880ignore-reload
- refresh_pattern-i.jpg$144050%2880ignore-reload
- refresh_pattern-i.png$144050%2880ignore-reload
- refresh_pattern-i.bmp$144050%2880ignore-reload
- refresh_pattern-i.doc$144050%2880ignore-reload
- refresh_pattern-i.ppt$144050%2880ignore-reload
- refresh_pattern-i.xls$144050%2880ignore-reload
- refresh_pattern-i.pdf$144050%2880ignore-reload
- refresh_pattern-i.rar$144050%2880ignore-reload
- refresh_pattern-i.zip$144050%2880ignore-reload
- refresh_pattern-i.txt$144050%2880ignore-reload
- quick_abort_min20KB
- quick_abort_max20KB
- quick_abort_pct95
- connect_timeout1minute
- negative_ttl0minutes
- read_timeout30seconds
- pconn_timeout120seconds
- shutdown_lifetime5seconds
- strip_query_termsoff
- #snmp
- #snmp_port3401
- #aclsnmppublicsnmp_orgmunitysnsimg
- #snmp_accessallowsnmppubliclocalhost
- #snmp_accessdenyall
- icp_port0
- #logfile
- emulate_httpd_logon
- #logformatcombined%{X-Forwarded-For}>h%ui%un[%tl]“%rm%ruHTTP/%rv”%Hs%<st“%{Referer}>h”“%{User-Agent}>h”%Ss:%Sh
- #access_lognone
- #access_log/data/logs/access.logcombined
- logformatsquid%ts.%03tu%6tr%>a%Ss/%03Hs%<st%rm%ru%un%Sh/%<A%mt
- access_log/var/log/squid/access.logsquid
- #cache_store_log/var/log/squid/store.log
- cache_store_log/dev/null
- cache_log/var/log/squid/cache.log
- logfile_rotate12
- #MISCELLANEOUS
- store_objects_per_bucket15
- client_dboff
4.创建目录,代码如下:
- /usr/sbin/groupaddsquid
- /usr/sbin/useradd-gsquidsquid
- mkdir-p/var/log/squid
- chown-Rsquid:squid/var/log/squid
- mkdir-p/var/{cache1,cache2}
- chown-Rsquid:squid/var/{cache1,cache2}
初始化squid的cache目录:
/usr/local/squid/sbin/squid -z
启动squid:
/usr/local/squid/sbin/squid -D
如果大家不喜欢这样的启动方式,可以自己去找个squid的启动脚本,这里就不放出了.当squid运行起来了之后,大家可以使用下面这个命令来查看命中率:
/usr/local/squid/bin/squidclient -p 80 mgr:info
好了,具体其他squid的使用命令就只能你们自己去搜了,就到这里了.
热门评论