每个人生的当口,都是会有一个孤独的时刻,四顾无人,只有自己,于是不得不看明白自己的脆弱,自己的欲望,自己的念想,自己的界限,还有,自己真正的梦想。
分类: LINUX
2016-05-11 15:37:13
原文地址:Squid+mysql验证排错经历 作者:飞鸿无痕
公司出口服务器是用的squid+mysql验证+iptables防火墙来控制用户上网的!我来了以后才知道公司出口服务器只有一台,没有备份用机,如果出口服务器硬件出问题,将导致整个公司网络瘫痪,于是申请了一台机器来搭建出口备份用服务器。
今天刚好有时间就来搭建下,但是出现了以前搭建时候没见过的问题,总结了下发出来,为大家以后安装遇到类似的问题提供参考!至于详细的安装过程,请搜索我以前在发的帖子《squid详细文档》,里面叙述得很清楚!先说下我的环境:
系 统:Red Hat Enterprise Linux AS release 4
Mysql:mysql-
Mysql_auth:mysql_auth-0.8.tar.gz
Squid:squid-2.5.STABLE13.tar.gz
编译环境:gcc-
下面是解决的过程:
当我把squid和mysql以及mysql_auth都安装好了以后,权限等也设置好了,但是启动的时候穿线如下问题(添加验证配置之前是正常启动的)!
[root@gateway etc]# /usr/local/squid/sbin/squid -Nd 1
2009/06/24 11:11:57| Starting Squid Cache version 2.5.STABLE13 for i686-pc-linux-gnu...
2009/06/24 11:11:57| Process ID 28778
2009/06/24 11:11:57| With 8192 file descriptors available
2009/06/24 11:11:57| Performing DNS Tests...
2009/06/24 11:11:57| Successful DNS name lookup tests...
2009/06/24
11:11:57| DNS Socket created at
2009/06/24 11:11:57| Adding nameserver 210.53.31.2 from squid.conf
2009/06/24 11:11:57| helperOpenServers: Starting 5 'mysql_auth' processes
2009/06/24 11:11:57| Unlinkd pipe opened on FD 14
2009/06/24 11:11:57| Swap maxSize 20480000 KB, estimated 1575384 objects
2009/06/24 11:11:57| Target number of buckets: 78769
2009/06/24 11:11:57| Using 131072 Store buckets
2009/06/24 11:11:57| Max Mem size: 49152 KB
2009/06/24 11:11:57| Max Swap size: 20480000 KB
2009/06/24 11:11:57| Rebuilding storage in /usr/local/squid/var/cache (DIRTY)
2009/06/24 11:11:57| Using Least Load store dir selection
2009/06/24 11:11:57| Current Directory is /usr/local/squid/etc
2009/06/24 11:11:57| Loaded Icons.
2009/06/24
11:11:57| Accepting HTTP connections at
2009/06/24 11:11:57| WCCP Disabled.
2009/06/24 11:11:57| Ready to serve requests.
2009/06/24 11:11:57| WARNING: basicauthenticator #1 (FD 6) exited
2009/06/24 11:11:57| WARNING: basicauthenticator #2 (FD 7) exited
2009/06/24 11:11:57| WARNING: basicauthenticator #3 (FD 8) exited
2009/06/24 11:11:57| Too few basicauthenticator processes are running
FATAL: The basicauthenticator helpers are crashing too rapidly, need help!
Aborted
紧接着查看系统文件日志
less /var/log/messages
Jun 24 11:11:54 gateway squid: The basicauthenticator helpers are crashing too rapidly, need help!
因为一般squid有问题的话都会反应在这两个地方,此时还是看不出问题的所在,我上次也是同样的步骤没有出现这样的问题,于是google,baidu了一遍,但是网上多半说是/usr/local/squid/etc/mysql_auth.conf文件权限的问题,于是
chmod 777 /usr/local/squid/etc/mysql_auth.conf
chown squid.squid /usr/local/squid/etc/mysql_auth.conf
问题依旧!此时脑子一片空白了,没办法,又把所有的squid的日志文件都查看了一遍,在查看/usr/local/squid/var/logs/cache.log文件的时候惊喜的发现如下日志:
2009/06/23 16:41:48| Cache dir '/usr/local/squid/var/cache' size remains unchanged at 20480000 KB
2009/06/23
16:41:48| DNS Socket created at
2009/06/23 16:41:48| Adding nameserver 210.53.31.2 from squid.conf
2009/06/23 16:41:48| helperOpenServers: Starting 5 'mysql_auth' processes
(mysql_auth): error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: Permission denied
(mysql_auth): error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: Permission denied
(mysql_auth): error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: Permission denied
(mysql_auth): error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: Permission denied
2009/06/23
16:41:49| Accepting HTTP connections at
2009/06/23 16:41:49| WCCP Disabled.
(mysql_auth): error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: Permission denied
2009/06/23 16:41:49| Loaded Icons.
2009/06/23 16:41:49| eventCleanup
2009/06/23 16:41:49| Ready to serve requests.
2009/06/23 16:41:49| WARNING: basicauthenticator #1 (FD 11) exited
2009/06/23 16:41:49| WARNING: basicauthenticator #2 (FD 12) exited
2009/06/23 16:41:49| WARNING: basicauthenticator #3 (FD 15) exited
2009/06/23 16:41:49| Too few basicauthenticator processes are running
原来是libmysqlclient.so.16文件权限有问题,问题就好解决了!首先查看该文件是否存在:
[root@gateway logs]# find / -name "libmysqlclient.so.16" -print
/lib/libmysqlclient.so.16
/usr/local/lib/libmysqlclient.so.16
/usr/local/mysql/lib/mysql/libmysqlclient.so.16
/usr/lib/libmysqlclient.so.16
/root/zhang/squid/mysql-
然后查看下mysql_auth文件调用的libmysqlclient.so.16是在哪个目录下,用ldd查看下:
[root@gateway libexec]# ldd mysql_auth
libmysqlclient.so.16 =>
/lib/libmysqlclient.so.16 (0x
libc.so.6 => /lib/tls/libc.so.6 (0x
libcrypt.so.1 => /lib/libcrypt.so.1 (0x009ef000)
libnsl.so.1 => /lib/libnsl.so.1 (0x00b37000)
libm.so.6 => /lib/tls/libm.so.6 (0x
libz.so.1 => /usr/lib/libz.so.1 (0x00111000)
/lib/ld-linux.so.2 (0x00651000)
好了,终于发现libmysqlclient.so.16的路径了,加上权限就可以了,
chmod 755 /lib/libmysqlclient.so.16
OK,启动下,一切正常,
[root@gateway ~]# /usr/local/squid/sbin/squid &
[root@gateway libexec]# ps -aux | grep squid
Warning: bad
syntax, perhaps a bogus '-'? See /usr/share/doc/procps-
root 3948 0.0 0.1 4556 616 ? Ss 14:09 0:00 /usr/local/squid/sbin/squid
squid 3950 0.1 0.9 8912 4856 ? S 14:09 0:00 (squid)
squid 3951 0.0 0.1 4240 852 ? Ss 14:09 0:00 (mysql_auth)
squid 3952 0.0 0.1 3320 852 ? Ss 14:09 0:00 (mysql_auth)
squid 3953 0.0 0.1 4404 852 ? Ss 14:09 0:00 (mysql_auth)
squid 3954 0.0 0.1 4296 852 ? Ss 14:09 0:00 (mysql_auth)
squid 3955 0.0 0.1 3696 852 ? Ss 14:09 0:00 (mysql_auth)
squid 3956 0.0 0.0 2740 272 ? Ss 14:09 0:00 (unlinkd)
[root@gateway libexec]# netstat -lnp | grep squid
tcp 0
0
udp 0 0
打开网页,终于出现了代理验证窗口,输入用户名密码,久违的网页终于出现了,至此问题解决!
通过这次问题的解决告诉我们,程序的日志文件非常的重要,如果程序出问题会第一时间反应在程序的日志文件甚至系统日志文件,所以我们解决问题的利剑就是利用日志文件!如果实在找不到问题的所在,那就把该程序的日志文件都浏览一遍,也许能发现一些蛛丝马迹!