squid3(高命中率)缓存服务器配置
今天对我的varnish进行了下小小的压力测试,40s里的8000并发,没有失败一个,估计还可以承受更大的并发,先不说varnish了,我最近找到个命中率很高的squid的配置文件,当然是squid3.0的配置文件,有需要的可以copy回去自己改.
系统:centos 5.x
需要的软件:squid-3.0.STABLE25.tar.gz
1.下载squid
wget http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE25.tar.gz
tar zxf squid-3.0.STABLE25.tar.gz && cd squid-3.0.STABLE25
2.编译squid
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里的内容:
4.创建目录
/usr/sbin/groupadd squid
/usr/sbin/useradd -g squid squid
mkdir -p /var/log/squid
chown -R squid:squid /var/log/squid
mkdir -p /var/{cache1,cache2}
chown -R squid: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的使用命令就只能你们自己去搜了,就到这里了.
系统:centos 5.x
需要的软件:squid-3.0.STABLE25.tar.gz
1.下载squid
wget http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE25.tar.gz
tar zxf squid-3.0.STABLE25.tar.gz && cd squid-3.0.STABLE25
2.编译squid
01 | ./configure --prefix=/usr/ local /squid \ |
02 | -- enable -async-io=100 \ |
03 | --with-pthreads \ |
04 | -- enable -storeio= "aufs,diskd,ufs" \ |
05 | -- enable -removal-policies= "heap,lru" \ |
06 | -- enable -icmp \ |
07 | -- enable -delay-pools \ |
08 | -- enable -useragent-log \ |
09 | -- enable -referer-log \ |
10 | -- enable - kill -parent-hack \ |
11 | -- enable -arp-acl \ |
12 | -- enable -default-err-language=Simplify_Chinese \ |
13 | -- enable -err-languages= "Simplify_Chinese English" \ |
14 | --disable-poll \ |
15 | --disable-wccp \ |
16 | --disable-wccpv2 \ |
17 | --disable-ident-lookups \ |
18 | --disable-internal-dns \ |
19 | -- enable -basic-auth-helpers= "NCSA" \ |
20 | -- enable -stacktrace \ |
21 | --with-large-files \ |
22 | --disable-mempools \ |
23 | --with-filedescriptors=65536 \ |
24 | -- enable -ssl \ |
25 | -- enable -x-accelerator-var |
26 |
27 | make |
28 | make install |
29 | make install -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里的内容:
001 | #accel listen port |
002 | http_port 80 accel vhost vport |
003 | #accel domain |
004 | cache_peer xx.xx.xx.xx parent 80 0 no-query originserver no-digest name=a |
005 | cache_peer_domain a blog.slogra.com |
006 | |
007 | #acl |
008 | acl manager proto cache_object |
009 | acl localhost src 127.0.0.1/255.255.255.255 |
010 | acl SSL_ports port 443 563 |
011 | acl Safe_ports port 80 # http |
012 | acl Safe_ports port 8080 |
013 | acl LanSrc src all |
014 | acl LanDst dst all |
015 | acl LanDstDM dstdomain blog.slogra.com |
016 | |
017 | acl CONNECT method CONNECT |
018 | http_access allow manager localhost |
019 | http_access deny manager |
020 | http_access deny !Safe_ports |
021 | http_access deny CONNECT !SSL_ports |
022 | http_access allow LanSrc |
023 | http_access allow LanDst |
024 | http_access allow LanDstDM |
025 | http_access deny all |
026 | |
027 | #base |
028 | visible_hostname blog.slogra.com |
029 | cache_mgr rocdk890@gmail.com |
030 | cache_effective_user squid |
031 | cache_effective_group squid |
032 | |
033 | error_directory /usr/ local /squid/share/errors/Simplify_Chinese |
034 | icon_directory /usr/ local /squid/share/icons |
035 | mime_table /usr/ local /squid/etc/mime.conf |
036 | |
037 | cache_replacement_policy lru |
038 | #cache_dir |
039 | cache_dir aufs /var/cache1 32768 64 64 |
040 | cache_dir aufs /var/cache2 32768 64 64 |
041 | cache_mem 2048 MB |
042 | max_open_disk_fds 0 |
043 | #maximum_object_size 512 KB |
044 | #maximum_object_size_in_memory 256 KB |
045 | maximum_object_size 20 MB |
046 | maximum_object_size_in_memory 8 MB |
047 | |
048 | #keepalived |
049 | client_persistent_connections off |
050 | server_persistent_connections on |
051 | #persistent_request_timeout 60 seconds |
052 | |
053 | #memory_pools on |
054 | #memory_pools_limit 64 MB |
055 | |
056 | forwarded_for on |
057 | log_icp_queries off |
058 | |
059 | via off |
060 | httpd_suppress_version_string off |
061 | |
062 | ie_refresh off |
063 | tcp_recv_bufsize 32 KB |
064 | |
065 | #acl webservices rep_header Server -i ^linuxtoneWS ^Apache ^nginx |
066 | #broken_vary_encoding allow webservices |
067 | |
068 | #hidden the squid header |
069 | #reply_header_access Server deny all |
070 | #reply_header_access X-Cache deny all |
071 | #reply_header_access Warning deny all |
072 | #reply_header_access Expires deny all |
073 | #reply_header_access Cache-Control deny all |
074 | #reply_header_access age deny all |
075 | #reply_header_access All deny all |
076 | |
077 | ipcache_size 1024 |
078 | ipcache_low 90 |
079 | ipcache_high 95 |
080 | |
081 | memory_replacement_policy lru |
082 | |
083 | hosts_file /etc/hosts |
084 | request_header_max_size 128 KB |
085 | |
086 | #deny cache |
087 | hierarchy_stoplist cgi-bin ? \.php |
088 | acl QUERY urlpath_regex cgi-bin\? \.php |
089 | cache deny QUERY |
090 | |
091 | #request_body_max_size 0 KB |
092 | |
093 | refresh_pattern ^ ftp : 60 20% 10080 |
094 | refresh_pattern ^gopher: 60 0% 1440 |
095 | refresh_pattern . 0 20% 1440 |
096 | refresh_pattern -i \.css$ 360 50% 2880 reload-into-ims |
097 | refresh_pattern -i \.js$ 1440 50% 2880 reload-into-ims |
098 | refresh_pattern -i \.html$ 720 50% 1440 reload-into-ims |
099 | refresh_pattern -i \.jpg$ 1440 90% 2880 ignore-reload |
100 | refresh_pattern -i \.gif$ 1440 90% 2880 ignore-reload |
101 | refresh_pattern -i \.swf$ 1440 90% 2880 ignore-reload |
102 | refresh_pattern -i \.jpg$ 1440 50% 2880 ignore-reload |
103 | refresh_pattern -i \.png$ 1440 50% 2880 ignore-reload |
104 | refresh_pattern -i \.bmp$ 1440 50% 2880 ignore-reload |
105 | |
106 | refresh_pattern -i \.doc$ 1440 50% 2880 ignore-reload |
107 | refresh_pattern -i \.ppt$ 1440 50% 2880 ignore-reload |
108 | refresh_pattern -i \.xls$ 1440 50% 2880 ignore-reload |
109 | refresh_pattern -i \.pdf$ 1440 50% 2880 ignore-reload |
110 | refresh_pattern -i \.rar$ 1440 50% 2880 ignore-reload |
111 | refresh_pattern -i \.zip$ 1440 50% 2880 ignore-reload |
112 | refresh_pattern -i \.txt$ 1440 50% 2880 ignore-reload |
113 | |
114 | quick_abort_min 20 KB |
115 | quick_abort_max 20 KB |
116 | quick_abort_pct 95 |
117 | |
118 | connect_timeout 1 minute |
119 | negative_ttl 0 minutes |
120 | read_timeout 30 seconds |
121 | pconn_timeout 120 seconds |
122 | shutdown_lifetime 5 seconds |
123 | strip_query_terms off |
124 | |
125 | #snmp |
126 | #snmp_port 3401 |
127 | #acl snmppublic snmp_orgmunity snsimg |
128 | #snmp_access allow snmppublic localhost |
129 | #snmp_access deny all |
130 | |
131 | icp_port 0 |
132 | |
133 | # logfile |
134 | emulate_httpd_log on |
135 | #logformat combined %{X-Forwarded-For}>h %ui %un [%tl] “%rm %ru HTTP/%rv” %Hs %<st “%{Referer}>h” “%{User-Agent}>h” %Ss:%Sh |
136 | #access_log none |
137 | #access_log /data/logs/access.log combined |
138 | logformat squid %ts.%03tu %6tr %>a %Ss/%03Hs %<st % rm %ru %un %Sh/%<A %mt |
139 | access_log /var/log/squid/access.log squid |
140 | #cache_store_log /var/log/squid/store.log |
141 | cache_store_log /dev/null |
142 | cache_log /var/log/squid/cache.log |
143 | logfile_rotate 12 |
144 | |
145 | # MISCELLANEOUS |
146 | store_objects_per_bucket 15 |
147 | client_db off |
4.创建目录
/usr/sbin/groupadd squid
/usr/sbin/useradd -g squid squid
mkdir -p /var/log/squid
chown -R squid:squid /var/log/squid
mkdir -p /var/{cache1,cache2}
chown -R squid: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的使用命令就只能你们自己去搜了,就到这里了.
评论: