月度归档: 2009 年 3 月

  • Squid 常用命令

    1,初始化你在 squid.conf 里配置的 cache 目录
    #squid/sbin/squid -z
    如果有错误提示,请检查你的 cache目录的权限。
    2,对你的squid.conf 排错,即验证 squid.conf 的 语法和配置。
    #squid/sbin/squid -k parse
    如果squid.conf 有语法或配置错误,这里会返回提示你,如果没有返回,恭喜,可以尝试启动squid。
    3,在前台启动squid,并输出启动过程。
    #squid/sbin/squid -N -d1
    如果有到 ready to server reques,恭喜,启动成功。
    然后 ctrl + c,停止squid,并以后台运行的方式启动它。
    4,启动squid在后台运行。
    #squid/sbin/squid -s
    这时候可以 ps -A 来查看系统进程,可以看到俩个 squid 进程。
    5,停止 squid
    #squid/sbin/squid -k shutdown
    这个不用解释吧。
    6,重引导修改过的 squid.conf
    #squid/sbin/squid -k reconfigure
    这个估计用的时候比较多,当你发现你的配置有不尽你意的时候,可以随时修改squid.conf,然后别忘记对你的 squid.conf排错,然后再执行此指令,即可让squid重新按照你的 squid.conf 来运行。
    注:Windos下运行需要加 -n squid?参数 其中squid为默认服务名。
    7,把squid添加到系统启动项
    编辑 /etc/rc.d/rc.local
    添加如下行:??/usr/local/squid/sbin/squid -s
    当然,并不是每个人都喜欢这种启动方式,你可以用你最习惯的方式;或者把它安装为服务。

    再来点其他的。
    1,修改cache 缓存目录的权限。
    #chown -R squid:squid /home/cache
    我的cache缓存目录是 /home/cache,squid执行用户和用户组是 squid,squid。
    2,修改squid 日志目录的权限
    #chown -R squid:squid /usr/local/squid/var/logs
    这一步并不是适合每一个使用squid的用户.意为让squid有权限在该目录进行写操作 。
    例如生成??access.log? ? cache.log? ?store.log
    3,查看你的日志文档。
    #more /usr/local/squid/var/logs/access.log | grep TCP_MEM_HIT
    该指令可以看到在squid运行过程中,有那些文件被squid缓存到内存中,并返回给访问用户。
    #more /usr/local/squid/var/logs/access.log | grep TCP_HIT
    该指令可以看到在squid运行过程中,有那些文件被squid缓存到cache目录中,并返回给访问用户。
    #more /usr/local/squid/var/logs/access.log | grep TCP_MISS
    该指令可以看到在squid运行过程中,有那些文件没有被squid缓存,而是现重原始服务器获取并返回给访问用户。
    关于 TCP_XXXX 等参数及代表的信息,请参看《squid中文权威指南》13.2.1 章节。
    当然,本例中的蓝色文字是可以修改为其他的参数,例如你的域名??www.xxxx.com ,同样可以看到access.log里关于该域名的行。

    二.squid命中率分析

    /usr/local/squid/bin/squidclient -p 80 mgr:info
    /usr/local/squid/bin/squidclient -p 80 mgr:5min
    可以看到详细的性能情况,其中PORT是你的proxy的端口,5min可以是60min

    取得squid运行状态信息: squidclient -p 80 mgr:info
    *取得squid内存使用情况: squidclient -p 80 mgr:mem
    *取得squid已经缓存的列表: squidclient -p 80 mgr:objects??????????????????? . use it carefully,it may crash
    *取得squid的磁盘使用情况: squidclient -p 80 mgr:diskd
    *强制更新某个url:squidclient -p 80 -m PURGE http://www.xxx.com/xxx.php
    *更多的请查看:squidclient-h 或者 squidclient -p 80 mgr:

    查命中率:
    /usr/local/squid/bin/squidclient -h 111.222.111.111 -p80 mgr:info

    /usr/local/squid/bin/squidclient -h具体的IP -p80 mgr:info

    (我们一般都会把squid配置成有缓存目录的模式,也就是有配置cache_dir目录,当squid应用运行了一段时间以后,cache_dir对应的swap.state文件就会变得越来越大,里面的无效接口数据越来越多,这可能在一定程度上影响squid的响应时间,此时我们可以使用rotate命令来使squid清理swap.state里面的无效数据,减少swap.state的大小。具体命令格式:
    /path/to/squid/sbin/squid -k rotate -f /path/to/squid/conf_file
    但是在3.0.7以前的版本都发现一些问题,rotate完以后启动DNSSERVER的时候会提示不能分配内存,从而导致DNSSERVER的辅助进程不能启动,此时一般情况下需要重启squid应用。)

  • Squid 2.7 conf for Windows

    http_port 80 accel vhost vport

    #源IP 等
    cache_peer 218.1.72.225 parent 80 0 no-query round-robin max-conn=32 originserver name=dl
    #需要加速的域名
    cache_peer_domain dl dl.example.com  
    #acl
    acl manager proto cache_object
    acl localhost src 127.0.0.1/255.255.255.255
    #squid3.0无需此行
    acl all src 0.0.0.0/0.0.0.0
    acl SSL_ports port 443 563
    acl Safe_ports port 80       # http
    acl Safe_ports port 8080
    acl LanDstDM dstdomain dl.example.com 
    acl LanSrc src 192.168.0.0/24
    acl LanDst dst 192.168.0.0/24

    acl CONNECT method CONNECT
    http_access allow manager localhost
    http_access allow LanDstDM
    http_access allow LanSrc
    http_access allow LanDst
    http_access deny manager
    http_access deny !Safe_ports
    http_access deny CONNECT !SSL_ports
    http_access deny all

    #base
    visible_hostname dl.example.com 

    cache_mgr [email protected]
    cache_effective_user squid
    cache_effective_group squid

    error_directory c:/squid/share/errors/Simplify_Chinese
    icon_directory c:/squid/share/icons
    mime_table c:/squid/etc/mime.conf

    cache_replacement_policy lru
    #cache_dir
    cache_dir ufs c:/squid/var/cache 10000 16 64

    cache_mem 64 MB

    max_open_disk_fds 0
    maximum_object_size 200 MB
    maximum_object_size_in_memory 128 KB
    #keepalived
    client_persistent_connections off
    server_persistent_connections on
    #persistent_request_timeout 60 seconds

    memory_pools on
    memory_pools_limit 64 MB

    forwarded_for on
    log_icp_queries off

    via on
    httpd_suppress_version_string off

    ie_refresh off
    tcp_recv_bufsize 32 KB

    #acl webservices rep_header Server -i ^Apache ^nginx
    #broken_vary_encoding allow webservices

    #hidden the squid header
    #reply_header_access Server deny all
    #reply_header_access X-Cache deny all
    #reply_header_access Warning deny all
    #reply_header_access Expires deny all
    #reply_header_access Cache-Control deny all
    #reply_header_access age deny all

    #reply_header_access All deny all

    ipcache_size 1024
    ipcache_low 90
    ipcache_high 95

    memory_replacement_policy lru

    hosts_file /etc/hosts
    request_header_max_size 128 KB
    #deny cache
    hierarchy_stoplist cgi-bin ? \.php
    acl QUERY urlpath_regex cgi-bin\? \.php \.css
    acl DIRECT url_regex -i ^http:\/\/www\.yourdomain\.org\/$
    acl DIRECT url_regex -i ^http:\/\/photo\.yourdomain \.org\/.*$
    acl DIRECT url_regex -i ^http:\/\/www\.yourdomain \.org\/index\.html$

    cache deny QUERY
    cache deny DIRECT
    #request_body_max_size 0 KB

    refresh_pattern ^ftp: 60 20% 10080
    refresh_pattern ^gopher: 60 0% 1440
    refresh_pattern -i \.css$ 1440 50% 129600 reload-into-ims
    refresh_pattern -i \.xml$ 1440 50% 129600 reload-into-ims
    refresh_pattern -i \.html$ 1440 90% 129600 reload-into-ims
    refresh_pattern -i \.shtml$ 1440 90% 129600 reload-into-ims
    refresh_pattern -i \.htm$ 1440 90% 129600 reload-into-ims
    refresh_pattern -i \.jpg$ 1440 90% 129600 reload-into-ims
    refresh_pattern -i \.png$ 1440 90% 129600 reload-into-ims
    refresh_pattern -i \.gif$ 1440 90% 129600 ignore-reload
    refresh_pattern -i \.bmp$ 1440 90% 129600 reload-into-ims
    refresh_pattern -i \.js$ 1440 90% 129600 reload-into-ims
    refresh_pattern -i \.mp3$ 1440 50% 2880 ignore-reload
    refresh_pattern -i \.wmv$ 1440 50% 2880 ignore-reload
    refresh_pattern -i \.rm$ 1440 50% 2880 ignore-reload
    refresh_pattern -i \.swf$ 1440 50% 2880 ignore-reload
    refresh_pattern -i \.mpeg$ 1440 50% 2880 ignore-reload
    refresh_pattern -i \.wma$ 1440 50% 2880 ignore-reload
    refresh_pattern -i \.rar$ 1440 50% 2880 ignore-reload
    refresh_pattern -i \.zip$ 1440 50% 2880 ignore-reload
    refresh_pattern -i \.7z$ 1440 50% 2880 ignore-reload
    refresh_pattern -i \.pdf$ 1440 50% 2880 ignore-reload
    refresh_pattern -i \.exe$ 1440 50% 2880 ignore-reload
    refresh_pattern -i \.doc$ 1440 50% 2880 ignore-reload
    refresh_pattern -i \.txt$ 1440 50% 2880 ignore-reload
    refresh_pattern . 120 50% 1440

    #大文件缓存
    quick_abort_min 16 MB
    quick_abort_max 16 MB
    quick_abort_pct 60

    #下载工具
    range_offset_limit -1

    connect_timeout 1 minute
    negative_ttl 0 minutes
    read_timeout 30 seconds
    pconn_timeout 120 seconds
    shutdown_lifetime 5 seconds
    strip_query_terms off

    # snmp
    #snmp_port 3401
    #acl snmppublic snmp_community snsimg
    #snmp_access allow snmppublic localhost
    #snmp_access deny all

    acl snmppublic snmp_community public
    snmp_port 3401
    snmp_access allow snmppublic all

    icp_port 0

    # logfile
    emulate_httpd_log on
    logformat orgbined %{X-Forwarded-For}>h %ui %un [%tl] “%rm %ru HTTP/%rv” %Hs %<st “%{Referer}>h” “%{User-Agent}>h” %Ss:%Sh

    access_log c:/squid/var/logs/access.log squid   

    cache_log c:/squid/var/logs/cache.log
    pid_filename c:/squid/var/logs/squid.pid
    cache_store_log none
    logfile_rotate 12

    # MISCELLANEOUS
    store_objects_per_bucket 15
    client_db off

    添加了一些注释,简单的修改后直接就能使用。该版本,2.6和3.0都可以使用(3.0需要简单修改),有什么问题可以在下面留言,大家共同讨论。

    Squid 2.7 for Windows 下载地址:http://www.serassio.it/SquidNT.htm

  • 岂曰无衣 与子同袍

    近日在《我的团长我的团》里总是听到这句话,于是查了查含义,以便于进一步理解该剧。

    岂曰无衣?与子同袍。王于兴师,修我戈矛。与子同仇!
    岂曰无衣?与子同泽。王于兴师,修我矛戟。与子偕作!
    岂曰无衣?与子同裳。王于兴师,修我甲兵。与子偕行!

    诗的大意是:
    怎能说没有衣裳?我愿和你同披一件战袍。天子让我们出兵打仗,且修好我们的戈与矛。我们面对的是共同的敌人!
    怎能说没有衣裳?我愿和你同穿一件汗衣。天子让我们出兵打仗,且修好我们的矛与戟。我愿与你一同战斗!
    怎能说没有衣裳?我愿和你同穿一件下裳。天子让我们出兵打仗,且修好我们的盔甲兵器。我愿与你一同前进!

    诗的背景:是西周的幽王(为了美女褒姒烽火戏诸侯的那位先生)为犬戎所杀,秦襄公护周平王东迁,并受王命攻打犬戎。王先谦先生解释本诗时说:“西戎杀幽王,于是周室诸侯以为不共戴天之仇,秦民敌王所忾,故曰同仇也。”

    这首诗一共三段,以复沓的形式,表现了秦军战士出征前的高昂士气:他们互相召唤、互相鼓励,舍生忘死、同仇敌忾。这是一首慷慨激昂的从军曲!

  • 无法通过google.cn缓存(网页快照)访问

    本网页可能涉及不符合相关法律法规和政策的内容, 无法通过google.cn缓存访问, 请返回 google.cn

    ? 如果你的网站首页或其他页在检查网页快照时出现类似提示,请确保没有“涉及不符合相关法律法规和政策的内容”。如果确信没有违法的,请仔细检查看是否出现了国家领导人的名字或称呼,去除后过上几天即可恢复快照。