论坛首页 综合技术论坛

solr日志的关闭

浏览 10735 次
精华帖 (0) :: 良好帖 (1) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2011-09-09  
solr访问量增大时,日志实在是多,1天的日志就是3G,而且基本没什么用,于是想着怎么关闭它。

solr使用jdk自带的logging输出,jvm启动时通过设置-Djava.util.logging.config.file可以指定日志的配置文件。这里以tomcat容器为例,tomcat启动时会设置:
-Djava.util.logging.config.file=tomcat/conf/logging.properties

我们在logging.properties添加以下的内容:
org.apache.solr.level = WARNING

重启tomcat之后,info的日志就不会输出了。

如果想使用log4j来替换jdk的logging,可参考:
http://blog.chenlb.com/2010/08/solr-with-log4j.html
   发表时间:2011-09-14  
LZ 我请想请教下,我前端搜索应用访问solr服务器经常有soket time out,而且solr服务器的watch-dog会在一段soket time out后自动重启resin,重启后就会好上几个小时。日志中不报其他错误,服务已经上线了,才出现这种问题,并发很低。

solr配置如下
private static final int SO_TIME_OUT = 10001;
	private static final int CONNECTION_TIME_OUT = 10001;
	private static final int DEFAULT_MAX_CONNECTION_PER_HOST = 500;
	private static final int MAX_TOTAL_CONNECTIONS =500 ;
	private static final int DEFAULT_PAGE_SIZE = 20;
	private static final int DEFAULT_CURRENT_PAGE = 1;

solrServer = new CommonsHttpSolrServer(solrServerUrl);
		solrServer.setParser(new XMLResponseParser());
		solrServer.setSoTimeout(SO_TIME_OUT);
		solrServer.setConnectionTimeout(CONNECTION_TIME_OUT);
		solrServer.setDefaultMaxConnectionsPerHost(DEFAULT_MAX_CONNECTION_PER_HOST);
		solrServer.setMaxTotalConnections(MAX_TOTAL_CONNECTIONS);
		solrServer.setFollowRedirects(false);
		solrServer.setAllowCompression(true);
		solrServer.setMaxRetries(1);



resin配置
accept-thread-min 5 keepalive-max 128
accept-thread-max 10 keepalive-select-max -1
accept-listen-backlog 100 keepalive-timeout 15000
connection-max 1048576 socket-timeout 65000
keepalive-connection-time-max 600000 suspend-time-max 600000


错误日志
[2011-09-14 15:39:02.802]Caused by: java.net.SocketTimeoutException: Read timed out
[2011-09-14 15:39:02.802]       at java.net.SocketInputStream.socketRead0(Native Method)
[2011-09-14 15:39:02.802]       at java.net.SocketInputStream.read(SocketInputStream.java:129)
[2011-09-14 15:39:02.802]       at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
[2011-09-14 15:39:02.802]       at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
[2011-09-14 15:39:02.802]       at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
[2011-09-14 15:39:02.802]       at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
[2011-09-14 15:39:02.802]       at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)
[2011-09-14 15:39:02.802]       at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1413)
[2011-09-14 15:39:02.802]       at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)
[2011-09-14 15:39:02.802]       at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
[2011-09-14 15:39:02.802]       at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
[2011-09-14 15:39:02.802]       at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
[2011-09-14 15:39:02.802]       at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
[2011-09-14 15:39:02.802]       at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
[2011-09-14 15:39:02.802]       at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
[2011-09-14 15:39:02.802]       at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:428)

0 请登录后投票
   发表时间:2011-09-15  
Read timed out异常出现的原因一般有2个:
1.请求太多,服务器接受不了这么多的请求
2.服务器处理太慢,超过了client设置的超时时间

你说的“并发很低”,具体是多少?建议你开启jmx,然后用jconsole监视一下jvm的活动线程数是多少。如果被限制在了10-20之间,可能就是这个原因了:
accept-thread-max 10

我没用过resin,参考了一个链接:http://hi.baidu.com/mygia/blog/item/329ed813b24a0d065baf53f0.html
里边设置的accept-thread-max都是一个比较大的值,类似于tomcat中的maxThreads。这个值决定了服务器能处理多少进程。我建议调整这个值(比如200)在测试机压力测试一下,应该没什么问题。

之前上线系统就遇到了因为maxThreads调的太低造成的问题。当时设置为500,查询到jvm的活动线程数已经到了560,然后tomcat挂了。后来调整到1000,并发800线程相安无事。
0 请登录后投票
论坛首页 综合技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics