当前位置:IT教程网教程中心操作系统代理服务器 → 教程内容

SQUID一问

减小字体 增大字体 作者:佚名  来源:不详  发布时间:2007-1-1 11:31:00

我用RedHat 9自带的Squid 2.5.STABLE1版本构建二级代理已经成功,但有一个问题总是不知何解?就是我每次启动SQUID服务,总是出现:
Starting squid: ....................                       [FAILED]
但是我用squid status看,结果又是:
squid (pid 9283 9280) is running...
而且所有客户端都能正常使用。查看cache.log有如下信息:
2003/06/17 10:24:48| Unlinkd pipe opened on FD 9
2003/06/17 10:24:48| Swap maxSize 5120000 KB, estimated 393846 objects
2003/06/17 10:24:48| Target number of buckets: 19692
2003/06/17 10:24:48| Using 32768 Store buckets
2003/06/17 10:24:48| Max Mem  size: 262144 KB
2003/06/17 10:24:48| Max Swap size: 5120000 KB
2003/06/17 10:24:48| Store logging disabled
2003/06/17 10:24:48| Rebuilding storage in /home2/var_squid/cache (DIRTY)
2003/06/17 10:24:48| Using Least Load store dir selection
2003/06/17 10:24:48| Current Directory is /home2/var_squid/logs
2003/06/17 10:24:48| Loaded Icons.
2003/06/17 10:24:48| Accepting HTTP connections at 0.0.0.0, port 6666, FD 10.
2003/06/17 10:24:48| WCCP Disabled.
2003/06/17 10:24:48| Ready to serve requests.
2003/06/17 10:24:48| Done reading /home2/var_squid/cache swaplog (1613 entries)
2003/06/17 10:24:48| Finished rebuilding storage from disk.
2003/06/17 10:24:48|      1579 Entries scanned
2003/06/17 10:24:48|         0 Invalid entries.
2003/06/17 10:24:48|         0 With invalid flags.
2003/06/17 10:24:48|      1574 Objects loaded.
2003/06/17 10:24:48|         0 Objects expired.
2003/06/17 10:24:48|         5 Objects cancelled.
2003/06/17 10:24:48|        27 Duplicate URLs purged.
2003/06/17 10:24:48|         0 Swapfile clashes avoided.
2003/06/17 10:24:48|   Took 0.3 seconds (5398.3 objects/sec).
2003/06/17 10:24:48| Beginning Validation Procedure
2003/06/17 10:24:48|   Completed Validation Procedure
2003/06/17 10:24:48|   Validated 1547 Entries

没有发现什么异常呀。
请教各位大侠,是不是conf文件那里有问题,或者应该如何设置才能解决这个问题?
谢谢大家了!!!

 段誉 回复于:2003-06-17 11:05:41
在启动之前,应该先停掉squid吧,有相同进程在跑,肯定不行啊。

 yeair 回复于:2003-06-17 11:30:42
进程我先用squid stop停掉了,也用pkill -u squid杀过,也reboot过,都一样呀,启动前ps -ef看过了,没有的。真的不知了,斑竹帮忙呀!!

 yeair 回复于:2003-06-17 13:14:26
up

 yeair 回复于:2003-06-17 21:49:47
   
问题终于解决了,原来我在squid.conf中加了
pid_filename /home2/var_squid/logs/squid.pid
本来,squid应该可以自己找到替换默认的,可是我打开
redhat 9的/etc/init.d/squid这个script才发现,它的默认居然是
/var/run/squid.pid
而且不能是别的,因为在下面的程序中有这样的判断:
[ ! -f /var/run/squid.pid ] || break
自然对于我的系统,永远都要break,所以failed是肯定的,虽然可以用,
但是pid号对于squid来说永远未知,所以stop也会failed,进程杀不死。
唉,居然这样~~~~~~我重新装了squid 2.5 stable3,那个脚本还是
老样子~~~~所以,只好动手了,现在把新改过的脚本贴出来,希望对大家有点用,不对地方还要多多指教!!!!


#!/bin/bash
# squidThis 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
########
#Update: 06172003, May & Chenzj, VLSI.ZJU,
#          can set pidfile name in&s;'''/etc/squid/squidof'''
#          like:&s;'''pid_filename /etc/run/squidi1'''

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

# check if the squid conf file is present
[ -f /etc/squid/squid.conf ] || exit 0

if [ -f /etc/sysconfig/squid ]; then
  . /etc/sysconfig/squid
fi

#&nbsdn'''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}

# determine the name of the squid binary
[ -f /usr/sbin/squid ] && SQUID=squid
[ -z "$SQUID" ] && exit 0

prog="$SQUID"

# determine which one is the cache_swap directory
CACHE_SWAP=`sed -e&s;'''s/#/g''' /etc/squid/squid.conf | \
grep cache_dir |  awkbp''''{ print $3&s;''''`
[ -z "$CACHE_SWAP" ] && CACHE_SWAP=/var/spool/squid

# determine which one is the pidfile directory
PID_FILE=`sed -ebp''''s/*/'''' /etc/squid/squid.conf | \
grep pid_filename |  awns;''''{ print $2bp}''''`
[ -z "$PID_FILE" ] && PID_FILE=/var/run/squid.pid

# echo $PID_FILE

RETVAL=0

start() {
    for adir in $CACHE_SWAP; do
        if [ ! -d $adir/00 ]; then 
     echo -n "init_cache_dir $adir... "
     $SQUID -z -F -D 2>/dev/null
fi
    done
    echo -n $"Starting $prog: "
    $SQUID $SQUID_OPTS 2> /dev/null
    RETVAL=$?
    if [ $RETVAL -eq 0 ]; then 
       timeout=0;
       while : ; do
          [ ! -f $PID_FILE ] || 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/$SQUID
    [ $RETVAL -eq 0 ] && echo_success
    [ $RETVAL -ne 0 ] && echo_failure
    echo
    return $RETVAL
}

stop() {
    echo -n  $"Stopping $prog: "
    $SQUID -k check >/dev/null 2>&1
    RETVAL=$?
    if [ $RETVAL -eq 0 ] ; then
        $SQUID -k shutdown &
    rm -f /var/lock/subsys/$SQUID
timeout=0
 while : ; do
[ -f $PID_FILE ] || 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 $SQUID_OPTS -k reconfigure 
}

restart() {
    stop
    start
}    

condrestart() {
    [ -e /var/lock/subsys/squid ] && restart || :
}

rhstatus() { 
    status $SQUID
    $SQUID -k check
}

probe() {
    return 0
}    

case "$1" in
start)
    start
    ;;

stop)
    stop
    ;;

reload)
    reload
    ;;

restart)
    restart
    ;;

condrestart)
    condrestart
    ;;

status)
    rhstatus
    ;;

probe)
    exit 0
    ;;

*)
    echo $"Usage: $0 {start|stop|status|reload|restart|condrestart}"
    exit 1
esac

exit $?

 yeair 回复于:2003-06-18 15:47:02
谢谢斑竹置顶:)
我再说详细一点:
主要修改的是一下部分:
# determine which one is the pidfile directory 
PID_FILE=`sed -ns;''''s./g'''' /etc/squid/squid.conf | \ 
grep pid_filename | awns;''''{ print $2bp}''''` 
[ -z "$PID_FILE" ] && PID_FILE=/var/run/squid.pid 
用来得到PID_FILE的值,从squid.conf中。
然后就是相应的要把以前的/var/run/squid.pid 部分替换成
$PID_FILE,就这么简单:-)

 zzh2482 回复于:2003-11-13 03:55:10
请问我在使用redhat 9 自带的squid时,总是报一行错不知何意
请教!请教!

错误:FATAL:Could not determine fully qualified hostname 
         please sens;''''visible_htae''''


email:zhuzhenghua@126.com

广告位置