且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Squid

更新时间:2022-10-04 18:47:26

1、Squid代理有三种模式:

传统代理、透明代理和反向代理

Squid



2、haproxy和squid代理的区别

haproxy是专业代理,squid可以做代理和缓存



3、安装squid硬件和系统要求

squid可以运行在几乎所有的常见Unix及Linux系统上,也可以在Windows上运行。

1)第一重要资源:内存

squid对硬件的要求最主要的就是内存资源,内存短缺会影响性能。因为所有的对象都会被缓存到内存中,


2)第二重要资源:磁盘IO

磁盘空间也是另一个squid能够高效运行的重要因素。更多的磁盘空间意味着更多的缓存目标和更高的命中率。快速的磁盘介质也是必要的。例如:SSD、SAS代替SATA硬盘

当然快速的CPU也是好的,但他并不是提高性能的关键因素。



4、Squid安装

1)下载安装包:http://www.squid-cache.org/Versions/

2)编译前关键内核调整

a、调整文件描述符

关于文件描述符的介绍参考:http://qingwang.blog.51cto.com/505009/579064/

查看当前用户的文件描述符设置:

1
2
# ulimit -n
1024


设置文件最大最大描述符的数目的方法:

方法一“”

1
2
#ulimit -Hn 20480
#echo “ulimit -Hn 20480” >> /etc/rc.local

方法二:

vim /etc/sysctl.conf

追加以下内容

1
fs.file-max = 102400

保存后使用sysctl -p命令使其生效


b、调整临时端口范围:

查看临时端口范围的方法:

1
2
# cat /proc/sys/net/ipv4/ip_local_port_range 
32768  61000

修改端口范围方法:

1
2
3
4
echo "net.ipv4.ip_local_port_range = 4000  65000" >>/etc/sysctl.conf
sysctl -p
# cat /proc/sys/net/ipv4/ip_local_port_range 
4000  65000


c、编译前查看帮助:

帮助文件路径在解压后的目录下,名为INSTALL

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
cat INSTALL 
/*
 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
 *
 * Squid software is distributed under GPLv2+ license and includes
 * contributions from numerous individuals and organizations.
 * Please see the COPYING and CONTRIBUTORS files for details.
 */
To build and install the Squid Cache, type:
% ./configure --prefix=/usr/local/squid
        make all
        make install
To run a Cache, you will need to:
1. customize the squid.conf configuration file:
      vi /usr/local/squid/etc/squid.conf
2. Initalise the cache:
      /usr/local/squid/sbin/squid -z
       
3. start the cache:
      /usr/local/squid/sbin/squid
If you want to use the WWW interface to the Cache Manager, copy
the tools/cachemgr.cgi program into your httpd server's cgi-bin


d、安装

安装gcc和gcc-c++

1
2
3
yum -y install gcc gcc-c++
./configure --prefix=/usr/local/squid --enable-icmp --enable-storeio=ufs,aufs
#make && make install










本文转自 曾哥最爱 51CTO博客,原文链接:http://blog.51cto.com/zengestudy/1856391,如需转载请自行联系原作者