SQUID3 cache server compile installation and high hit rate configuration sample _ Server Other

Source: Internet
Author: User
Tags mkdir varnish

Today, my varnish carried out a small pressure test, 40s 8000 concurrency, no failure, an estimate can withstand a greater concurrency, not to mention varnish, I recently found a high percentage of squid profile, of course, squid3.0 configuration file, There is a need to copy back to their own change.

System: CentOS 5.x
Required Software: squid-3.0.stable25.tar.gz

1. Download Squid

Copy Code code as follows:

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. Compile Squid


Copy Code code as follows:

./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_chinese 中文版" \
--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
Make install
Make Install-pinger

3. Configure Squid

Copy Code code as follows:

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

Contents of squid.conf:


Copy Code code as follows:

#accel Listen Port
Http_port Accel Vhost Vport
#accel Domain
Cache_peer xx.xx.xx.xx Parent 0 no-query originserver no-digest name=a
Cache_peer_domain a blog.slogra.com

#acl
ACL manager Proto Cache_object
ACL localhost src 127.0.0.1/255.255.255.255
ACL ssl_ports Port 443 563
ACL safe_ports Port # http
ACL safe_ports Port 8080
ACL lansrc src All
ACL LANDST DST All
ACL LANDSTDM Dstdomain blog.slogra.com

ACL Connect method Connect
Http_access allow manager localhost
Http_access Deny Manager
Http_access Deny! Safe_ports
Http_access Deny CONNECT! Ssl_ports
Http_access Allow LANSRC
Http_access Allow LANDST
Http_access Allow LANDSTDM
Http_access Deny All

#base
Visible_hostname blog.slogra.com
Cache_mgr rocdk890@gmail.com
Cache_effective_user Squid
Cache_effective_group Squid

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_policy LRU
#cache_dir
Cache_dir Aufs/var/cache1 32768 64 64
Cache_dir Aufs/var/cache2 32768 64 64
Cache_mem 2048 MB
Max_open_disk_fds 0
#maximum_object_size MB KB
#maximum_object_size_in_memory 256 KB
Maximum_object_size MB
Maximum_object_size_in_memory 8 MB

#keepalived
Client_persistent_connections off
Server_persistent_connections on
#persistent_request_timeout seconds

#memory_pools on
#memory_pools_limit MB

Forwarded_for on
Log_icp_queries off

Via off
Httpd_suppress_version_string off

Ie_refresh off
tcp_recv_bufsize MB

#acl webservices rep_header server-i ^linuxtonews ^apache ^nginx
#broken_vary_encoding Allow WebServices

#hidden The squid header
#reply_header_access Server deny all
#reply_header_access X-cache deny all
#reply_header_access Warning deny all
#reply_header_access Expires deny all
#reply_header_access Cache-control deny all
#reply_header_access Age Deny all
#reply_header_access all deny all

Ipcache_size 1024
Ipcache_low 90
Ipcache_high 95

Memory_replacement_policy LRU

Hosts_file/etc/hosts
Request_header_max_size 128 KB

#deny Cache
Hierarchy_stoplist Cgi-bin? \.php
ACL QUERY Urlpath_regex cgi-bin\? \.php
Cache Deny QUERY

#request_body_max_size 0 KB

Refresh_pattern ^ftp:60 20% 10080
Refresh_pattern ^gopher:60 0% 1440
Refresh_pattern. 0 20% 1440
Refresh_pattern-i \.css$ 360 50% 2880 reload-into-ims
Refresh_pattern-i \.js$ 1440 50% 2880 reload-into-ims
Refresh_pattern-i \.html$ 720 50% 1440 Reload-into-ims
Refresh_pattern-i \.jpg$ 1440 90% 2880 ignore-reload
Refresh_pattern-i \.gif$ 1440 90% 2880 ignore-reload
Refresh_pattern-i \.swf$ 1440 90% 2880 ignore-reload
Refresh_pattern-i \.jpg$ 1440 50% 2880 ignore-reload
Refresh_pattern-i \.png$ 1440 50% 2880 ignore-reload
Refresh_pattern-i \.bmp$ 1440 50% 2880 ignore-reload

Refresh_pattern-i \.doc$ 1440 50% 2880 ignore-reload
Refresh_pattern-i \.ppt$ 1440 50% 2880 ignore-reload
Refresh_pattern-i \.xls$ 1440 50% 2880 ignore-reload
Refresh_pattern-i \.pdf$ 1440 50% 2880 ignore-reload
Refresh_pattern-i \.rar$ 1440 50% 2880 ignore-reload
Refresh_pattern-i \.zip$ 1440 50% 2880 ignore-reload
Refresh_pattern-i \.txt$ 1440 50% 2880 ignore-reload

Quick_abort_min KB
Quick_abort_max KB
quick_abort_pct 95

Connect_timeout 1 minute
Negative_ttl 0 Minutes
Read_timeout seconds
Pconn_timeout seconds
Shutdown_lifetime 5 Seconds
Strip_query_terms off

#snmp
#snmp_port 3401
#acl snmppublic snmp_orgmunity snsimg
#snmp_access Allow snmppublic localhost
#snmp_access Deny All

Icp_port 0

# logfile
Emulate_httpd_log on
#logformat combined%{x-forwarded-for}>h%ui%un [%tl] "%rm%ru" HTTP/%RV "%Hs%<st"%{referer}>h ""%{user-agent}& Gt;h "%ss:%sh
#access_log None
#access_log/data/logs/access.log combined
Logformat Squid%ts.%0 3tu%6tr%>a%ss/%03hs%<st%rm%ru%un%sh/%<a%mt
Access_log/var/log/squid/access.log Squid
#cache_store_log/var/log/squid/store.log
Cache_store_log/dev/null
Cache_log/var/log/squid/cache.log
Logfile_rotate 12

# Miscellaneous
Store_objects_per_bucket 15
client_db off

4. Create a table of contents


Copy Code code as follows:

/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}

Cache Directory of initialized squid
Copy Code code as follows:

/usr/local/squid/sbin/squid-z

Start squid
Copy Code code as follows:

/usr/local/squid/sbin/squid-d

If you do not like this way, you can find a squid to start the script, here is not released. When squid runs, you can use the following command to view the hit rate:
Copy Code code as follows:

/usr/local/squid/bin/squidclient-p Mgr:info

Well, the specific use of other SQUID commands can only you go to search, it is here.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.