免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123下一页
最近访问板块 发新帖
查看: 23447 | 回复: 24

[proxy] [sibling模式 集群] Squid-2.6之集群(sibling模式)Web反向代理加速实做 [复制链接]

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
发表于 2006-12-28 15:06 |显示全部楼层
ydabing,好消息,Squid-2.6之集群(sibling模式)Web反向代理加速实验成功啦

  昨天晚上到了两点多才睡觉,把squid官方的电邮记档翻了个底朝天(当然只找我想要的),今天总算把sibling模式的集群给做出来。

  access.log之中出现了激动人心日志:

  1. cache1# tail -f access.log
  2. 1167289010.723     24 192.168.1.4 TCP_MISS/200 824 GET http://img.test.org:1080/test/test.html - SIBLING_HIT/192.168.1.203 text/html
复制代码

  1. cache2# tail -f access.log
  2. 1167288960.602    126 192.168.1.4 TCP_MISS/200 687 GET http://img.test.org:1080/test/test.html - FIRST_UP_PARENT/192.168.1.201 text/html
  3. 1167289010.127      0 192.168.1.203 UDP_HIT/000 66 ICP_QUERY http://img.test.org:1080/test/test.html - NONE/- -
  4. 1167289010.720      0 192.168.1.203 TCP_MEM_HIT/200 694 GET http://img.test.org:1080/test/test.html - NONE/- text/html
复制代码


  真是高兴急啦,先上来自己贺喜一下子,稍候整理文档和配置发上来。

[ 本帖最后由 HonestQiao 于 2006-12-28 15:36 编辑 ]

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
发表于 2006-12-28 15:11 |显示全部楼层
首先,怎么安装Squid2.6可以看:
http://bbs.chinaunix.net/viewthread.php?tid=798564

我在FreeBSD操作系统之下,首先portsnap fetch extract update更新ports,然后
cd /usr/ports/www/squid26/
make rmconfig;make PREFIX=/usr/local/squid1
这就是安装cache1了。
然后安装cache2到/usr/local/squid2
我看了,其配置参数如下:

  1. ./configure --bindir=/usr/local/squid1/sbin --sbindir=/usr/local/squid1/sbin --datadir=/usr/local/squid1/etc/squid --lib
  2. execdir=/usr/local/squid1/libexec/squid --localstatedir=/usr/local/squid1/squid --sysconfdir=/usr/local/squid1/etc/squid --e
  3. nable-removal-policies=lru heap --disable-linux-netfilter --disable-linux-tproxy --disable-epoll --enable-auth=basic ntlm di
  4. gest --enable-basic-auth-helpers=NCSA PAM MSNT SMB YP --enable-digest-auth-helpers=password --enable-external-acl-helpers=ip
  5. _user session unix_group wbinfo_group --enable-ntlm-auth-helpers=SMB --enable-storeio=ufs diskd null --enable-htcp --enable-
  6. cache-digests --enable-wccpv2 --disable-http-violations --enable-referer-log --enable-useragent-log --enable-follow-x-forwar
  7. ded-for --enable-kqueue --with-large-files --enable-large-cache-files --enable-err-languages=Azerbaijani Bulgarian Catalan C
  8. zech Danish Dutch  English Estonian Finnish French German Greek Hebrew  Hungarian Italian Japanese Korean Lithuanian  Polish
  9. Portuguese Romanian Russian-1251 Russian-koi8-r  Serbian Simplify_Chinese Slovak Spanish Swedish  Traditional_Chinese Turki
  10. sh --enable-default-err-language=English --prefix=/usr/local/squid1 i386-portbld-freebsd6.2
复制代码

  其他系统参照这个配置即可。
  我用FreeBSD的ports安装很简单,他会给我一个菜单,菜单的配置如下:

  1. www# make showconfig
  2. ===> The following configuration options are available for squid-2.6.6:
  3.      SQUID_LDAP_AUTH=off "Install LDAP authentication helpers"
  4.      SQUID_SASL_AUTH=off "Install SASL authentication helpers"
  5.      SQUID_DELAY_POOLS=off "Enable delay pools"
  6.      SQUID_SNMP=off "Enable SNMP support"
  7.      SQUID_CARP=on "Enable CARP support"
  8.      SQUID_SSL=off "Enable SSL support for reverse proxies"
  9.      SQUID_PINGER=off "Install the icmp helper"
  10.      SQUID_DNS_HELPER=off "Use the old 'dnsserver' helper"
  11.      SQUID_HTCP=on "Enable HTCP support"
  12.      SQUID_VIA_DB=off "Enable forward/via database"
  13.      SQUID_CACHE_DIGESTS=on "Enable cache digests"
  14.      SQUID_WCCP=on "Enable Web Cache Coordination Prot. v1"
  15.      SQUID_WCCPV2=on "Enable Web Cache Coordination Prot. v2"
  16.      SQUID_STRICT_HTTP=on "Be strictly HTTP compliant"
  17.      SQUID_IDENT=on "Enable ident (RFC 931) lookups"
  18.      SQUID_REFERER_LOG=on "Enable Referer-header logging"
  19.      SQUID_USERAGENT_LOG=on "Enable User-Agent-header logging"
  20.      SQUID_ARP_ACL=off "Enable ACLs based on ethernet address"
  21.      SQUID_PF=off "Enable transparent proxying with PF"
  22.      SQUID_IPFILTER=off "Enable transp. proxying with IPFilter"
  23.      SQUID_FOLLOW_XFF=on "Follow X-Forwarded-For headers"
  24.      SQUID_ICAP=off "Enable ICAP client functionality"
  25.      SQUID_AUFS=off "Enable the aufs storage scheme"
  26.      SQUID_COSS=off "Enable the COSS storage scheme"
  27.      SQUID_KQUEUE=on "Use kqueue(2) instead of poll(2)"
  28.      SQUID_LARGEFILE=on "Support log and cache files >2GB"
  29.      SQUID_STACKTRACES=off "Create backtraces on fatal errors"
  30. ===> Use 'make config' to modify these settings
复制代码

说明:
我在同一台服务器测试的,但是我用的不同的IP和不同的端口,多台服务器类似,不多说了。
cache1安装在/usr/local/squid1
cache2安装在/usr/localsquid2

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
发表于 2006-12-28 15:15 |显示全部楼层
安装完成了,就需要配置了。

按照我这样子的安装:
cache1的配置在/usr/local/squid1/etc/squid/squid.conf
cache2的配置在/usr/local/squid2/etc/squid/squid.conf

然后我的IP相关信息分配如下:
原始WEB服务器,192.168.1.201,端口80
CACHE1,192.168.1.202,端口1080,ICP端口3132
CACHE2,192.168.1.203,端口1080,ICP端口3133

然后其他的配置按照我上传的文件即可:

squid_cache1.zip

983 Bytes, 下载次数: 847

cache1的配置

squid_cache2.zip

983 Bytes, 下载次数: 648

cache2的配置

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
发表于 2006-12-28 15:17 |显示全部楼层
然后,就要开始测试啦:
分别在两个cache服务器上执行:
#cache1
rm -rf /usr/local/squid1/squid/cache/* ; /usr/local/squid1/sbin/squid -z ; /usr/local/squid1/sbin/squid -NCd1

#cache2
rm -rf /usr/local/squid2/squid/cache/* ; /usr/local/squid2/sbin/squid -z ; /usr/local/squid2/sbin/squid -NCd1

这个时候,你就可以开始访问测试了。
当然,我的测试域名,我用我本地的DNS做了指向,测试过程之中,分别指向过202和203来检查是否有实际的效果。

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
发表于 2006-12-28 15:22 |显示全部楼层
上面的指令是调试指令,你可以同时接合看:
/usr/local/squid目录/squid/logs/access.log

在我们配置存在问题的时候,调试窗口会出现:
temporary disabling (Forbidden) digest from 192.168.1.203
或者
temporary disabling (Forbidden) digest from 192.168.1.202

而且access.log会出现:
UDP_MISS和TCP_DENIED/403

UDP_MISS在初次一般会出现的,因为他没有缓存,还没有cache_degist。

而Forbidden和TCP_DENIED说明我们没有设置好acl.

所以我的配置之中,加了:
acl gsrc src 192.168.1.201 192.168.1.202 192.168.2.203
acl gdst dst 192.168.1.201 192.168.1.202 192.168.2.203
http_access allow gsrc                             
http_access allow gdst

则,我们的原始WEB服务器和CACHE服务器群之间,相互放行。
这样子的问题就不会出现了。

如果按照我前面的配置,应该是不会出现这样子的情况的,测试一下子,tail -f access.log就可以知道了。
然后,把gsrc和gdst的部分注释掉,再来测试,上面的情况,几乎是一定出现的。

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
发表于 2006-12-28 15:24 |显示全部楼层
另外,在网上看到有人使用parent的模式做反向加速代理,这样子会慢很多。

大家如果有条件,请尽快测试,如果发现什么问题,望告诉我,再来完善调整哦。

另外,这里仅仅是为了测试和实现sibling模式的群,所以,配置里面的其他部分,就没有仔细设置了,请大家见谅。

论坛徽章:
0
发表于 2006-12-28 23:49 |显示全部楼层
LZ,我在 ./configure --enable-auth=basic \
--enable-basic-auth-helpers=LDAP

后怎么在/usr/local/squid/libexec里找不到squid_ldap_auth的?而要重新回到base_auth/LDAP里make一下,再复制squid_ldap_auth到/usr/local/squid/libexec里?

有哪里做错了吗?

论坛徽章:
0
发表于 2006-12-29 09:27 |显示全部楼层
懂e文真好,斑竹有耐心把squid官方的电邮记档翻了个底朝天

论坛徽章:
0
发表于 2006-12-29 09:50 |显示全部楼层
我把安装脚本修改了一下

./configure --bindir=/usr/local/squid1/sbin \
--sbindir=/usr/local/squid1/sbin \
--datadir=/usr/local/squid1/etc/squid \
--libexecdir=/usr/local/squid1/libexec/squid \
--localstatedir=/usr/local/squid1/squid \
--sysconfdir=/usr/local/squid1/etc/squid \
--enable-removal-policies=lru heap \
--disable-linux-netfilter \
--disable-linux-tproxy \
--disable-epoll \
--enable-auth=basic ntlm digest \
--enable-basic-auth-helpers=NCSA PAM MSNT SMB YP \
--enable-digest-auth-helpers=password \
--enable-external-acl-helpers=ip_user session unix_group wbinfo_group \
--enable-ntlm-auth-helpers=SMB \
--enable-storeio=ufs diskd null \
--enable-htcp \
--enable-cache-digests \
--enable-wccpv2 \
--disable-http-violations \
--enable-referer-log \
--enable-useragent-log \
--enable-follow-x-forwarded-for \
--enable-kqueue \
--with-large-files \
--enable-large-cache-files \
--enable-err-languages=Azerbaijani Bulgarian Catalan Czech Danish Dutch  English Estonian Finnish French German Greek Hebrew  Hungarian Italian Japanese Korean Lithuanian  Polish
Portuguese Romanian Russian-1251 Russian-koi8-r  Serbian Simplify_Chinese Slovak Spanish Swedish  Traditional_Chinese Turkish \
--enable-default-err-language=English \
--prefix=/usr/local/squid1 i386-portbld-freebsd6.2

论坛徽章:
0
发表于 2006-12-29 11:22 |显示全部楼层
呵呵,谢谢

安装2.6版本试试
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP