Metainformationen zur Seite
Custom-Build Squid-3 unter CentOS 5
ACHTUNG: DIESE ANLEITUNG STIMMT SO NOCH NICHT!
Selbstgebauter Accel-Squid mit 131072 file-descriptoren für maximale Performance
1. Download der aktuellen 3er Stable von http://www.squid-cache.org/Versions/ nach /usr/src
2. Entpacken, danach „cd squid-3.0.STABLE5“
3. Vorraussetzungen installieren:
yum -y install kernel-headers glibc-headers glibc-devel imake autoconf elfutils-libs elfutils cpp libgomp gcc libstdc++-devel automake gcc-c++ rpm-build cyrus-sasl-devel
4. Maximale Anzahl gleichzeitig geöffneter Files hochsetzen, dies muss vor dem build passieren, das dieser Wert dabei verwendet wird. In /etc/security/limits.conf folgendes eintragen:
root soft nofile 131072 root hard nofile 131072
Danach neu einloggen und mit „ulimit -n“ prüfen, ob das neue Limit gesetzt ist, falls nicht: „ulimit -HSn 131072“ ausführen.
5. Configure mit diesen Optionen starten: Build-Optionen:
./configure --enable-poll \ --enable-storeio=aufs,coss,diskd,null,ufs \ --with-pthreads \ --enable-removal-policies=heap,lru \ --enable-epoll \ --enable-linux-netfilter \ --enable-useragent-log \ --enable-referer-log \ --enable-underscores \ --disable-dependency-tracking \ --disable-ident-lookups \ --with-large-files \ --enable-follow-x-forwarded-for \ --enable-cache-digests \ --enable-delay-pools \ --enable-truncate
6. danach „make“, „make install“ ausführen
7. folgendes Init-Script /etc/init.d/squid verwenden:
#!/bin/bash # squid This shell script takes care of starting and stopping # Squid Internet Object Cache # # chkconfig: - 90 25 # description: Squid - Internet Object Cache. Internet object caching is \ # a way to store requested Internet objects (i.e., data available \ # via the HTTP, FTP, and gopher protocols) on a system closer to the \ # requesting site than to the source. Web browsers can then use the \ # local Squid cache as a proxy HTTP server, reducing access time as \ # well as bandwidth consumption. # pidfile: /var/run/squid.pid # config: /etc/squid/squid.conf PATH=/usr/bin:/sbin:/bin:/usr/sbin export PATH # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 prog=squid SQUID_CONFIG=/usr/local/$prog/etc/squid.conf # check if the squid conf file is present [ -f $SQUID_CONFIG ] || exit 0 if [ -f /etc/sysconfig/squid ]; then . /etc/sysconfig/squid fi # don't raise an error if the config file is incomplete # set defaults instead: SQUID_OPTS=${SQUID_OPTS:-"-D"} SQUID_PIDFILE_TIMEOUT=${SQUID_PIDFILE_TIMEOUT:-20} SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-100} SQUID_FDMAX=${SQUID_FDMAX:-1024} ulimit -HSn $SQUID_FDMAX # determine the name of the squid binary #[ -f /usr/sbin/squid ] && SQUID=squid [ -f /usr/local/$prog/sbin/$prog ] && SQUID=/usr/local/$prog/sbin/$prog [ -z "$SQUID" ] && exit 0 # determine which one is the cache_swap directory CACHE_SWAP=`sed -e 's/#.*//g' /usr/local/$prog/etc/squid.conf | \ grep cache_dir | awk '{ print $3 }'` [ -z "$CACHE_SWAP" ] && CACHE_SWAP=/var/spool/$prog RETVAL=0 start() { for adir in $CACHE_SWAP; do if [ ! -d $adir/00 ]; then echo -n "init_cache_dir $adir... " $SQUID -z -F -D -f $SQUID_CONFIG >> /usr/local/squid/var/logs/squid.out 2>&1 fi done echo -n $"Starting $prog: " $SQUID $SQUID_OPTS -f $SQUID_CONFIG >> /usr/local/squid/var/logs/squid.out 2>&1 RETVAL=$? if [ $RETVAL -eq 0 ]; then timeout=0; while : ; do [ ! -f /var/run/$prog.pid ] || break if [ $timeout -ge $SQUID_PIDFILE_TIMEOUT ]; then RETVAL=1 break fi sleep 1 && echo -n "." timeout=$((timeout+1)) done fi [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog [ $RETVAL -eq 0 ] && echo_success [ $RETVAL -ne 0 ] && echo_failure echo return $RETVAL } stop() { echo -n $"Stopping $prog: " $SQUID -f $SQUID_CONFIG -k check >> /usr/local/squid/var/logs/squid.out 2>&1 RETVAL=$? if [ $RETVAL -eq 0 ] ; then $SQUID -f $SQUID_CONFIG -k shutdown & rm -f /var/lock/subsys/$prog timeout=0 while : ; do [ -f /var/run/$prog.pid ] || break if [ $timeout -ge $SQUID_SHUTDOWN_TIMEOUT ]; then echo return 1 fi sleep 2 && echo -n "." timeout=$((timeout+2)) done echo_success echo else echo_failure echo fi return $RETVAL } reload() { $SQUID -f $SQUID_CONFIG $SQUID_OPTS -k reconfigure } restart() { stop start } condrestart() { [ -e /var/lock/subsys/$prog ] && restart || : } rhstatus() { status $SQUID $SQUID -f $SQUID_CONFIG -k check } probe() { return 0 } clean() { rm -r $CACHE_SWAP/?? rm $CACHE_SWAP/swap.state* rm -f /usr/local/squid/var/logs/squid.out rm -f /var/run/$prog.pid rm -f /var/lock/subsys/$prog } case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) restart ;; condrestart) condrestart ;; status) rhstatus ;; probe) exit 0 ;; rotate) $SQUID -f $SQUID_CONFIG $SQUID_OPTS -k rotate ;; clean) clean ;; *) echo $"Usage: $0 {start|stop|status|reload|restart|condrestart|rotate|clean}" exit 1 esac exit $?
8. Die Datei „/etc/sysconfig/squid“ mit folgendem Inhalt erstellen:
# default squid options # -D disables initial dns checks. If you most likely will not to have an # internet connection when you start squid, uncomment this SQUID_OPTS="-D" # Time to wait for Squid to shut down when asked. Should not be necessary # most of the time. SQUID_SHUTDOWN_TIMEOUT=100 # maximum file descriptors available for squid: SQUID_FDMAX=32768
9. Folgendes in der Datei /etc/sysctl.conf ergänzen und die vorhandene Zeile mit syncookies löschen:
net.ipv4.tcp_syncookies = 0 net.ipv4.tcp_max_syn_backlog = 4096 net.ipv4.tcp_synack_retries = 3
10. Den User „squid“ und das Cache-Directory anlegen und Eigentümer von /usr/local/squid ändern
useradd squid mkdir /usr/local/squid/var/cache chown -R squid.squid /usr/local/squid
11. In /usr/local/squid/etc/squid.conf die Optionen cache_effective_user und cache_effective_group setzen und cache_dir-Parameter einkommentieren:
cache_effective_user squid cache_effective_group squid cache_dir ufs /usr/local/squid/var/cache 100 16 256
12. Jetzt noch die Squid-Cache Verzeichnisse erstellen und den Squid testweise mal starten:
cd /usr/local/squid/sbin ./squid -d9 -N -z ./squid -d9 -N
13. Der Squid sollte jetzt ohne Fehlermeldung zu starten sein.
Diskussion