# /usr/local/squid/sbin/squid -N -d1
2013/07/17 05:52:03| Starting Squid Cache version 2.7.STABLE9 for x86_64-unknown-linux-gnu...
2013/07/17 05:52:03| Process ID 13897
2013/07/17 05:52:03| With 1024 file descriptors available
2013/07/17 05:52:03| Using epoll for the IO loop
2013/07/17 05:52:03| Performing DNS Tests...
2013/07/17 05:52:03| Successful DNS name lookup tests...
2013/07/17 05:52:03| helperOpenServers: Starting 5 'dnsserver' processes
2013/07/17 05:52:03| User-Agent logging is disabled.
2013/07/17 05:52:03| Referer logging is disabled.
2013/07/17 05:52:03| logfileOpen: opening log /usr/local/squid/var/logs/access.log
2013/07/17 05:52:03| Unlinkd pipe opened on FD 15
2013/07/17 05:52:03| Swap maxSize 102400 + 8192 KB, estimated 8507 objects
2013/07/17 05:52:03| Target number of buckets: 425
2013/07/17 05:52:03| Using 8192 Store buckets
2013/07/17 05:52:03| Max Mem size: 8192 KB
2013/07/17 05:52:03| Max Swap size: 102400 KB
2013/07/17 05:52:03| logfileOpen: opening log /usr/local/squid/var/logs/store.log
2013/07/17 05:52:03| Rebuilding storage in /usr/local/squid/var/cache (DIRTY)
2013/07/17 05:52:03| Using Least Load store dir selection
2013/07/17 05:52:03| Set Current Directory to /usr/local/squid/var/cache
2013/07/17 05:52:03| Loaded Icons.
2013/07/17 05:52:03| Accepting proxy HTTP connections at 0.0.0.0, port 80, FD 16.
2013/07/17 05:52:03| Accepting ICP messages at 0.0.0.0, port 3130, FD 17.
2013/07/17 05:52:03| Accepting SNMP messages on port 3401, FD 18.
2013/07/17 05:52:03| WCCP Disabled.
2013/07/17 05:52:03| Pinger socket opened on FD 19
2013/07/17 05:52:03|
Ready to serve requests.
2013/07/17 05:52:03| Done scanning /usr/local/squid/var/cache (0 entries)
2013/07/17 05:52:03| Finished rebuilding storage from disk.
2013/07/17 05:52:03| 0 Entries scanned
2013/07/17 05:52:03| 0 Invalid entries.
2013/07/17 05:52:03| 0 With invalid flags.
2013/07/17 05:52:03| 0 Objects loaded.
2013/07/17 05:52:03| 0 Objects expired.
2013/07/17 05:52:03| 0 Objects cancelled.
2013/07/17 05:52:03| 0 Duplicate URLs purged.
2013/07/17 05:52:03| 0 Swapfile clashes avoided.
2013/07/17 05:52:03| Took 0.3 seconds ( 0.0 objects/sec).
2013/07/17 05:52:03| Beginning Validation Procedure
2013/07/17 05:52:03| Completed Validation Procedure
2013/07/17 05:52:03| Validated 0 Entries
2013/07/17 05:52:03| store_swap_size = 0k
2013/07/17 05:52:04| storeLateRelease: released 0 objects
如果有到 ready to server reques,恭喜,启动成功。
然后 ctrl + c,停止squid,并以后台运行的方式启动它。
4、启动squid作为后台进程运行
/usr/local/squid/sbin/squid -s
5、停止squid服务
/usr/local/squid/sbin/squid -k shutdown
6、重引导修改过的squid.conf配置文件
/usr/local/squid/sbin/squid -k reconfigure
这个估计用的时候比较多,当你发现你的配置有不尽你意的时候,可以随时修改squid.conf,然后别忘记对你的 squid.conf排错,然后再执行此指令,即可让squid重新按照你的 squid.conf 来运行。
7、squid添加到系统启动项
/usr/local/squid/sbin/squid -s
8、查看运行信息
/usr/local/squid/bin/squidclient -h 127.0.0.1 -p 80 mgr:info
9、分割日志
20 0 * * * /usr/local/squid/sbin/squid -k rotate
10、清楚缓存
/usr/local/squid/bin/squidclient -h 192.168.10.10 -p 80 -m PURGE http://192.168.10.10/code.jpeg
11、查看你的日志文档
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缓存,而是现重原始服务器获取并返回给访问用户
12、相关命令
squid运行状态信息:
/usr/local/squid/bin/squidclient -h 192.168.10.10 -p 80 mgr:info
/usr/local/squid/bin/squidclient -h 192.168.10.10 -p 80 mgr:5min
squid内存使用情况:
/usr/local/squid/bin/squidclient -h 192.168.10.10 -p 80 mgr:mem
squid缓存信息列表:
/usr/local/squid/bin/squidclient -h 192.168.10.10 -p 80 mgr:objects (use it carefully,it may crash)
squid磁盘使用情况:
/usr/local/squid/bin/squidclient -h 192.168.10.10 -p 80 mgr:disk
强制更新某个url:
/usr/local/squid/bin/squidclient -h 192.168.10.10 -p 80 -m PURGE http://www.hnhack.com/