高性能缓存服务器Squid架构配置

一、实施环境

系统版本:CentOSx86_64 5.8Squid版本:squid-2.6Nginx版本:nginx-1.4.2

二、正式安装

安装之前我们需要对系统进行优化,主要优化系统内核相关参数,仅供参考:

#sysctl.conf config 2014-03-26net.ipv4.ip_forward = 0net.ipv4.conf.default.rp_filter = 1net.ipv4.conf.default.accept_source_route = 0kernel.sysrq = 0kernel.core_uses_pid = 1net.ipv4.tcp_syncookies = 1kernel.msgmnb = 65536kernel.msgmax = 65536kernel.shmmax = 68719476736kernel.shmall = 4294967296net.ipv4.tcp_max_tw_buckets = 10000net.ipv4.tcp_sack = 1net.ipv4.tcp_window_scaling = 1net.ipv4.tcp_rmem = 409687380 4194304net.ipv4.tcp_wmem = 409616384 4194304net.core.wmem_default = 8388608net.core.rmem_default = 8388608net.core.rmem_max = 16777216net.core.wmem_max = 16777216net.core.netdev_max_backlog = 262144net.core.somaxconn = 262144net.ipv4.tcp_max_orphans = 3276800net.ipv4.tcp_max_syn_backlog = 262144net.ipv4.tcp_timestamps = 0net.ipv4.tcp_synack_retries = 1net.ipv4.tcp_syn_retries = 1net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_mem = 94500000 915000000 927000000net.ipv4.tcp_fin_timeout = 1net.ipv4.tcp_keepalive_time = 15net.ipv4.ip_local_port_range = 1024 65535

简单逻辑图如下:

直接上脚本:

#!/bin/sh#Auto make install squid server#Author wugk 2014-03-26SQUID_CNF=/etc/squid/squid.confCACHE_DIR=(/data/cache1/data/cache2)#Install squid shellyum install -y squid#config squid.confcat >>$SQUID_CNF <<EOF#global config squid.conf 2014-03-26http_port 80 accel vhost vportcache_peer 192.168.149.128 parent 80 0 originserver name=wugk1cache_peer 192.168.149.129 parent 80 0 originserver name=wugk2cache_peer_domain wugk1 cache_peer_domain wugk2 visible_hostname localhostforwarded_for offvia offcache_vary on#acl configacl manager proto cache_objectacl localhost src 127.0.0.1/32acl to_localhost dst 127.0.0.0/8 0.0.0.0/32acl localnet src 10.0.0.0/8# RFC1918 possible internal networkacl localnet src 172.16.0.0/12 # RFC1918 possible internal networkacl localnet src 192.168.0.0/16 # RFC1918 possible internal networkacl SSL_ports port 443acl Safe_ports port 80 8080# httpacl Safe_ports port 21# ftpacl Safe_ports port 443# httpsacl all src 0.0.0.0/0acl CONNECT method CONNECThttp_access allow manager localhosthttp_access deny managerhttp_access deny !Safe_portshttp_access deny CONNECT !SSL_portshttp_access allow localnethttp_access allow localhosthttp_access allow allacl PURGE method PURGEhttp_access allow PURGE localhosthttp_access deny PURGE#squid config 2014-03-25cache_dir aufs /data/cache1 10240 16 256cache_dir aufs /data/cache2 10240 16 256cache_mem 4000 MBmaximum_object_size 8 MBmaximum_object_size_in_memory 256 KBhierarchy_stoplist cgi-bin ?coredump_dir /var/spool/squidrefresh_pattern ^ftp:1440 20%10080refresh_pattern ^gopher:1440 0%1440refresh_pattern -i (/cgi-bin/|\?) 00%0refresh_pattern \.(jpg|png|gif|mp3|xml|html|htm|css|js) 1440 50%2880 ignore-reloadrefresh_pattern .020%4320EOF#config cache_dirmkdir -p ${CACHE_DIR[@]} ;chown -R squid:squid ${CACHE_DIR[@]}#restart squid server/etc/init.d/squid restartif[ “$?” == “0” ];thenecho “The Squid Server Install Successfully !!”elseecho “The Squid Server Install Failed !!,Please Check Log……”fi

最后测试,前端LVS截图(注LVS此处不配置了,,博客有专门的安装方法)

通过浏览器查看head头,缓存命中情况截图如下:

通过命令

squidclient -p 80 mgr:info |egrep “(Request Hit Ratios|Byte Hit Ratios)”

查看缓存命中率如下:

更多squid优化及深入配置后期更新。。

本文出自 “吴光科-专注自动化运维” 博客,请务必保留此出处

思想如钻子,必须集中在一点钻下去才有力量

高性能缓存服务器Squid架构配置

相关文章:

你感兴趣的文章:

标签云: