Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redsocks2负载比较高的时候崩溃 #39

Closed
yanggis opened this issue Mar 5, 2016 · 119 comments
Closed

redsocks2负载比较高的时候崩溃 #39

yanggis opened this issue Mar 5, 2016 · 119 comments

Comments

@yanggis
Copy link

yanggis commented Mar 5, 2016

Hi semigodking谢谢开发这个项目,给我们的网络工作带来了极大的便利。
但是最近我碰到一个问题,是在Ubuntu上测试发现的。
就是redsocks2在负载比较高的时候会莫名其妙的崩溃,报的错误是,
redsocks[29116]: segfault at 9c ip b7740684 sp bfde666c error 4 in libevent-2.0.so.5.1.9[b772b000+4d000]
然后redsocks2就崩溃了,系统日志可以看到这个:
Mar 5 04:57:00 VPS systemd[1]: redsocks.service: main process exited, code=killed, status=11/SEGV
Mar 5 04:57:00 VPS systemd[1]: Unit redsocks.service entered failed state.
Mar 5 04:57:00 VPS systemd[1]: redsocks.service failed.
在这个错误之前就会报一些小错误:redsocks[29116]: [73.233.25.115:55405->104.23.18.178:80]: shutdown(relay, SHUT_WR): Transport endpoint is not connected

我搜了一下这个问题和libevent的一个bug有关系,这个如果您google搜索segfault error libevent就能类似的报告。求助有其他的解决办法吗?比如重新自己编译libevent修正这个bug,还是redsocks稍微调整一下避免这个bug呢?

@yanggis
Copy link
Author

yanggis commented Mar 5, 2016

另外,在高负荷运行一段时间就会提示
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: socket: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: [182.239.105.210:35390->104.26.18.17:80]: red_connect_relay failed!!!: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: accept: out of file descriptors, backing off for 96 ms: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: socket: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: [220.134.29.223:33877->104.26.18.17:80]: red_connect_relay failed!!!: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: accept: out of file descriptors, backing off for 25 ms: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: socket: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: [124.82.21.234:56587->104.26.18.17:80]: red_connect_relay failed!!!: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: socket: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: [61.244.107.12:57164->104.26.18.17:80]: red_connect_relay failed!!!: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: socket: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: [111.253.169.32:40503->104.26.18.17:80]: red_connect_relay failed!!!: Too many open files

@semigodking
Copy link
Owner

这种情况是因为你没改允许打开文件数限制。在启动redsocks2 时要用 ulimit -n 4096 设置下。具体ubuntu
上怎么通过配置文件改这个你要查一下。我不用ubuntu 的
2016年3月5日 上午10:56,"X.K. YANG" [email protected]写道:

另外,在高负荷运行一段时间就会提示
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: socket: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: [182.239.105.210:35390->
104.26.18.17:80]: red_connect_relay failed!!!: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: accept: out of file
descriptors, backing off for 96 ms: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: socket: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: [220.134.29.223:33877->
104.26.18.17:80]: red_connect_relay failed!!!: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: accept: out of file
descriptors, backing off for 25 ms: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: socket: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: [124.82.21.234:56587->
104.26.18.17:80]: red_connect_relay failed!!!: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: socket: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: [61.244.107.12:57164->
104.26.18.17:80]: red_connect_relay failed!!!: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: socket: Too many open files
Mar 5 10:53:54 yanggis-VPS redsocks[9399]: [111.253.169.32:40503->
104.26.18.17:80]: red_connect_relay failed!!!: Too many open files


Reply to this email directly or view it on GitHub
#39 (comment)
.

@yanggis
Copy link
Author

yanggis commented Mar 5, 2016

@semigodking
嗯,socket: Too many open files这个问题我已经解决啦。
现在最关键的还是第一个问题。虽然是在Ubuntu平台上测试的,但是如果高负荷运行,在其他的平台应该也有可能出现吧。我现在的连接数基本上是每小时25000个连接,也就是大概每分钟400多个。另外还有一个问题就是设置deamon=off的时候,在有有些ubuntu上没法启动,提示start redsocks service timeout.有些可以启动没问题。

@semigodking
Copy link
Owner

现在还会死掉?你编译时把调试信息带上,用最新代码。到时把core dump发给我看看。

@semigodking https://github.com/semigodking
嗯,socket: Too many open files这个问题我已经解决啦。
现在最关键的还是第一个问题。虽然是在Ubuntu平台上测试的,但是如果高负荷运行,在其他的平台应该也有可能出现吧。我现在的连接数基本上是每小时25000个连接,也就是大概每分钟400多个。另外还有一个问题就是设置deamon=off的时候,在有有些ubuntu上没法启动,提示start
redsocks service timeout.有些可以启动没问题。


Reply to this email directly or view it on GitHub
#39 (comment).

@semigodking
Copy link
Owner

Daemon off 启动时timeout我怀疑是你service没配置正确, service一直在等redsocks2进程结束
2016年3月5日 下午1:20,"Semigod King" [email protected]写道:

现在还会死掉?你编译时把调试信息带上,用最新代码。到时把core dump发给我看看。

@semigodking https://github.com/semigodking
嗯,socket: Too many open files这个问题我已经解决啦。
现在最关键的还是第一个问题。虽然是在Ubuntu平台上测试的,但是如果高负荷运行,在其他的平台应该也有可能出现吧。我现在的连接数基本上是每小时25000个连接,也就是大概每分钟400多个。另外还有一个问题就是设置deamon=off的时候,在有有些ubuntu上没法启动,提示start
redsocks service timeout.有些可以启动没问题。


Reply to this email directly or view it on GitHub
#39 (comment)
.

@yanggis
Copy link
Author

yanggis commented Mar 5, 2016

刚才看了一下服务器,在一点多的时候又挂掉了。错误信息是一样的。

Mar 5 13:16:53 VPS kernel: [13287.863978] redsocks[20782]: segfault at 9c ip b76ff684 sp bf8af7cc error 4 in libevent-2.0.so.5.1.9[b76ea000+4d000]
Mar 5 13:16:53 VPS systemd[1]: redsocks.service: main process exited, code=killed, status=11/SEGV
Mar 5 13:16:53 VPS systemd[1]: Unit redsocks.service entered failed state.
Mar 5 13:16:53 VPS systemd[1]: redsocks.service failed.

我先在把log日志设置为on,一会再等等看,再挂掉的话,把日志信息给你贴上来。

@yanggis
Copy link
Author

yanggis commented Mar 5, 2016

另外那个service配置,我一直都是默认的配置,应该不是有错呀,这是我的service配置文件,就是设施deamon=off,就启动不了了。但是事实上redsocks是启动了的,因为我看到有数据包在发送,只是系统检查service redsocks start timeout,就又关闭了。

这是我的配置文件:
#!/bin/sh
###BEGIN INIT INFO
#Provides: redsocks
#Required-Start: $network $local_fs $remote_fs
#Required-Stop: $remote_fs
#Default-Start: 2 3 4 5
#Default-Stop: 0 1 6
#Short-Description: redsocks TCP connection-to-SOCKS redirector
#Description:
#<...>
#<...>
###END INIT INFO

#Author: Apollon Oikonomopoulos [email protected]

#PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC=redsocks #Introduce a short description here
NAME=redsocks #Introduce the short server's name here
DAEMON=/usr/sbin/redsocks #Introduce the server's location here
DAEMON_ARGS="" #Arguments to run the daemon with
PIDFILE=/run/$NAME/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

#Exit if the package is not installed
[ -x $DAEMON ] || exit 0

#Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

#Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

#Define LSB log_* functions.
#Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

#Function that starts the daemon/service

do_start()
{
#Take care of pidfile permissions
USER=$(egrep '\buser\s_=' $CONFFILE | sed -r 's/.\buser\s+=\s(._);/\1/')
mkdir /run/$NAME 2>/dev/null || true
chown "$USER" /run/$NAME
#Return
#0 if daemon has been started
#1 if daemon was already running
#2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --
-c "$CONFFILE" -p $PIDFILE
|| return 2
#Add code here, if necessary, that waits for the process to be ready
#to handle requests from services started subsequently which depend
#on this one. As a last resort, sleep for some time.
}

#Function that stops the daemon/service

do_stop()
{
#Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
#Wait for children to finish too if this is a daemon that forks
#and if the daemon is only ever run from this initscript.
#If the above conditions are not satisfied then add some other code
#that waits for the process to drop all resources that could be
#needed by services started subsequently. A last resort is to
#sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
#Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
return "$RETVAL"
}

case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; #Old process is still running
*) log_end_msg 1 ;; #Failed to start
esac
;;
*)
#Failed to stop
log_end_msg 1
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac

:

@semigodking
Copy link
Owner

那很显然是service写的有问题而不是程序问题
2016年3月5日 下午2:43,"X.K. YANG" [email protected]写道:

另外那个service配置,我一直都是默认的配置,应该不是有错呀,这是我的service配置文件,就是设施deamon=off,就启动不了了。但是事实上redsocks是启动了的,因为我看到有数据包在发送,只是系统检查service
redsocks start timeout,就又关闭了。


Reply to this email directly or view it on GitHub
#39 (comment)
.

@yanggis
Copy link
Author

yanggis commented Mar 5, 2016

能提供一个您现在正在用的service文件吗?谢谢。

@yanggis
Copy link
Author

yanggis commented Mar 5, 2016

这是最新的抓取到的错误日志。

Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49670->104.23.18.17:80]: data relaying started
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49670->104.23.18.17:80]: relay, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49670->104.23.18.17:80]: WCB relay, fs: 0, ts: 2, fin: 0, fout: 339, tin: 218
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49670->104.23.18.17:80]: WCB client, fs: 2, ts: 0, fin: 218, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49670->104.23.18.17:80]: WCB client, fs: 2, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49669->104.23.18.17:80]: data relaying started
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49669->104.23.18.17:80]: WCB relay, fs: 0, ts: 0, fin: 0, fout: 339, tin: 507
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49669->104.23.18.17:80]: WCB client, fs: 0, ts: 0, fin: 507, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49669->104.23.18.17:80]: WCB client, fs: 0, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49669->104.23.18.17:80]: relay, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49669->104.23.18.17:80]: WCB client, fs: 2, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [202.53.146.5:13457->104.23.18.17:80]: data relaying started
Mar 5 16:46:05 VPS redsocks[4090]: [202.53.146.5:13457->104.23.18.17:80]: relay, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [202.53.146.5:13457->104.23.18.17:80]: WCB relay, fs: 0, ts: 2, fin: 0, fout: 373, tin: 181
Mar 5 16:46:05 VPS redsocks[4090]: [202.53.146.5:13457->104.23.18.17:80]: WCB client, fs: 2, ts: 0, fin: 181, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [202.53.146.5:13457->104.23.18.17:80]: WCB client, fs: 2, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49670->104.23.18.17:80]: client, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49670->104.23.18.17:80]: WCB relay, fs: 6, ts: 2, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49670->104.23.18.17:80]: both client and server disconnected
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49670->104.23.18.17:80]: dropping client
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49671->104.23.18.17:80]: data relaying started
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49671->104.23.18.17:80]: relay, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49671->104.23.18.17:80]: WCB relay, fs: 0, ts: 2, fin: 0, fout: 339, tin: 143
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49671->104.23.18.17:80]: WCB client, fs: 2, ts: 0, fin: 143, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49671->104.23.18.17:80]: WCB client, fs: 2, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49672->104.23.18.17:80]: data relaying started
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49672->104.23.18.17:80]: WCB relay, fs: 0, ts: 0, fin: 0, fout: 339, tin: 218
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49672->104.23.18.17:80]: WCB client, fs: 0, ts: 0, fin: 218, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49672->104.23.18.17:80]: WCB client, fs: 0, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49672->104.23.18.17:80]: relay, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49672->104.23.18.17:80]: WCB client, fs: 2, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [181.161.137.64:52328->104.23.18.17:80]: accepted
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49669->104.23.18.17:80]: client, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49669->104.23.18.17:80]: WCB relay, fs: 6, ts: 2, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49669->104.23.18.17:80]: both client and server disconnected
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49669->104.23.18.17:80]: dropping client
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49674->104.23.18.17:80]: data relaying started
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49674->104.23.18.17:80]: WCB relay, fs: 0, ts: 0, fin: 0, fout: 339, tin: 108
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49674->104.23.18.17:80]: WCB client, fs: 0, ts: 0, fin: 108, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49674->104.23.18.17:80]: WCB client, fs: 0, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49674->104.23.18.17:80]: relay, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49674->104.23.18.17:80]: WCB client, fs: 2, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [89.83.82.190:58766->104.23.18.17:80]: accepted
Mar 5 16:46:05 VPS redsocks[4090]: [89.83.82.190:58765->104.23.18.17:80]: accepted
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49675->104.23.18.17:80]: accepted
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]: data relaying started
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]: WCB relay, fs: 0, ts: 0, fin: 0, fout: 339, tin: 495
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]: WCB client, fs: 0, ts: 0, fin: 495, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]: WCB client, fs: 0, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]: RCB relay, in: 10
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]: relay, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]: WCB client, fs: 2, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49671->104.23.18.17:80]: client, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49671->104.23.18.17:80]: WCB relay, fs: 6, ts: 2, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49671->104.23.18.17:80]: both client and server disconnected
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49671->104.23.18.17:80]: dropping client
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49672->104.23.18.17:80]: client, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49672->104.23.18.17:80]: WCB relay, fs: 6, ts: 2, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49672->104.23.18.17:80]: both client and server disconnected
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49672->104.23.18.17:80]: dropping client
Mar 5 16:46:05 VPS redsocks[4090]: [202.53.146.5:13457->104.23.18.17:80]: client, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [202.53.146.5:13457->104.23.18.17:80]: WCB relay, fs: 6, ts: 2, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [202.53.146.5:13457->104.23.18.17:80]: both client and server disconnected
Mar 5 16:46:05 VPS redsocks[4090]: [202.53.146.5:13457->104.23.18.17:80]: dropping client
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49674->104.23.18.17:80]: client, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49674->104.23.18.17:80]: WCB relay, fs: 6, ts: 2, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49674->104.23.18.17:80]: both client and server disconnected
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49674->104.23.18.17:80]: dropping client
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]: client, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]: WCB relay, fs: 6, ts: 2, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]: both client and server disconnected
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]: dropping client
Mar 5 16:46:05 VPS redsocks[4090]: [219.92.174.89:25784->104.23.18.17:80]: accepted
Mar 5 16:46:06 VPS redsocks[4090]: [122.116.114.218:53125->104.23.18.17:80]: accepted
Mar 5 16:46:06 VPS redsocks[4090]: Audit client list for instance 0x8201288(http-relay):
Mar 5 16:46:06 VPS redsocks[4090]: [118.161.235.156:34132->104.23.18.17:80]: client(464): (R/-) SHUT_WR input 0 output 0, relay(465): (-/W) SHUT_RD input 0 output 0, age: 130 sec, idle: 128 sec.
Mar 5 16:46:06 VPS redsocks[4090]: [118.161.235.156:34132->104.23.18.17:80]: dropping client
Mar 5 16:46:06 VPS redsocks[4090]: [135.0.168.237:56755->104.23.18.17:80]: client(454): (R/-) SHUT_WR input 0 output 0, relay(445): (-/W) SHUT_RD input 0 output 0, age: 188 sec, idle: 188 sec.
Mar 5 16:46:06 VPS redsocks[4090]: [135.0.168.237:56755->104.23.18.17:80]: dropping client
Mar 5 16:46:06 VPS redsocks[4090]: [122.117.218.218:44027->104.23.18.17:80]: client(313): (-/W) SHUT_RD input 0 output 0, relay(318): (R/-) SHUT_WR input 0 output 0, age: 196 sec, idle: 184 sec.
Mar 5 16:46:06 VPS redsocks[4090]: [122.117.218.218:44027->104.23.18.17:80]: dropping client
Mar 5 16:46:06 VPS redsocks[4090]: [1.34.162.28:33103->104.23.18.17:80]: client(434): (R/-) SHUT_WR input 0 output 0, relay(446): (-/W) SHUT_RD input 0 output 0, age: 211 sec, idle: 210 sec.
Mar 5 16:46:06 VPS redsocks[4090]: [1.34.162.28:33103->104.23.18.17:80]: dropping client
Mar 5 16:46:06 VPS redsocks[4090]: [111.255.176.47:50011->104.23.18.17:80]: client(461): (R/-) SHUT_WR input 0 output 0, relay(463): (-/W) SHUT_RD input 0 output 0, age: 219 sec, idle: 218 sec.
Mar 5 16:46:06 VPS redsocks[4090]: [111.255.176.47:50011->104.23.18.17:80]: dropping client
Mar 5 16:46:06 VPS redsocks[4090]: [61.65.158.93:49699->104.23.18.17:80]: client(372): (R/-) SHUT_WR input 0 output 0, relay(457): (-/W) SHUT_RD input 0 output 0, age: 227 sec, idle: 226 sec.
Mar 5 16:46:06 VPS redsocks[4090]: [61.65.158.93:49699->104.23.18.17:80]: dropping client
Mar 5 16:46:06 VPS redsocks[4090]: [218.161.79.135:53024->104.23.18.17:80]: client(435): (R/-) SHUT_WR input 0 output 0, relay(438): (-/W) SHUT_RD input 0 output 0, age: 232 sec, idle: 231 sec.
Mar 5 16:46:06 VPS kernel: [25840.572096] redsocks[4090]: segfault at 9c ip b76ff684 sp bfc7b75c error 4 in libevent-2.0.so.5.1.9[b76ea000+4d000]
Mar 5 16:46:06 VPS redsocks[4090]: [218.161.79.135:53024->104.23.18.17:80]: dropping client
Mar 5 16:46:06 VPS redsocks[4090]: [126.227.229.93:49927->104.23.18.17:80]: client(319): (R/-) SHUT_WR input 0 output 0, relay(338): (-/W) SHUT_RD input 0 output 0, age: 239 sec, idle: 239 sec.
Mar 5 16:46:06 VPS redsocks[4090]: [126.227.229.93:49927->104.23.18.17:80]: dropping client
Mar 5 16:46:06 VPS systemd[1]: redsocks.service: main process exited, code=killed, status=11/SEGV
Mar 5 16:46:06 VPS systemd[1]: Unit redsocks.service entered failed state.
Mar 5 16:46:06 VPS systemd[1]: redsocks.service failed.

@semigodking
Copy link
Owner

这就是一个典型的nodaemon的service

$ cat lircd.service
[Unit]
Description=LIRC Infrared Signal Decoder
After=network.target

[Service]
Type=simple
ExecStart=/usr/sbin/lircd --nodaemon

[Install]
WantedBy=multi-user.target

另外,你可以试试把
#define REDSOCKS_AUDIT_INTERVAL 60*2
这个定义改大一点,比如改成 60 * 60,看看SEGV的情况下有没有改善。

On Sat, Mar 5, 2016 at 5:37 PM, X.K. YANG [email protected] wrote:

这是最新的抓取到的错误日志。

Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49670->104.23.18.17:80]:
data relaying started
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49670->104.23.18.17:80]:
relay, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49670->104.23.18.17:80]:
WCB relay, fs: 0, ts: 2, fin: 0, fout: 339, tin: 218
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49670->104.23.18.17:80]:
WCB client, fs: 2, ts: 0, fin: 218, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49670->104.23.18.17:80]:
WCB client, fs: 2, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49669->104.23.18.17:80]:
data relaying started
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49669->104.23.18.17:80]:
WCB relay, fs: 0, ts: 0, fin: 0, fout: 339, tin: 507
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49669->104.23.18.17:80]:
WCB client, fs: 0, ts: 0, fin: 507, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49669->104.23.18.17:80]:
WCB client, fs: 0, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49669->104.23.18.17:80]:
relay, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49669->104.23.18.17:80]:
WCB client, fs: 2, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [202.53.146.5:13457->104.23.18.17:80]:
data relaying started
Mar 5 16:46:05 VPS redsocks[4090]: [202.53.146.5:13457->104.23.18.17:80]:
relay, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [202.53.146.5:13457->104.23.18.17:80]:
WCB relay, fs: 0, ts: 2, fin: 0, fout: 373, tin: 181
Mar 5 16:46:05 VPS redsocks[4090]: [202.53.146.5:13457->104.23.18.17:80]:
WCB client, fs: 2, ts: 0, fin: 181, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [202.53.146.5:13457->104.23.18.17:80]:
WCB client, fs: 2, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49670->104.23.18.17:80]:
client, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49670->104.23.18.17:80]:
WCB relay, fs: 6, ts: 2, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49670->104.23.18.17:80]:
both client and server disconnected
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49670->104.23.18.17:80]:
dropping client
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49671->104.23.18.17:80]:
data relaying started
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49671->104.23.18.17:80]:
relay, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49671->104.23.18.17:80]:
WCB relay, fs: 0, ts: 2, fin: 0, fout: 339, tin: 143
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49671->104.23.18.17:80]:
WCB client, fs: 2, ts: 0, fin: 143, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49671->104.23.18.17:80]:
WCB client, fs: 2, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49672->104.23.18.17:80]:
data relaying started
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49672->104.23.18.17:80]:
WCB relay, fs: 0, ts: 0, fin: 0, fout: 339, tin: 218
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49672->104.23.18.17:80]:
WCB client, fs: 0, ts: 0, fin: 218, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49672->104.23.18.17:80]:
WCB client, fs: 0, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49672->104.23.18.17:80]:
relay, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49672->104.23.18.17:80]:
WCB client, fs: 2, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [181.161.137.64:52328->104.23.18.17:80]:
accepted
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49669->104.23.18.17:80]:
client, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49669->104.23.18.17:80]:
WCB relay, fs: 6, ts: 2, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49669->104.23.18.17:80]:
both client and server disconnected
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49669->104.23.18.17:80]:
dropping client
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49674->104.23.18.17:80]:
data relaying started
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49674->104.23.18.17:80]:
WCB relay, fs: 0, ts: 0, fin: 0, fout: 339, tin: 108
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49674->104.23.18.17:80]:
WCB client, fs: 0, ts: 0, fin: 108, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49674->104.23.18.17:80]:
WCB client, fs: 0, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49674->104.23.18.17:80]:
relay, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49674->104.23.18.17:80]:
WCB client, fs: 2, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [89.83.82.190:58766->104.23.18.17:80]:
accepted
Mar 5 16:46:05 VPS redsocks[4090]: [89.83.82.190:58765->104.23.18.17:80]:
accepted
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49675->104.23.18.17:80]:
accepted
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]:
data relaying started
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]:
WCB relay, fs: 0, ts: 0, fin: 0, fout: 339, tin: 495
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]:
WCB client, fs: 0, ts: 0, fin: 495, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]:
WCB client, fs: 0, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]:
RCB relay, in: 10
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]:
relay, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]:
WCB client, fs: 2, ts: 0, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49671->104.23.18.17:80]:
client, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49671->104.23.18.17:80]:
WCB relay, fs: 6, ts: 2, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49671->104.23.18.17:80]:
both client and server disconnected
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49671->104.23.18.17:80]:
dropping client
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49672->104.23.18.17:80]:
client, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49672->104.23.18.17:80]:
WCB relay, fs: 6, ts: 2, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49672->104.23.18.17:80]:
both client and server disconnected
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49672->104.23.18.17:80]:
dropping client
Mar 5 16:46:05 VPS redsocks[4090]: [202.53.146.5:13457->104.23.18.17:80]:
client, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [202.53.146.5:13457->104.23.18.17:80]:
WCB relay, fs: 6, ts: 2, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [202.53.146.5:13457->104.23.18.17:80]:
both client and server disconnected
Mar 5 16:46:05 VPS redsocks[4090]: [202.53.146.5:13457->104.23.18.17:80]:
dropping client
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49674->104.23.18.17:80]:
client, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49674->104.23.18.17:80]:
WCB relay, fs: 6, ts: 2, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49674->104.23.18.17:80]:
both client and server disconnected
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49674->104.23.18.17:80]:
dropping client
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]:
client, what: READING|0|EOF|0|0|0|0x0: Success
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]:
WCB relay, fs: 6, ts: 2, fin: 0, fout: 0, tin: 0
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]:
both client and server disconnected
Mar 5 16:46:05 VPS redsocks[4090]: [116.70.201.54:49673->104.23.18.17:80]:
dropping client
Mar 5 16:46:05 VPS redsocks[4090]: [219.92.174.89:25784->104.23.18.17:80]:
accepted
Mar 5 16:46:06 VPS redsocks[4090]: [122.116.114.218:53125->104.23.18.17:80]:
accepted
Mar 5 16:46:06 VPS redsocks[4090]: Audit client list for instance
0x8201288(http-relay):
Mar 5 16:46:06 VPS redsocks[4090]: [118.161.235.156:34132->104.23.18.17:80]:
client(464): (R/-) SHUT_WR input 0 output 0, relay(465): (-/W) SHUT_RD
input 0 output 0, age: 130 sec, idle: 128 sec.
Mar 5 16:46:06 VPS redsocks[4090]: [118.161.235.156:34132->104.23.18.17:80]:
dropping client
Mar 5 16:46:06 VPS redsocks[4090]: [135.0.168.237:56755->104.23.18.17:80]:
client(454): (R/-) SHUT_WR input 0 output 0, relay(445): (-/W) SHUT_RD
input 0 output 0, age: 188 sec, idle: 188 sec.
Mar 5 16:46:06 VPS redsocks[4090]: [135.0.168.237:56755->104.23.18.17:80]:
dropping client
Mar 5 16:46:06 VPS redsocks[4090]: [122.117.218.218:44027->104.23.18.17:80]:
client(313): (-/W) SHUT_RD input 0 output 0, relay(318): (R/-) SHUT_WR
input 0 output 0, age: 196 sec, idle: 184 sec.
Mar 5 16:46:06 VPS redsocks[4090]: [122.117.218.218:44027->104.23.18.17:80]:
dropping client
Mar 5 16:46:06 VPS redsocks[4090]: [1.34.162.28:33103->104.23.18.17:80]:
client(434): (R/-) SHUT_WR input 0 output 0, relay(446): (-/W) SHUT_RD
input 0 output 0, age: 211 sec, idle: 210 sec.
Mar 5 16:46:06 VPS redsocks[4090]: [1.34.162.28:33103->104.23.18.17:80]:
dropping client
Mar 5 16:46:06 VPS redsocks[4090]: [111.255.176.47:50011->104.23.18.17:80]:
client(461): (R/-) SHUT_WR input 0 output 0, relay(463): (-/W) SHUT_RD
input 0 output 0, age: 219 sec, idle: 218 sec.
Mar 5 16:46:06 VPS redsocks[4090]: [111.255.176.47:50011->104.23.18.17:80]:
dropping client
Mar 5 16:46:06 VPS redsocks[4090]: [61.65.158.93:49699->104.23.18.17:80]:
client(372): (R/-) SHUT_WR input 0 output 0, relay(457): (-/W) SHUT_RD
input 0 output 0, age: 227 sec, idle: 226 sec.
Mar 5 16:46:06 VPS redsocks[4090]: [61.65.158.93:49699->104.23.18.17:80]:
dropping client
Mar 5 16:46:06 VPS redsocks[4090]: [218.161.79.135:53024->104.23.18.17:80]:
client(435): (R/-) SHUT_WR input 0 output 0, relay(438): (-/W) SHUT_RD
input 0 output 0, age: 232 sec, idle: 231 sec.
Mar 5 16:46:06 VPS kernel: [25840.572096] redsocks[4090]: segfault at 9c
ip b76ff684 sp bfc7b75c error 4 in libevent-2.0.so.5.1.9[b76ea000+4d000]
Mar 5 16:46:06 VPS redsocks[4090]: [218.161.79.135:53024->104.23.18.17:80]:
dropping client
Mar 5 16:46:06 VPS redsocks[4090]: [126.227.229.93:49927->104.23.18.17:80]:
client(319): (R/-) SHUT_WR input 0 output 0, relay(338): (-/W) SHUT_RD
input 0 output 0, age: 239 sec, idle: 239 sec.
Mar 5 16:46:06 VPS redsocks[4090]: [126.227.229.93:49927->104.23.18.17:80]:
dropping client
Mar 5 16:46:06 VPS systemd[1]: redsocks.service: main process exited,
code=killed, status=11/SEGV
Mar 5 16:46:06 VPS systemd[1]: Unit redsocks.service entered failed state.
Mar 5 16:46:06 VPS systemd[1]: redsocks.service failed.


Reply to this email directly or view it on GitHub
#39 (comment)
.

@yanggis
Copy link
Author

yanggis commented Mar 5, 2016

哈哈,现在晚上负载更高,那个问题还没出现就已经达到报错:Too many open files了。
但是很奇怪,我已经通过ulimit 设置了最大打开文件是ulimit设置了最大数为1024000。通过检测也能发现设置成功了。结果如下:
root@yanggis-VPS:/etc/security/limits.d# ulimit -n
1024000
但是,我针对redsocks去检测时候发现redsocks的最大打开文件数还是1024没有变。首先我获得的是redsocks的进程,
root@yanggis-VPS:/etc/security/limits.d# ps aux | grep redsocks
root 29815 0.0 0.3 4748 1760 ? Ss Mar05 0:00 /usr/sbin/redsocks -c /etc/redsocks.conf
然后查看这个进程的限制参数:
root@yanggis-VPS:/etc/security/limits.d# cat /proc/29815/limits
Limit Soft Limit Hard Limit Units
Max cpu time unlimited unlimited seconds
Max file size unlimited unlimited bytes
Max data size unlimited unlimited bytes
Max stack size 8388608 unlimited bytes
Max core file size 0 unlimited bytes
Max resident set unlimited unlimited bytes
Max processes 3791 3791 processes
Max open files 1024 4096 files <------------这里是1024
Max locked memory 65536 65536 bytes
Max address space unlimited unlimited bytes
Max file locks unlimited unlimited locks
Max pending signals 3791 3791 signals
Max msgqueue size 819200 819200 bytes
Max nice priority 0 0
Max realtime priority 0 0
Max realtime timeout unlimited unlimited us

这个怎么解决呢?

@semigodking
Copy link
Owner

Ulimit 是仅当前shell 有效 ,要全局有效要改系统配置。
2016年3月6日 上午12:07,"X.K. YANG" [email protected]写道:

哈哈,现在晚上负载更高,那个问题还没出现就已经达到报错:Too many open files了。
但是很奇怪,我已经通过ulimit 设置了最大打开文件是ulimit设置了最大数为1024000。通过检测也能发现设置成功了。结果如下:
root@yanggis-VPS:/etc/security/limits.d# ulimit -n
1024000
但是,我针对redsocks去检测时候发现redsocks的最大打开文件数还是1024没有变。首先我获得的是redsocks的进程,
root@yanggis-VPS:/etc/security/limits.d# ps aux | grep redsocks
root 29815 0.0 0.3 4748 1760 ? Ss Mar05 0:00 /usr/sbin/redsocks -c
/etc/redsocks.conf
然后查看这个进程的限制参数:
root@yanggis-VPS:/etc/security/limits.d# cat /proc/29815/limits
Limit Soft Limit Hard Limit Units
Max cpu time unlimited unlimited seconds
Max file size unlimited unlimited bytes
Max data size unlimited unlimited bytes
Max stack size 8388608 unlimited bytes
Max core file size 0 unlimited bytes
Max resident set unlimited unlimited bytes
Max processes 3791 3791 processes
Max open files 1024 4096 files <------------这里是1024
Max locked memory 65536 65536 bytes
Max address space unlimited unlimited bytes
Max file locks unlimited unlimited locks
Max pending signals 3791 3791 signals
Max msgqueue size 819200 819200 bytes
Max nice priority 0 0
Max realtime priority 0 0
Max realtime timeout unlimited unlimited us

这个怎么解决呢?


Reply to this email directly or view it on GitHub
#39 (comment)
.

@yanggis
Copy link
Author

yanggis commented Mar 5, 2016

您好,我已经改了系统的配置文件了,你看现在对系统参数的检查结果:
root@yanggis-VPS:# cat /proc/sys/fs/file-max
2097152
root@yanggis-VPS:
# cat /proc/sys/fs/file-nr
1248(当前打开文件数) 0 2097152(最大数)
root@yanggis-VPS:~# cat /etc/security/limits.conf

  •     hard    nofile      500000
    
  •     soft    nofile      500000
    

root hard nofile 500000

root soft nofile 500000

但是,重启系统之后,看到redsocks 的还是Max open files 1024 4096 files。系统各方面检验结果现在都对了,就是针对redsocks 这个Max open files没有变。我刚开看了shadowsocks的源代码,它的代码在初始化的时候有自动加的一行:
do_start()
{
# Modify the file descriptor limit
ulimit -n ${MAXFD}
是不是和这个有关系呢?
但是我在redsocks的do_start()函数里也加了这句:

#Function that starts the daemon/service

do_start()
{
ulimit -n 20000

还是没起作用。

@yanggis
Copy link
Author

yanggis commented Mar 6, 2016

OK,现在Max open files这个问题已经解决了。现在测试#define REDSOCKS_AUDIT_INTERVAL 改成60*60,看看能不能解决segfault的问题。

@yanggis
Copy link
Author

yanggis commented Mar 6, 2016

修改之后,测试4个小时,现在还没出现问题。以前基本就是1个小时多就崩溃了。

@yanggis
Copy link
Author

yanggis commented Mar 6, 2016

@semigodking,感谢帮忙,测试到现在都没有问题,应该是没问题了。这个issue可以管了。

@yanggis yanggis closed this as completed Mar 6, 2016
@yanggis yanggis reopened this Mar 6, 2016
@yanggis
Copy link
Author

yanggis commented Mar 6, 2016

刚才开了一下系统日志发现redsocks又崩溃了,还是同意的问题,同样的报错信息,只是今天比昨天没修改前崩溃的频率低了一些。今天崩溃2次。
Mar 6 12:07:50 VPS kernel: [11117.803532] redsocks[3076]: segfault at 9c ip b7785684 sp bffb633c error 4 in libevent-2.0.so.5.1.9[b7770000+4d000]

Mar 6 15:08:02 VPS kernel: [21929.719660] redsocks[16782]: segfault at 9c ip b7743684 sp bffa039c error 4 in libevent-2.0.so.5.1.9[b772e000+4d000]

@semigodking
Copy link
Owner

那你可继续调大甚至关了 audit,对你这server, 我想应该没有大的影响
2016年3月6日 下午4:15,"X.K. YANG" [email protected]写道:

刚才开了一下系统日志发现redsocks又崩溃了,还是同意的问题,同样的报错信息,只是今天比昨天没修改前崩溃的频率低了一些。今天崩溃2次。
Mar 6 12:07:50 VPS kernel: [11117.803532] redsocks[3076]: segfault at 9c
ip b7785684 sp bffb633c error 4 in libevent-2.0.so.5.1.9[b7770000+4d000]

Mar 6 15:08:02 VPS kernel: [21929.719660] redsocks[16782]: segfault at 9c
ip b7743684 sp bffa039c error 4 in libevent-2.0.so.5.1.9[b772e000+4d000]


Reply to this email directly or view it on GitHub
#39 (comment)
.

@yanggis
Copy link
Author

yanggis commented Mar 6, 2016

@semigodking 感谢及时回复; 您说#define REDSOCKS_AUDIT_INTERVAL 改成60X60改成60X600之类的吗?怎么样可以在代码里关闭audit呢?

@semigodking
Copy link
Owner

是。注释掉redsocks_audit 里的实现即可。
2016年3月6日 下午4:26,"X.K. YANG" [email protected]写道:

@semigodking https://github.com/semigodking 感谢及时回复; 您说#define
REDSOCKS_AUDIT_INTERVAL 改成60_60改成60_600之类的吗?怎么样可以在代码里关闭audit呢?


Reply to this email directly or view it on GitHub
#39 (comment)
.

@yanggis
Copy link
Author

yanggis commented Mar 6, 2016

@semigodking,还有一个问题,我觉得redsocks很有可能有内存泄漏,我用top命令实时显示redsocks的内存占用量,刚开始启动的时候只有5M,然后开始逐步上升,最后崩溃之前已经是几十M了,就是从开始运行,一直在无限制的膨胀……。

@semigodking
Copy link
Owner

这个我也有怀疑,但最近还没查出原因。
2016年3月6日 下午5:10,"X.K. YANG" [email protected]写道:

@semigodking https://github.com/semigodking
,还有一个问题,我觉得redsocks很有可能有内存泄漏,我用top命令实时显示redsocks的内存占用量,刚开始启动的时候只有5M,然后开始逐步上升,最后崩溃之前已经是几十M了,就是从开始运行,一直在无限制的膨胀……。


Reply to this email directly or view it on GitHub
#39 (comment)
.

@yanggis
Copy link
Author

yanggis commented Mar 6, 2016

嗯,我运行了大概5个小时,占用内存从最初的5M已经涨到60M了,这个是个大麻烦,要是这么膨胀,一般的路由器肯定没法用了。

@semigodking
Copy link
Owner

一般路甴没有问题,我几天才增加几m 。应该和负荷有一定关系。
2016年3月6日 下午11:13,"X.K. YANG" [email protected]写道:

嗯,我运行了大概5个小时,占用内存从最初的5M已经涨到60M了,这个是个大麻烦,要是这么膨胀,一般的路由器肯定没法用了。


Reply to this email directly or view it on GitHub
#39 (comment)
.

@semigodking
Copy link
Owner

我现在才注意到,你用的是http-relay这种方式.我之前其实并没有怎么关注这一块相关的代码,也没有仔细测试过.刚看了看相关代码,我觉得http-relay的代码有很多值得改进的地方,特别是对内存使用方面需要改进.如果你懂C的话,建议你看看改改.

@yanggis
Copy link
Author

yanggis commented Mar 8, 2016

我是懂一点C,但是就是不太了解这个程序的架构,所以一下次吃透有点困难,但是我的基本上知道,问题就出在http-relay数据包的转发那个地方,基本上是转发一次就会有一点内存泄漏,因为我的服务器负载比较高,每天50万次的访问量,所以这个问题就很容易暴露出来了。很可能就是http-relay某个地方内存回收有问题。

@semigodking
Copy link
Owner

你试试这个patch看看效果吧,我没有多少时间仔细去改这个http-relay,现在http-relay工作应该是可以的,只是效率比较低.这个patch尝试略优化一下效率,解决一个可能出现的内存泄漏.我只编译通过,但没有验证过.建议你先在非生产环境验证下.
http_relay_test1.zip

@yanggis
Copy link
Author

yanggis commented Mar 21, 2016

Android上的makefile是一个Android.mk的文件,这个是我自己新建的。和你程序里那个带的那个makefile不一样,估计问题就在这。

@semigodking
Copy link
Owner

把那几个文件照着样子加进去就可以了。
2016年3月21日 下午1:01,"X.K. YANG" [email protected]写道:

Android上的makefile是一个Android.mk的文件,这个是我自己新建的。和你程序里那个带的那个makefile不一样,估计问题就在这。


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#39 (comment)

@yanggis
Copy link
Author

yanggis commented Mar 21, 2016

嗯,我试试。

@yanggis
Copy link
Author

yanggis commented Mar 21, 2016

嗯,那个编译过去了,现在socks5-udp.c编译的时候报这个错:

[armeabi] Compile thumb : redsocks <= socks5-udp.c
In file included from E:/Android_SDK/redsocks2/android/jni/openssl/ssl/../../../../socks5-udp.c:26:0:
E:/Android_SDK/redsocks2/android/jni/openssl/ssl/../../../../redudp.h:27:21: error: field 'bindaddr' has incomplete type
struct sockaddr_in bindaddr;
^
E:/Android_SDK/redsocks2/android/jni/openssl/ssl/../../../../redudp.h:28:21: error: field 'relayaddr' has incomplete type
struct sockaddr_in relayaddr;
^
E:/Android_SDK/redsocks2/android/jni/openssl/ssl/../../../../redudp.h:30:21: error: field 'destaddr' has incomplete type
struct sockaddr_in destaddr;
^
E:/Android_SDK/redsocks2/android/jni/openssl/ssl/../../../../redudp.h:50:22: error: field 'clientaddr' has incomplete type
struct sockaddr_in clientaddr;
^
E:/Android_SDK/redsocks2/android/jni/openssl/ssl/../../../../redudp.h:51:22: error: field 'destaddr' has incomplete type
struct sockaddr_in destaddr;
^
E:/Android_SDK/redsocks2/android/jni/openssl/ssl/../../../../redudp.h:63:21: error: field 'destaddr' has incomplete type
struct sockaddr_in destaddr;
^
make.exe: *** [E:/Android_SDK/redsocks2/android/obj/local/armeabi/objs/redsocks/socks5-udp.o] Error 1

@yanggis
Copy link
Author

yanggis commented Mar 21, 2016

现在就差socks5-udp.c这个文件编译通不过了,其他都编译成功了。

@semigodking
Copy link
Owner

Refuel.h 需要包含
#include <netinet/in.h>
2016年3月21日 下午1:10,"X.K. YANG" [email protected]写道:

嗯,那个编译过去了,现在socks5-udp.c编译的时候报这个错:

[armeabi] Compile thumb : redsocks <= socks5-udp.c
In file included from
E:/Android_SDK/redsocks2/android/jni/openssl/ssl/../../../../socks5-udp.c:26:0:
E:/Android_SDK/redsocks2/android/jni/openssl/ssl/../../../../redudp.h:27:21:
error: field 'bindaddr' has incomplete type
struct sockaddr_in bindaddr;
^
E:/Android_SDK/redsocks2/android/jni/openssl/ssl/../../../../redudp.h:28:21:
error: field 'relayaddr' has incomplete type
struct sockaddr_in relayaddr;
^
E:/Android_SDK/redsocks2/android/jni/openssl/ssl/../../../../redudp.h:30:21:
error: field 'destaddr' has incomplete type
struct sockaddr_in destaddr;
^
E:/Android_SDK/redsocks2/android/jni/openssl/ssl/../../../../redudp.h:50:22:
error: field 'clientaddr' has incomplete type
struct sockaddr_in clientaddr;
^
E:/Android_SDK/redsocks2/android/jni/openssl/ssl/../../../../redudp.h:51:22:
error: field 'destaddr' has incomplete type
struct sockaddr_in destaddr;
^
E:/Android_SDK/redsocks2/android/jni/openssl/ssl/../../../../redudp.h:63:21:
error: field 'destaddr' has incomplete type
struct sockaddr_in destaddr;
^
make.exe: ***
[E:/Android_SDK/redsocks2/android/obj/local/armeabi/objs/redsocks/socks5-udp.o]
Error 1


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#39 (comment)

@yanggis
Copy link
Author

yanggis commented Mar 21, 2016

程序里面没有Refuel.h这个文件呀。

@yanggis
Copy link
Author

yanggis commented Mar 21, 2016

难道你说的是redudp.h吗?

@semigodking
Copy link
Owner

是的,手机打字,自动更正搞错达。
2016年3月21日 下午1:20,"X.K. YANG" [email protected]写道:

难道你说的是redudp.h吗?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#39 (comment)

@yanggis
Copy link
Author

yanggis commented Mar 21, 2016

嗯,OK,那个编译过去了,现在缺少twalk,估计也是昨天那个问题,要找个twalk.c复制进来吧?

redudp.c:651: error: undefined reference to 'twalk'
collect2.exe: error: ld returned 1 exit status
make.exe: *** [E:/Android_SDK/redsocks2/android/obj/local/armeabi/redsocks] Error 1

@semigodking
Copy link
Owner

是 可以从musl 里搞出来
2016年3月21日 下午1:26,"X.K. YANG" [email protected]写道:

嗯,OK,那个编译过去了,现在缺少twalk,估计也是昨天那个问题,要找个twalk.c复制进来吧?

redudp.c:651: error: undefined reference to 'twalk'
collect2.exe: error: ld returned 1 exit status
make.exe: ***
[E:/Android_SDK/redsocks2/android/obj/local/armeabi/redsocks] Error 1


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#39 (comment)

@yanggis
Copy link
Author

yanggis commented Mar 21, 2016

好的,我去找找。

@yanggis
Copy link
Author

yanggis commented Mar 21, 2016

现在直接调用libevent2的编译好的文件是可以编译通了,但是用libevent2源文件参与编译的话就会报如下错误:
libevent2/event.c:49:25: fatal error: sys/eventfd.h: No such file or directory
#include <sys/eventfd.h>
缺少sys/eventfd.h文件,这个文件是从哪里可以获得呢?搜了一圈也没结果。

@semigodking
Copy link
Owner

那个是系统的文件不能通过这种方式获得。 你的目标平台的版本问题或者编译方式不对。
2016年3月21日 下午6:22,"X.K. YANG" [email protected]写道:

现在直接调用libevent2的编译好的文件是可以编译通了,但是用libevent2源文件参与编译的话就会报如下错误:
libevent2/event.c:49:25: fatal error: sys/eventfd.h: No such file or
directory
#include
缺少sys/eventfd.h文件,这个文件是从哪里可以获得呢?搜了一圈也没结果。


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#39 (comment)

@yanggis
Copy link
Author

yanggis commented Mar 21, 2016

弄了一天终于编译成功了,你需要把这个支持Android的平台配置文件合并进去吗?还是在Wiki简单写一下就OK了?

@semigodking
Copy link
Owner

在wiki上写一下就可以了,以后慢慢再合进去。谢谢!
2016年3月21日 下午9:10,"X.K. YANG" [email protected]写道:

弄了一天终于编译成功了,你需要把这个支持Android的平台配置文件合并进去吗?还是在Wiki简单写一下就OK了?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#39 (comment)

@yanggis
Copy link
Author

yanggis commented Mar 21, 2016

嗯,OK,这两天感谢你大力帮忙哈。

@semigodking
Copy link
Owner

不客气
2016年3月21日 下午9:12,"X.K. YANG" [email protected]写道:

嗯,OK,这两天感谢你大力帮忙哈。


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#39 (comment)

@yanggis
Copy link
Author

yanggis commented Apr 3, 2016

@semigodking 最近这一段使用又发现一个新问题,还要麻烦您帮忙。
因为这一段我的服务器使用人数剧增,并发人数可以达到1000-2000人,在使用redsocks就发现一个问题,在晚上8-10点钟的网络访问高峰期,redsocks2会突然没有任何响应,就是不接受任何数据包也不转发任何数据包了,处于假死状态,期间也没有报任何错误日志。然后我就只能手动重启,重启的时候报这个错误:

Apr 2 10:28:28 vps redsocks[22736]: getsockopt: No such file or directory
Apr 2 10:28:28 vps redsocks[22736]: redsocks goes down
Apr 2 10:28:28 vps redsocks[22736]: There are connected clients during shutdown! Disconnecting them.
Apr 2 10:28:28 vps redsocks[4047]: redsocks started

@yanggis
Copy link
Author

yanggis commented Apr 3, 2016

@semigodking 忘了补充一下了,内存基本上增加不明显,期间也没有什么错误,redsocks就突然处于假死状态不接受任何数据包了。基本都是发生在晚上8-10点钟的网络访问高峰期。高峰期连接数大概有2000-3000个。

@rampageX
Copy link

rampageX commented Apr 3, 2016

这么有规律就定时重启 redsocks 呗,几秒钟。

@yanggis
Copy link
Author

yanggis commented Apr 3, 2016

@rampageX 这个显然是个笨办法啊,我同时在线有1000-2000人,redsocks重启的话,这一两千人网络连接就会全部断掉,必须重连,一天这样搞几次,我这服务器就不用要了,人都跑完了……

@semigodking
Copy link
Owner

你用的是trunk上最新版吗?

@yanggis
Copy link
Author

yanggis commented Apr 3, 2016

@semigodking 感谢回复。我是用的十几天前你发布的那个最新版。最初十多天一直没有问题,这两天周末加上放假,用的人一下增加很多,就出现这个问题了。

@semigodking
Copy link
Owner

这个问题我一下子也是想不出原因。给你个建议,也许可避免这个问题:
用两个redsocks2进程,分别使用不同的配置文件,分别处理80和443 端口。这样流量可分布到两个进程,也许就消没什么事了。
2016年4月3日 下午9:15,"X.K. YANG" [email protected]写道:

@semigodking https://github.com/semigodking
感谢回复。我是用的十几天前你发布的那个最新版。最初十多天一直没有问题,这两天周末加上放假,用的人一下增加很多,就出现这个问题了。


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#39 (comment)

@semigodking
Copy link
Owner

这样有个附加的好处:可以利用多核心并发能力加强。
2016年4月3日 下午9:35,"Semigod King" [email protected]写道:

这个问题我一下子也是想不出原因。给你个建议,也许可避免这个问题:
用两个redsocks2进程,分别使用不同的配置文件,分别处理80和443 端口。这样流量可分布到两个进程,也许就消没什么事了。
2016年4月3日 下午9:15,"X.K. YANG" [email protected]写道:

@semigodking https://github.com/semigodking
感谢回复。我是用的十几天前你发布的那个最新版。最初十多天一直没有问题,这两天周末加上放假,用的人一下增加很多,就出现这个问题了。


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#39 (comment)

@yanggis
Copy link
Author

yanggis commented Apr 3, 2016

@semigodking 您这个建议很好,我要好好试一下。非常感谢。如果有新的发现,我再来汇报。再次感谢。

@semigodking
Copy link
Owner

即使是同一80端口,也可以利用iptables根据一定的规则劈开成几份。根据你CPU核心数决定redsocks2的进程数,并可设置进程对核心的affinity。
请在编译时带上调试信息,并在下次再出现问题时,用gdb attach 上去收backtrace 等信息。如果能做core dump发过来更好。
2016年4月3日 21:53,"X.K. YANG" [email protected]写道:

@semigodking https://github.com/semigodking
您这个建议很好,我要好好试一下。非常感谢。如果有新的发现,我再来汇报。再次感谢。


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#39 (comment)

@yanggis
Copy link
Author

yanggis commented Apr 3, 2016

@semigodking 非常感谢您的建议,等我先研究一下您说的该怎么实现,然后再向您请教。非常感谢您的建议。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants