tilg 发表于 2015-9-3 08:30:05

squid调整

  Squid采用新方案部署的调整步骤
一,隔离
二,修改
三,验证
四,波及
==============================
把被引用到的待修改对像实例,从前端应用负载nginx的配置中摘出
  比如cdn节点XX截止2014-10-10,对外提供服务的2个节点是111.222,111.223
登录上述2台主机,修改nginx配置文件,注释掉引用到待修改对象主机111.225的内网地址172.0.0.X行。
.../sbin/nginx -t
.../sbin/nginx -reload
   
在对像主机上检查已经没有生成新的连接
在待修改节点上如:111.225上,查看nginx日志 ,如果不直接对提供服务的话,也可以查看squid日志
由于squid日志太大,一般不配置;
所以也可以直接查看当前连接:
# nempptat -an | grep 61
   创建一个自动编译的脚本(注意,使用的版本是本公司在官方2.7基础上修改后的)
  以下引用tongshi创建的范例:
#!/bin/bash
  squid_install_dir='/usr/local/xiangmu/'
squid_insance=(squid1 squid2 squid3)
squid_package='/root/squid-2.7.tar.gz'
squid_tar_dir='/root/squid-2.7.本公司-modified/'
  if [ -e $squid_package ]; then
    tar -xzvf $squid_package
else
    echo "squid don't exismpp"
fi
  if [ -e $squid_tar_dir ]; then
    cd $squid_tar_dir
    for squid in ${squid_insance[@]}
    do
       echo $squid
       ./configure --prefix=/usr/local/xiangmu/$squid --enable-storeio=ufs,aufs,coss --disable-wccp --disable-wccpv2
       make
       make install
       make clean
    done
fi
  
停止旧有的squid实例,删除旧有的cache目录,重建新规划的cache目录;
  # /usr/local/xiangmu/squid/sbin/squid -h
-k reconfigure|rotate|shutdown|interrupt|kill|debug|check|parse
               Parse configuration file, then send signal to
               running copy (except -k parse) and exit.
  # /usr/local/xiangmu/squid/sbin/squid -k shutdown
  查看既有的配置文件,注意到有如下段落:
cache_mem 6192 MB
50 cache_dir aufs /data/sto/ca 5000000 16 256
51 cache_dir aufs /data/sto2/ca 5000000 16 256
  [/@wo ~]# df -h
Filesystem            SizeUsed Avail Use% Mounted on
/dev/sda1            95G   76G   15G74% /
tmpfs               7.9G   07.9G   0% /dev/shm
/dev/sdb1             9.0T711G8.1T   8% /data/sto1
/dev/sdb2            11T6.6T4.0T63% /data/sto2
  准备做新的规划:
  在sto1,sto2中创建新的子目录如:cache1,cache2,cache3;并删除原有缓存目录cache;
   修改新方案(其中3个是新编译的squid)中squid的详细配置如下:
  修改到新端口,共计3处:
acl Safe_pormpp port 74          # http
acl Safe_pormpp port 8074      # http
  acl accel_80 myport 74
acl accel_8080 myport 8074
  http_port 74 http11 accel vhost vport
http_port 8074 http11 accel vhost vport
  修改访问主机名称(注意多个squid实例之间该值唯一)
visible_hostname hostname-2
  修改内存缓存值,本地磁盘缓存路径以及空间值
  cache_mem 1024 MB
cache_dir aufs /data/sto2/ca3 2000000 16 256
   重新初始化squid;给suqid下var中logs目录授权为777权限;并启动squid实例
squid2/sbin/squid -z
# /usr/local/xiangmu/squid2/sbin/squid -z
  [/@wo var]# pwd
/usr/local/xiangmu/squid3/var
[/@wo var]# ll
total 4
drwxrwxrwx 2 root root 4096 Oct 10 15:53 logs
  squid3/sbin/squid
# /usr/local/xiangmu/squid3/sbin/squid
  验证新squid实例是否启动成功,TCP端口是否启动;查看当前squid信息;
  [/@wo ~]# nempptat -nlp | grep squid
tcp      0      0 0.0.0.0:8061                0.0.0.0:*                   LISTEN      1072/(squid)      
tcp      0      0 0.0.0.0:61                  0.0.0.0:*                   LISTEN      1072/(squid)      
tcp      0      0 0.0.0.0:8052                0.0.0.0:*                   LISTEN      1400/(squid)      
tcp      0      0 0.0.0.0:52                  0.0.0.0:*                   LISTEN      1400/(squid)      
tcp      0      0 0.0.0.0:8093                0.0.0.0:*                   LISTEN      1424/(squid)      
tcp      0      0 0.0.0.0:93                  0.0.0.0:*                   LISTEN      1424/(squid)      
tcp      0      0 0.0.0.0:8074                0.0.0.0:*                   LISTEN      1449/(squid)      
tcp      0      0 0.0.0.0:74                  0.0.0.0:*                   LISTEN      1449/(squid)      
udp      0      0 0.0.0.0:51728               0.0.0.0:*                               1400/(squid)      
udp      0      0 0.0.0.0:55056               0.0.0.0:*                               1072/(squid)      
udp      0      0 0.0.0.0:3130                0.0.0.0:*                               1449/(squid)      
udp      0      0 0.0.0.0:3130                0.0.0.0:*                               1424/(squid)      
udp      0      0 0.0.0.0:3130                0.0.0.0:*                               1400/(squid)      
udp      0      0 0.0.0.0:3130                0.0.0.0:*                               1072/(squid)      
udp      0      0 0.0.0.0:60496               0.0.0.0:*                               1424/(squid)      
udp      0      0 0.0.0.0:41850               0.0.0.0:*                               1449/(squid)      
  
-----------
# cd /usr/local/xiangmu/squid
# watch -n 1 "bin/squidclient -p 61 mgr:info@本公司mima"
# /usr/local/xiangmu/squid/bin/squidclient -p 61 mgr:info@本公司mima
  

在节点本地,修改本地nginx.conf,vod80.conf中的配置信息
添加新的upstream和新的mpp文件分派规则
并验证新的配置文件
重新加载新配置文件
   upstream si_0 {
         server 127.0.0.1:61;
   }

   upstream si_1 {
         server 127.0.0.1:52;
   }

   upstream si_2 {
         server 127.0.0.1:93;
   }

   upstream si_3 {
         server 127.0.0.1:74;
    }
  upstream vs9 {
         server 127.0.0.1:61;
         server 127.0.0.1:52;
         server 127.0.0.1:93;
         server 127.0.0.1:74;
   }
  ----------
location ~ ^/uri(/.*) {
      set $url $1;

      if ($url ~ \.list) {
            proxy_pass http://vs9$url$is_args$args;
      }

      if ($url ~ (0|1|2)\.mpp$) {
            proxy_pass http://si_0$url;
      }

      if ($url ~ (3|4|5)\.mpp$) {
            proxy_pass http://si_1$url;
      }

      if ($url ~ (6|7)\.mpp$) {
            proxy_pass http://si_2$url;
      }

      if ($url ~ (8|9)\.mpp$) {
            proxy_pass http://si_3$url;
      }
}
  
# /usr/local/xiangmu/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/xiangmu/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/xiangmu/nginx/conf/nginx.conf test is successful
# /usr/local/xiangmu/nginx/sbin/nginx -reload
  

备份网卡配置文件,电话联系IDC机房客服,确认新IP地址的网关和掩码
修改外网网卡地址,并重启网络服务
在主控机上,或者跳板机上验证外网登录,访问。
(使用内网地址连上去)
  [/@wo logs]# cd /etc/sysconfig/network-scripts/
[/@wo network-scripmpp]# pwd
/etc/sysconfig/network-scripts
[/@wo network-scripmpp]# ll ifcfg-eth*
-rw-r--r-- 3 root root 197 Oct 10 16:37 ifcfg-eth0
-rw-r--r-- 1 root root 197 Oct 10 13:36 ifcfg-eth0_New
-rw-r--r-- 1 root root 197 Oct 10 16:36 ifcfg-eth0.save.bak_2014-10-10
-rw-r--r-- 3 root root 171 Dec72012 ifcfg-eth1
  
验证:
在本地修改hosts文件指向,在浏览器中尝试打开kids.本公司.com的视频
并查看nginx的日志,确认日志当中mpp文件和端口匹配
  #ip s1.本公司.com
#ip dxlt2.本公司.com
  
115.194.125.194 - -
"GET / "-" "127.0.0.1:61"
  113.99.6.61 - -
"GET "-" "127.0.0.1:74"
  
修改相关波及链条:

在dns中添加新地址77分配;
  
页: [1]
查看完整版本: squid调整