SquidPrinciple
SquidLinuxCacheInternetdataserversoftware,UserDownloadDownloaddata。UserDownloadwww.idcshare,requestsquid,suqidconnectionwww.idcsharerequest,NextUser.Userrequest,squiddisk,dataUser.
Squid
1) client:HTTP .FTP.Gopher.WAIS.SSL
2) CacheManagement:ICP(Internet Cache). HTCP().SNNP. Cache Digests
:
1) ClientServer;
2) Server,『』『』?If,,Proxy,ServerClient。
3) ServerFirst,cache Client,If,ClientInternet;
4) dataclient
5)1, 2, 3cache,, ProxyInternet;
6), proxy『cache』;
7)FinallyClient。
server
:
1) Cache
2) ipinternet
3) networkSecurity
4) UserManagement
:
1) server
2) server
3) reverse proxyserver
Installation
1)CompilationOptimization
,OptimizationparameterexportcommandCFLAGSCXXFLAGS,Thenconfigure,makeOptimizationparameter。AddOptimizationparameter,CPUsystemOptimization,file、CPU、memory。Optimization,systemplatform。
[root@server soft]# cat /proc/cpuinfo |more
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 23
model name : Intel(R) Xeon(R) CPU E5420 @ 2.50GHz
stepping : 10
cpu MHz : 2493.978
cache size : 6144 KB
physical id : 0
siblings : 4
core id : 0
cpu cores : 4
apicid : 0
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush d
ts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr
lahf_lm
bogomips : 4987.95
Configuration:
[root@server soft]#export CHOST="i686-pc-linux-gnu"
[root@server soft]#export CFLAGS="-march=Prescott -O2 -pipe -fomit-frame-pointer"
[root@server soft]#export CXXFLAGS="${CFLAGS}"
[root@server soft]#env
SettingsEnvironmentvariable
,Description.
3)parameter
fileMeanwhilefile,default1024。In other words,Iffile,Meanwhile1024file,SquidMeanwhilefile,,response,file.
:a.Usersquid,squidfile,ThenfileUser。
b.squidfile,Usersquid,squidUser。,Userrequest。
Firstfile。
/usr/include/bits/typesizes.h
/usr/include/linux/posix_types.h
vifile
#define __FD_SETSIZE 1024
102465536,Then,Linux。
/usr/include/bits/typesizes.h
/usr/include/linux/posix_types.h
vifile
#define __FD_SETSIZE 1024
102465536,Then,Linux。
fileC/C++file,Compilationsquid。file,CurrentlyEnvironmentSettings。sshLoginsystem。LoginprocessSettings,DisableCurrentlyLogin,EnvironmentvariableSettings.
ulimitSettingsCurrentlyEnvironment。commandEnvironmentSettings,LogoutCurrentlyLoginprocesscommand。
command
[root@server soft]#ulimit -Hs 65536
[root@server soft]#ulimit -n 65536
,,:
vi /etc/security/limits.conf,
* soft nofile 65536
* hard nofile 65536
Hparameter,s,nfile。
:
ulimit parameter:
-H Settingshardware.
-S Settingssoftware.
-a Currently.
-c size:Settingscorefile.:blocks
-d size:Settingsdata.:kbytes
-f size:SettingsCreatefile.:blocks
-l size:Settingsmemoryprocess.:kbytes
-m size:Settingsmemory.:kbytes
-n size:SettingsMeanwhilefile.:n
-p size:Settings.:kbytes
-s size:Settings.:kbytes
-t size:SettingsCPU.:seconds
-v size:Settingsmemory.:kbytes
-H Settingshardware.
-S Settingssoftware.
-a Currently.
-c size:Settingscorefile.:blocks
-d size:Settingsdata.:kbytes
-f size:SettingsCreatefile.:blocks
-l size:Settingsmemoryprocess.:kbytes
-m size:Settingsmemory.:kbytes
-n size:SettingsMeanwhilefile.:n
-p size:Settings.:kbytes
-s size:Settings.:kbytes
-t size:SettingsCPU.:seconds
-v size:Settingsmemory.:kbytes
InstallationConfiguration
Installation
[root@server soft]# tar -zxvf squid-3.0.STABLE24.tar.gz
[root@server soft]# cd squid-3.0.STABLE24
[[email protected]]#./configure –prefix=/usr/local/squid/–enable-gnuregex/–enable-icmp/–enable-linux-netfilter/–enable-default-err-language="Simplify_Chinese"/–enable-kill-parent-hack/–enable-cache-digests/–enable-dlmalloc/–enable-poll/–enable-async-io=240/–enable-delay-pools/–with-filedescriptors=65536/–enable-snmp/–enable-arp-acl/–mandir=/usr/share/man/–with-large-files
:
command
[root@viong squid-3.0.STABLE24]# ./configure –help
–enable-gnuregex
Configuration,squid。GNUsquid;operating system。./configurescriptsystem,,GNU。IfBecause,GNU,For instanceproxy。,./configurecommand.
–enable-icmp
squidICMPmessage,ping。Functions。
–enable-linux-netfilter
Netfilterlinux 2.4。linux2.4versionHTTPFunctions,。
–enable-default-err-language=lang
Settingserror_directorydefault。For example,,:
% ./configure –enable-default-err-language=Dutch
squid.conferror_directory,A。,defaulterror。
–enable-kill-parent-hack
squid,parent process
–enable-cache-digests
CacheICP,
–enable-dlmalloc[=LIB]
system,memory(malloc)squid。–enable-dlmallocsquiddlmallocCompilation。systemInstallationdlmalloc,=LIBparameterpath。
–enable-poll
unixfunctionI/Oeventfile:select()poll()../configurescriptpoll()select().poll(),。
–enable-async-io[=N_THREADS]
I/Osquidtechnology,Performance。aufsmodulethreaddiskI/O。linuxsolarissystem。=N_THREADSparametersquidthread。IfserverConfiguration,160。If,40.
Note: –enable-async-io./configure,:
–with-aufs-threads=N_THREADS
–with-pthreads
–enable-storeio=ufs,aufs
–enable-delay-pools
squidbandwidthtechnology。clientIPAddress。clientrequestcache,response
–with-filedescriptors=65536
file
–enable-snmp
networkManagement(SNMP)networkserver。CompilationCompilationSNMP,versionCMU SNMP。
–enable-arp-acl
MACAddress
–mandir=/usr/share/man
manInstallationdirectory
–with-large-files
log2G
[root@server squid-3.0.STABLE24]# make; make install
make[3]: Leaving directory `/root/soft/squid-3.0.STABLE24/tools'
make[2]: Leaving directory `/root/soft/squid-3.0.STABLE24/tools'
make[1]: Leaving directory `/root/soft/squid-3.0.STABLE24/tools'
make[1]: Entering directory `/root/soft/squid-3.0.STABLE24'
Build Successful.
make[2]: Entering directory `/root/soft/squid-3.0.STABLE24'
make[2]: Nothing to be done for `install-exec-am'.==================DescriptionInstallationsuccess
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/root/soft/squid-3.0.STABLE24'
make[1]: Leaving directory `/root/soft/squid-3.0.STABLE24'
[root@server squid-3.0.STABLE24]#
[root@server squid-3.0.STABLE24]# ll /usr/local/squid–enable-gnuregex/
24
drwxr-xr-x 2 root root 4096 03-04 23:35 bin
drwxr-xr-x 2 root root 4096 03-04 23:35 etc
drwxr-xr-x 2 root root 4096 03-04 23:35 libexec
drwxr-xr-x 2 root root 4096 03-04 23:35 sbin
drwxr-xr-x 5 root root 4096 03-04 23:35 share
drwxr-xr-x 3 root root 4096 03-04 23:35 var
bin/ :squidscriptsdirectory,RunCache;
etc/ :squid;
libexec/ :;
sbin/ :squid!
share/ :error,directory;
var/ :log file,,!
squid,Settings/usr/local/squid/var,/usr/local/squid/etc/squid.confAdd,visible_hostnam viong http_port port.80
[root@server squid-3.0.STABLE24]# chown -R nobody:nobody /usr/local/squid/var
[root@server squid-3.0.STABLE24]# /usr/local/squid/sbin/squid –zD
squidcache,squidDNSStart,CurrentlyConfiguration,DNSTesting,squidStart
Squid[root@viong soft]# netstat -ntpl |grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
[root@server squid-3.0.STABLE24]# /usr/local/squid/bin/squidclient -p 80 -h localhost mgr:info
squid
HTTP/1.0 200 OK
Server: squid/3.0.STABLE24
Mime-Version: 1.0
Date: Fri, 05 Mar 2010 14:43:26 GMT
Content-Type: text/plain
Expires: Fri, 05 Mar 2010 14:43:26 GMT
Last-Modified: Fri, 05 Mar 2010 14:43:26 GMT
X-Cache: MISS from viong
Via: 1.0 viong (squid/3.0.STABLE24)
Proxy-Connection: close
Squid Object Cache: Version 3.0.STABLE24
Start Time: Fri, 05 Mar 2010 14:42:48 GMT
Current Time: Fri, 05 Mar 2010 14:43:26 GMT
Connection information for squid:
Number of clients accessing cache: 1
Number of HTTP requests received: 0
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: 0.0
Average ICP messages per minute since start: 0.0
Select loop called: 8659 times, 4.376 ms avg
Cache information for squid:
Hits as % of all requests: 5min: 0.0%, 60min: 0.0%
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: 0 KB
Storage Swap capacity: 0.0% used, 100.0% free
Storage Mem size: 104 KB
Storage Mem capacity: 1.3% used, 98.7% free
Mean Object Size: 0.00 KB
Requests given to unlinkd: 0
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: 37.890 seconds
CPU Time: 0.070 seconds
CPU Usage: 0.18%
CPU Usage, 5 minute avg: 0.00%
CPU Usage, 60 minute avg: 0.00%
Process Data Segment Size via sbrk(): 2784 KB
Maximum Resident Size: 0 KB
Page faults with physical i/o: 0
Memory usage for squid via mallinfo():
Total space in arena: 3052 KB
Ordinary blocks: 2938 KB 1 blks
Small blocks: 0 KB 0 blks
Holding blocks: 1520 KB 8 blks
Free Small blocks: 0 KB
Free Ordinary blocks: 113 KB
Total in use: 4458 KB 98%
Total free: 113 KB 2%
Total size: 4572 KB
Memory accounted for:
Total accounted: 1886 KB 41%
memPool accounted: 1886 KB 41%
memPool unaccounted: 2685 KB 59%
memPoolAlloc calls: 1504
memPoolFree calls: 481
File descriptor usage for squid:
Maximum number of file descriptors: 65536 =============file
Largest file desc currently in use: 16
Number of file desc currently in use: 10
Files queued for open: 0
Available number of file descriptors: 1014
Reserved number of file descriptors: 100
Store Disk files open: 0
Internal Data Structures:
26 StoreEntries
26 StoreEntries with MemObjects
25 Hot Object Cache Items
0 on-disk objects
:
Squidclientparameter:
squid: squidclient -p 80 mgr:info
squidmemory: squidclient -p 80 mgr:mem
squidCache: squidclient -p 80 mgr:objects
squiddisk: squidclient -p 80 mgr:diskd
squid: squidclient -p 80 mgr:info
squidmemory: squidclient -p 80 mgr:mem
squidCache: squidclient -p 80 mgr:objects
squiddisk: squidclient -p 80 mgr:diskd
ulimit -HSn 65536 ,squidStartscript,replicationscriptsquid.sh
#!/bin/sh
#
ulimit -HSn 65536
# starts and stops Squid
case "$1" in
start)
/usr/local/squid/sbin/squid -s
echo -n ' Squid'
;;
stop)
/usr/local/squid/sbin/squid -k shutdown
;;
esac
#
ulimit -HSn 65536
# starts and stops Squid
case "$1" in
start)
/usr/local/squid/sbin/squid -s
echo -n ' Squid'
;;
stop)
/usr/local/squid/sbin/squid -k shutdown
;;
esac
StartStopsquid,command
[root@viong soft]# sh squid.sh stop
[root@viong soft]# sh squid.sh start
http://viong.blog.51cto.com/844766/280978
http://viong.blog.51cto.com/844766/280978

