- 浏览: 220990 次
- 性别:
- 来自: 沈阳
文章分类
- 全部博客 (105)
- java (30)
- linux unix (19)
- 版本控制 (15)
- ajax (2)
- 开发工具及辅助工具 (3)
- database (2)
- flex (10)
- 其它 (2)
- windows (1)
- 开源企业应用 (6)
- 开源erp (4)
- 开源cms (0)
- 开源门户 (0)
- php (1)
- ofbiz&opentaps (4)
- 运维管理 (0)
- MOQUI (3)
- linux unix mysql (0)
- mysql (2)
- hadoop (3)
- android (0)
- 微信公众号 (1)
- java cassandra nosql (0)
- Nosql (1)
- socket (1)
- tcp (1)
- udp (1)
- 十六进制 (1)
- ofbiz (1)
- docker (1)
- 虚拟化 (0)
- 分布式 (0)
最新评论
-
w87848608:
用phpunit --coverage-html命令一样出现了 ...
关于phpunit与Selenium取coverage的配置(原创) -
surpass_li:
好久没来这了,不好意思,你参照Deploying OFBiz ...
ofibz10.04部署到 jboss5.1.0成功 -
tide2046:
求部署文档。谢谢。
ofibz10.04部署到 jboss5.1.0成功 -
Romotc:
征文 +1,1楼的方法还是有点问题。
eclipse编译时过滤SVN版本控制信息方法 -
我改名了:
谢谢,收 藏 了,备用。
Java获取客户端真实IP地址的两种方法(转)
<!----><!----><!----> <!---->
测试环境:
操作系统:centos 5.0
Web 服务器: apache2 + tomcat 5.5
Jdk : j2se 1.5.5
1. 下载squid-3.0.STABLE9.tar.gz (测试时最新的版本)。
http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE9.tar.gz
2. 添加用户及组
# useradd squid -M -c "Squid user" -d /dev/null -s /sbin/nologin
3. 解压并编译安装
tar squid-3.0.STABLE9.tar.gz
cd squid-3.0.STABLE9
./configure --prefix=/data/squid3 --disable-carp --with-aufs-threads=32 --with-pthreads --enable-storeio='ufs,aufs, null' --enable-disk-io='AIO,Blocking' --enable-removal-policies='heap,lru' --disable-wccp --enable-kill-parent-hack --disable-snmp --disable-poll --disable-select --enable-auth=basic --with-aio --disable-ident-lookup --with-filedescriptors=65536
编译参数不做详细介绍请查相关文档
Make
make install
安装完毕。
4. 配置
可能需要创建一些文件 这些都是配置文件中需要调用的(这个要注意文件的属主和权限)
1) [root@www ~]#cd /data/squid3/var/logs/
2) [root@www ~]#touch cache.log
3) [root@www ~]#chmod 755 cache.log
4) [root@www ~]#chown squid:squid cache.log
5) [root@www ~]#touch page_zs_access_log
6) [root@www ~]#chmod 755 page_zs_access_log
7) [root@www ~]#chown squid:squid page_zs_access_log
8) [root@www ~]#cd /data/squid3/etc/
9) 配置squid 配置文件 squid.conf
[root@www ~]# vi squid.conf (192.168.3.11 为服务器的ip 地址)
visible_hostname www.test.com
http_port 80 vhost vport
cache_mem 512 MB
maximum_object_size_in_memory 2048 KB
memory_replacement_policy lru
cache_dir ufs /tmp 512 16 256
max_open_disk_fds 0
minimum_object_size 0 KB
maximum_object_size 32768 KB
logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st "%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh
access_log /data/squid3/var/logs/page_zs_access_log combined
pid_filename/data/squid3/var/logs/squid.pid
cache_store_log none
cache_peer 192.168.3.11 parent 81 0 no-query no-digest originserver name=www
cache_peer_domain www www.test.com
cache_peer_access www allow all
http_access allow all
acl QUERY urlpath_regex cgi-bin .php .cgi .avi .wmv .rm .ram .mpg .mpeg .zip .exe
cache deny QUERY
cache_effective_user squid
cache_effective_group squid
10) [root@www ~]#/data/squid3/sbin/squid -k parse
可以根据这个测试命令用来验证squid.conf 的语法和配置(下面是OK 的如果不OK 会有相应的提示根据提示来修改配置文件)
2008/10/14 21:14:56| Processing Configuration File: /data/squid3/etc/squid.conf (depth 0)
11) [root@www ~]#/data/squid3/sbin/squid -z
用来创建缓存目录
12) vi 一个squid.sh 的启动脚本如下:赋予可执行权限
[root@www ~]#vi squid.sh
#!/bin/sh
#
ulimit -HSn 15000
# this script starts and stops Squid
echo 15000 > /proc/sys/fs/file-max
case "$1" in
start)
/data/squid3/sbin/squid -s
echo -n ' Squid'
;;
stop)
/data/squid3/sbin/squid -k shutdown
;;
esac
#chmod +x squid.sh
5. 启动squid
[root@www ~]#./squid.sh start 就可以启动squid 了
查看有没有启动可以
[root@www ~]#ps fax|grep squid
13750 pts /3 S+ 0:00 \_ grep squid
30474 ? Ss 0:00 /data/squid3/sbin/squid -s
30476 ? S 0:01 \_ (squid) -s
通过命令lsof -i:80 查看谁占用了80 端口
查看squid 的访问日志。
[root@www ~]# tail – f /data/squid3/var/logs/page_zs_access_log
查看命中率及其他相关信息
[root@www ~]# /data/squid3/bin/squidclient -p 80 -h localhost mgr:info
HTTP/1.0 200 OK
Server: squid/3.0.STABLE9
Mime-Version: 1.0
Date: Tue, 14 Oct 2008 13:22:40 GMT
Content-Type: text/plain
Expires: Tue, 14 Oct 2008 13:22:40 GMT
Last-Modified: Tue, 14 Oct 2008 13:22:40 GMT
X-Cache: MISS from www.6558855.com
Via: 1.0 www.6558855.com (squid/3.0.STABLE9)
Connection: close
Squid Object Cache: Version 3.0.STABLE9
Start Time: Tue, 14 Oct 2008 11:25:50 GMT
Current Time: Tue, 14 Oct 2008 13:22:40 GMT
Connection information for squid:
Number of clients accessing cache: 2
Number of HTTP requests received: 772
Number of ICP messages received: 0
Number of ICP messages sent: 0
Number of queued ICP replies: 0
Number of HTCP messages received: 0
Number of HTCP messages sent: 0
Request failure ratio: 0.00
Average HTTP requests per minute since start: 6.6
Average ICP messages per minute since start: 0.0
Select loop called: 7081542 times, 0.990 ms avg
Cache information for squid:
Hits as % of all requests: 5min: 0.0%, 60min: 89.7%
Hits as % of bytes sent: 5min: -0.0%, 60min: -0.0%
Memory hits as % of hit requests: 5min: 0.0%, 60min: 0.0%
Disk hits as % of hit requests: 5min: 0.0%, 60min: 0.0%
Storage Swap size: 104 KB
Storage Swap capacity: 0.0% used, 100.0% free
Storage Mem size: 228 KB
Storage Mem capacity: 0.0% used, 100.0% free
Mean Object Size: 10.40 KB
Requests given to unlinkd: 68
Median Service Times (seconds) 5 min 60 min:
HTTP Requests (All): 0.00000 0.00000
Cache Misses: 0.00000 0.00000
Cache Hits: 0.00000 0.00000
Near Hits: 0.00000 0.00000
Not-Modified Replies: 0.00000 0.00000
DNS Lookups: 0.00000 0.00000
ICP Queries: 0.00000 0.00000
Resource usage for squid:
UP Time: 7009.125 seconds
CPU Time: 0.948 seconds
CPU Usage: 0.01%
CPU Usage, 5 minute avg: 0.00%
CPU Usage, 60 minute avg: 0.01%
Process Data Segment Size via sbrk(): 2968 KB
Maximum Resident Size: 0 KB
Page faults with physical i/o: 2
Memory usage for squid via mallinfo():
Total space in arena: 3240 KB
Ordinary blocks: 3194 KB 17 blks
Small blocks: 0 KB 0 blks
Holding blocks: 11472 KB 17 blks
Free Small blocks: 0 KB
Free Ordinary blocks: 45 KB
Total in use: 14666 KB 100%
Total free: 45 KB 0%
Total size: 14712 KB
Memory accounted for:
Total accounted: 3001 KB 20%
memPool accounted: 3001 KB 20%
memPool unaccounted: 11710 KB 80%
memPoolAlloc calls: 147106
memPoolFree calls: 145713
File descriptor usage for squid:
Maximum number of file descriptors: 15000
Largest file desc currently in use: 14
Number of file desc currently in use: 8
Files queued for open: 0
Available number of file descriptors: 14992
Reserved number of file descriptors: 100
Store Disk files open: 0
Internal Data Structures:
45 StoreEntries
41 StoreEntries with MemObjects
40 Hot Object Cache Items
10 on-disk objects
6. 关于动态页面的缓存。
如 jsp 页面。
利用Header 为jsp 服务器减压
在参与缓存的jsp 中加入如下程序,进行“Last-Modified ”和“Expires ”的设置;
<%@ page import="java.io.*"%>
<%
long file_lmodified = new File("/tmp/catchmodified".lastModified();
response.setBufferSize(16);
response.setDateHeader("Last-Modified", file_lmodified);
response.setDateHeader("Expires", System.currentTimeMillis() / 1000 * 1000 + 300000);
response.flushBuffer();
%>
7. 添加自动更新记时方式
[root@www ~]# vi refreshCatch.sh
#/bin/sh
/bin/echo >/tmp/catchmodified
Chmod +x refreshCatch.sh
然后在crontab 里写一句
*/5 * * * * /data/squid3/refreshCatch.sh
发表评论
-
Docker运行mysql
2017-01-08 18:32 3991.系统环境 CentOS 7 安装过更新 # yum ... -
hadoop2.4在windows7搭建单节点环境的简要介绍
2014-05-27 16:18 846本文参照 hadoop2.2在window7上搭建单节点 ... -
linux下Percona-Server(mysql衍生版)的安装
2012-05-04 09:25 1095安装包: 下载地址:http:/ ... -
CentOS系统安装Tomcat切换JDK的方法
2011-10-14 09:38 1069CentOS系统安装Tomcat切换JDK的方法 ... -
让wget自动支持断点续传
2011-09-27 12:08 1191都知道-c可以断点续传, 可是总有迷糊的人, 模糊 ... -
Fedora 教程汇总帖 - 最快速的 Fedora/Linux 学习指南
2010-05-09 19:57 2651本教程省略了传统 Linux 学习教程中相对枯燥的内容,从实用 ... -
关于网络流量监控器mrtg-2.16.1安装与配置文档
2008-02-27 11:50 2381其它软件包的检查: [root@mail doc]# rpm ... -
在Linux下设置最简单的ssh安全自动登录
2008-02-03 14:38 3832在Linux下设置最简单的ss ... -
linux /unix下循环加载文件shell
2007-04-26 18:42 2335在linux上或unix环境下在没有ide的情况下编译/运行j ... -
DOS文件转换成UNIX文件格式
2007-04-09 16:43 2547DOS文件??成UNIX文件格式 dos格式文件上载到uni ... -
unix /linux 开发C统计编译错误的小脚本。
2007-03-14 14:16 1371这段时间做unix上的C开发,由于用makefile统一编译当 ... -
如何在使用ssh的时候不需要输入密码(转)
2007-03-07 21:52 72ritazrh | 01 三月, 2007 13:50 在 ... -
crontab加文件锁笔记
2007-02-20 18:20 1240先创建文件lockRegaudit.txt内容为0锁标志 再创 ... -
Linux Shell 下的输出重定向( 转)
2007-02-20 18:17 2047Linux Shell 环境中支持输入输出重定向,用符号&l ... -
Cron服务配置详解(摘自linuxaid)
2007-02-20 18:15 1324刚做了一个备份的模块,后来师傅提示最好再加一个自动备份的功 ... -
unix 提示符修改
2006-12-05 09:27 2638#prompt PS1='$USER[$PWD] $ ' ... -
使用Grub进行Linux的硬盘安装与修复 (转)
2006-12-02 11:35 1921Grub是现在各个Linux发行 ... -
shell循环脚本
2006-11-30 00:19 5351##执行方法:脚本名 参数1(循环次数$1) 参数2($2) ... -
shell小试
2006-11-27 22:00 1230初学shell和make,今天, ...
相关推荐
包括DNS的安装和配置、squid 2.6的安装和配置、apache的安装和配置。做反向代理加速内网web服务器
而对Sina,NetEase这样的大型站点,Squid又充当WEB加速器。这两个角色它都扮演得异常优秀。窗外繁星点点,开源的世界亦如这星空般美丽,而Squid是其中耀眼的一颗星。 彭勇华 目 录第1章 介绍 o 1.1 Web缓存 o 1.2...
Squid中文权威指南(PDF) 译者序: ...而对Sina,NetEase这样的大型站点,Squid又充当WEB加速器。这两个角色它都扮演得异常优秀。窗外繁星点点,开源的世界亦如这星空般美丽,而Squid是其中耀眼的一颗星。
而对Sina,NetEase这样的大型站点,Squid又充当WEB加速器。这两个角色它都扮演得异常优秀。窗外繁星点点,开源的世界亦如这星空般美丽,而Squid是其中耀眼的一颗星。 http://blog.s135.com/book/squid/
squid可充当代理服务器,而对sian,netEase等大型的站点,squid又充当web加速器。我也是在网上找了很长一阵子才找到的,希望能给想学习squid的哥们有点帮助。
本人在工作中维护着数台Squid服务器,多次参阅Duane ...而对Sina,NetEase这样的大型站点,Squid又充当WEB加速器。这两个角色它都扮演得异常优秀。窗外繁星点点,开源的世界亦如这星空般美丽,而Squid是其中耀眼的一颗星
主服务器群:源Web服务器群 位于公网ip:220.XXX.XXX.X port:80(后台才是WEB的服务器) 注: 要保证TCP80,UDP3130在防火墙上是开的(供icp_port通讯使用,多台Squid集群才会用到) 全国各地分服务器:A服务器公网IP111.xxx...
对普通的单位上网用户,Squid可充当代理服务器...而对Sina,NetEase这样的大型站点,Squid又充当WEB加速器。这两个角色它都扮演得异常优秀。窗外繁星点点,开源的世界亦如这星空般美丽,而Squid是其中耀眼的一颗星。
您可能感兴趣的文章:php使用socket post数据到其它web服务器的方法C#使用PHP服务端的Web Service通信实例基于php在各种web服务器的运行模式详解Nginx + php 搭建 超性能 WEB 服务器Linux+Nginx+Php架设高性能WEB...
Squid具有广泛的访问控制,是一个出色的服务器加速器。 它可以在大多数可用的操作系统(包括Windows)上运行,并且已获得GNU GPL的许可。 该项目提供了用于Squid代理服务器的MSI Windows Installer。 只需单击几下...
Lighttpd+Squid+Apache搭建高效率Web服务器 9 浏览量比较大的网站应该从哪几个方面入手? 17 用负载均衡技术建设高负载站点 20 大型网站的架构设计问题 25 开源平台的高并发集群思考 26 大型...
2.3.3 Varnish对应多台Web服务器的配置实例 2.4 运行Varnish 2.4.1 varnishd指令 2.4.2 配置Varnish运行脚本 2.4.3 管理Varnish运行日志 2.5 管理Varnish 2.5.1 查看Varnish进程 2.5.2 查看Varnish...
9.4.3 反向代理加速Web网站 9.5 代理客户端配置 9.5.1 Linux客户端配置 9.5.2 Windows客户端配置 9.6 Squid企业实战与应用 9.6.1 企业环境 9.6.2 需求分析 9.6.3 解决方案 9.6.4 真实案例配置文件 9.7 本章习题 ...