friendlessstar 发表于 2018-12-26 10:20:17

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

    前言* 随着网站访问人数越来越多,承受的并发和压力也越来越高,这时候我们需要对网站和架构进行优化,今天我们来讨论使用Squid对架构进行优化,缓存网站。网上对squid描述的文章也有成千上万,我这里简单记录一下实践的步骤。

  一、实施环境
系统版本:CentOSx86_64 5.8
Squid版本:squid-2.6
Nginx版本:nginx-1.4.2  二、正式安装
     安装之前我们需要对系统进行优化,主要优化系统内核相关参数,仅供参考:
vi /etc/sysctl.conf
#sysctl.conf config 2014-03-26
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
net.ipv4.tcp_max_tw_buckets = 10000
net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_rmem = 4096      87380   4194304
net.ipv4.tcp_wmem = 4096      16384   4194304
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.netdev_max_backlog = 262144
net.core.somaxconn = 262144
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 15
net.ipv4.ip_local_port_range = 1024    65535  优化Linux文件打开最大数:
vi/etc/security/limits.conf
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535  接下来上自动安装Squid脚本,里面分别配置了两个虚拟主机域名,前端有LVS,LVS均衡后端多组squid集群,根据命中率去调整squid集群的数量,Squid后端均衡Nginx或者Apache。(完整的架构LVS+Keepalived+Squid+Nginx+Resin/Tomcat/PHP+MySQL集群)
  简单逻辑图如下:
http://s3.运维网.com/wyfs02/M00/23/21/wKiom1MyeQCSP8bRAAGXIgAao8Q437.jpg
  

  直接上脚本:
#!/bin/sh
#Auto make install squid server
#Author wugk 2014-03-26
SQUID_CNF=/etc/squid/squid.conf
CACHE_DIR=(
    /data/cache1
    /data/cache2
)
#Install squid shell
yum install -y squid
#config squid.conf
cat >>$SQUID_CNF >/dev/null
      if [ $? -eq 0 ];then
      echo -e "----------------------------------\nThe $line cache update successfully!"
      fi
done < list.txt  脚本执行:
# sh auto_clean_cache.sh forum.php
----------------------------------
The http://www.wugk2.com/forum.php cache update successfully!
#  更多squid优化及深入配置后期更新。。




页: [1]
查看完整版本: 高性能缓存服务器Squid架构配置