(Squid缓存服务器篇)071229110003

  • 格式:pdf
  • 大小:179.25 KB
  • 文档页数:8

搭建一个大型网站架构的实验环境(Squid缓存服务器篇)2007/12/28 16:37六、squid缓存服务器的配置squid缓存服务器在这个实验环境中有两台(192.168.10.30,192.168.10.31)做成squid集群,我们首先安装一台,然后复制一台,再做配置,这样省事,哈!squid01服务器网络配置# ee /etc/rc.confifconfig_lnc0="inet 192.168.10.30 netmask 255.255.255.0"defaultrouter="192.168.10.10"hostname="squid01.rd.bj"# ee /etc/hosts192.168.10.30 squid01.rd.bj # ee /etc/resolv.confnameserver 192.168.10.40网络配置好后,我们开始安装squid,先把的藏身处找到:# whereis squid30squid30: /usr/ports/www/squid30# cd /usr/ports/www/squid30# make config #配置安装选项# make showconfig #我的配置选项===> The following configuration options are available for squid-3.0.1:SQUID_LDAP_AUTH=off "Install LDAP authentication helpers"SQUID_SASL_AUTH=off "Install SASL authentication helpers"SQUID_DELAY_POOLS=off "Enable delay pools"SQUID_SNMP=on "Enable SNMP support"SQUID_CARP=on "Enable CARP support"SQUID_SSL=off "Enable SSL support for reverse proxies"SQUID_PINGER=off "Install the icmp helper"SQUID_DNS_HELPER=off "Use the old 'dnsserver' helper"SQUID_HTCP=on "Enable HTCP support"SQUID_VIA_DB=off "Enable forward/via database"SQUID_CACHE_DIGESTS=on "Enable cache digests"SQUID_WCCP=on "Enable Web Cache Coordination Prot. v1"SQUID_WCCPV2=on "Enable Web Cache Coordination Prot. v2"SQUID_STRICT_HTTP=on "Be strictly HTTP compliant"SQUID_IDENT=on "Enable ident (RFC 931) lookups"SQUID_REFERER_LOG=on "Enable Referer-header logging"SQUID_USERAGENT_LOG=on "Enable User-Agent-header logging"SQUID_ARP_ACL=off "Enable ACLs based on ethernet address"SQUID_IPFW=off "Enable transparent proxying with IPFW"SQUID_PF=off "Enable transparent proxying with PF"SQUID_IPFILTER=off "Enable transp. proxying with IPFilter"SQUID_ICAP=off "Enable ICAP client functionality"SQUID_ESI=off "Enable ESI support (experimental)"SQUID_AUFS=off "Enable the aufs storage scheme"SQUID_COSS=off "Enable the COSS storage scheme"SQUID_KQUEUE=on "Use kqueue(2) (experimental)"SQUID_LARGEFILE=on "Support log and cache files >2GB"SQUID_STACKTRACES=off "Create backtraces on fatal errors"SQUID_DEBUG=off "Enable debugging options"===> Use 'make config' to modify these settings# make install clean漫长的安装过程又来了,我该干点什么呢?看看新浪互联星空播客吧!速度挺快的,支持!!!Squid安装好了,现在开始配置她了。

安装完后,在/usr/local/etc/squid下有squid的配置文件squid.conf和 squid.conf.default,这两个都是一样的,我们先删除掉squid.conf,在建个新的squid.conf,然后把我们的配置信息写在里面,这样的话更加清晰一点,省得在原来的配置文件中改,里面内容那么多,改到后来,自己都不知道改了那些东西,糊涂了,如果对配置有什么不清楚的还是可以参考squid.conf.default文件的。

# cd /usr/local/etc/squid# rm -rf squid.conf# touch squid.conf# ee squid.conf加入:http_port 192.168.10.30:3128 vhost vport defaultsite=www.rd.bjcache_mem 64 MBcache_swap_low 90cache_swap_high 95maximum_object_size 20 MBminimum_object_size 0 KBmaximum_object_size_in_memory 5 MBipcache_size 1024ipcache_low 90ipcache_high 95fqdncache_size 1024#acl all src 0.0.0.0/0.0.0.0 #好像squid30已经内置了acl gsrc src 192.168.10.20 192.168.10.30 192.168.10.31 192.168.10.40 http_access allow gsrcacl Manager proto cache_objectacl Localhost src 127.0.0.1http_access allow Manager Localhostacl Safe_ports port 3128 80 3130 3131http_access deny !Safe_portshttp_access allow allvisible_hostname squid01.rd.bjcache_mgr admin@rd.bjcache_effective_user squidcache_effective_group squidtcp_recv_bufsize 65536 bytescache_peer 192.168.10.31 sibling 3128 3131cache_peer_access 192.168.10.31 allow allcache_peer 192.168.10.40 parent 80 0 no-query originserver no-digestaccess_log /usr/local/squid/logs/access.logcache_dir diskd /usr/local/squid/cache 256 16 256 Q1=60 Q2=50error_directory /usr/local/etc/squid/errors/Simplify_Chineseicp_port 3130htcp_port 0icp_query_timeout 2000icp_access allow alldigest_generation onlog_icp_queries onicp_hit_stale on保存退出后,我们验证一下配置文件是否正确:# rehash# squid parse如果没有什么信息出现的话,恭喜你,配置无误!OK,现在我们先根据配置文件创建缓存目录。

# squid -z2007/12/27 12:43:55| Creating Swap Directories2007/12/27 12:43:55| /usr/local/squid/cache exists2007/12/27 12:43:55| Making directories in /usr/local/squid/cache/002007/12/27 12:43:55| Making directories in /usr/local/squid/cache/012007/12/27 12:43:55| Making directories in /usr/local/squid/cache/022007/12/27 12:43:55| Making directories in /usr/local/squid/cache/032007/12/27 12:43:56| Making directories in /usr/local/squid/cache/042007/12/27 12:43:56| Making directories in /usr/local/squid/cache/052007/12/27 12:43:57| Making directories in /usr/local/squid/cache/062007/12/27 12:43:58| Making directories in /usr/local/squid/cache/072007/12/27 12:43:58| Making directories in /usr/local/squid/cache/082007/12/27 12:43:59| Making directories in /usr/local/squid/cache/092007/12/27 12:43:59| Making directories in /usr/local/squid/cache/0A2007/12/27 12:43:59| Making directories in /usr/local/squid/cache/0B2007/12/27 12:43:59| Making directories in /usr/local/squid/cache/0C2007/12/27 12:44:00| Making directories in /usr/local/squid/cache/0D2007/12/27 12:44:00| Making directories in /usr/local/squid/cache/0E2007/12/27 12:44:01| Making directories in /usr/local/squid/cache/0F这样就创建完成了。