Squid调优
目的
通过调优Squid的配置文件,可以有效的提高服务器的性能。
方法
- 配置Squid配置文件。
执行脚本优化配置文件,文件路径:“/usr/local/squid/etc/squid.conf”。
脚本内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/bin/bash SquidIP=$1 SquidFile=/usr/local/squid/etc/squid.conf sed -i "s/http_access deny all/http_access allow all/" $SquidFile sed -i "/acl Safe_ports port 80/a acl Safe_ports port 82" $SquidFile sed -i "/coredump_dir/d" $SquidFile sed -i "/Leave coredumps/a coredump_dir /path/to/\n \ pid_filename /usr/local/squid/var/run/squid.pid" $SquidFile sed -i "51 a\workers 43\n \ cpu_affinity_map process_numbers=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48 cores=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48\n \ acl maxconds maxconn 65535\n \ http_access deny maxconds\n \ cache_effective_user squid\n \ cache_effective_group squid\n \ minimum_object_size 0 bytes\n \ maximum_object_size 512 KB\n \ cache_mem 20480 MB\n \ cache_dir rock /usr/local/squid/squid_cache 1024 slot-size=512\n \ cache_log /usr/local/squid/var/logs/cache.log\n \ cache_access_log none\n \ cache_store_log none\n \ cache_peer "$SquidIP" parent 80 0 no-query originserver name=httpd\n \ http_port "$SquidIP":82 accel vhost vport\n \ cache_peer_access httpd allow all\n" $SquidFile
Squid启动参数说明如表 Squid启动参数说明所示。
- 一路CPU上启动一个Squid实例。
1
/usr/local/squid/sbin/squid -s
如需启动两个Squid实例,需新建配置文件squid_2.conf,启动第二个实例。
1
/usr/local/squid/sbin/squid -f /usr/local/squid/etc/squid_2.conf
父主题: Squid 调优指南