Debug solr

Recently I was puzzled by some behavior Solr was showing me. I scratched my head and called over a colleague. We couldn’t quite figure out what was going on. Well Solr is open source so… next stop – Debuggersville! Running Solr in the Eclipse debugger isn’t hard, but there are many scattered user group posts and blog articles that you’ll need to manually tie together into a coherent picture. So let me do you the favor of tying all of that info together for you here. First step is of course to [grab the source code][1] for the version of Solr you want to debug. Unpack this somewhere, and browse to the top directory. Let’s get comfortable with the directory structure. Most importantly, I want to point out these three pieces: * build.xml – top level Solr/Lucene ant build.xml file * lucene/ — directory containing Lucene’s source * solr/ — directory containing Solr’s source The takeaway here is that it’s important to note that Solr and Lucene are deployed together. This has a lot of conveniences, but is a bit confusing. We think we just downloaded Solr, but really we have Solr and Lucene bundled together. To help keep things clear, I’m going to call the whole shebang we just downloaded the **Solr/Lucene** source tree and I’ll call the `solr/` subdirectory the Solr source tree.

My Solr/Lucene Source Tree

OK enough nonsense, let’s get started. Browse to the top-level Solr/Lucene source tree in your command line and let’s bootstrap the Solr/Lucene Eclipse project.

~/workspace/solr-4.2.1$ ant eclipse

Once this completes, load up Eclipse, and select File -> Import. Select Existing Eclipse Project from the dialog and browse to the top of your Solr/Lucene source tree. Once this directory is selected, click “Finish”. Now you have an Eclipse project with both Solr and Lucene.

Import Solr/Lucene Into Eclipse

Now back to the command prompt, we’ll go into the Solr source tree and build the example/ directory that holds the Solr/Jetty web application. The same example/ directory distributed with Solr`s binaries.

~/workspace/solr-4.2.1$ cd solr/ ~/workspace/solr-4.2.1/solr$ ant example

Once the example app has been built, we can cd into the example directory, and use start.jar in the same way we would with the binary distribution of Solr. We can still include the usual solr arguments for items such as changing solr.home, etc. The only difference here is we’re going add Java arguments needed for debugging.

~/workspace/solr-4.2.1/solr$ cd example ~/workspace/solr-4.2.1/solr/example$ java -jar -Xdebug \      -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=1044 \      start.jar

Because we set suspend=y, Java is waiting for us to attach our debugger before beginning execution. Switch back to Eclipse. Right click on your Solr/Lucene Java project and select Debug As and then Debug Configurations. Under theRemote Java Application category. Click New to create a new debug configuration. Enter in the port we just specified to Java at the command line — 1044. Hit Apply and Debug. Over in the command line you should see Solr starting up.

Debug Config For Attaching to Example Web App

Huzzah! You’ve done it! You should now be able to set breakpoints throughout the Solr/Lucene code base, step through code, and do all the other fun stuff you can do with any other hunk of source code. In the future, you can simply recall this debug configuration in the “Debug As” menu and Eclipse will attempt to attach to any Solr instance launched with Java’s debug commands. Have fun hacking on Solr!

时间: 2024-07-29 02:52:17

Debug solr的相关文章

Solr使用入门指南

本文转自http://chuanliang2007.spaces.live.com/blog/cns!E5B7AB2851A4C9D2!499.entry?wa=wsignin1.0 由于搜索引擎功能在门户社区中对提高用户体验有着重在门户社区中涉及大量需要搜索引擎的功能需求,目前在实现搜索引擎的方案上有集中方案可供选择: 1. 基于Lucene自己进行封装实现站内搜索.工作量及扩展性都较大,不采用. 2. 调用Google.Baidu的API实现站内搜索.同第三方搜索引擎绑定太死,无法满足后期业

[转载] Solr使用入门指南

转载自http://blog.csdn.net/liuzhenwen/article/details/4060922 由于搜索引擎功能在门户社区中对提高用户体验有着重要的作用,在门户社区中涉及大量需要搜索引擎的功能需求,目前在实现搜索引擎的方案上有几种方案可供选择: 1. 基于Lucene自己进行封装实现站内搜索.工作量及扩展性都较大,不采用. 2. 调用Google.Baidu的API实现站内搜索.同第三方搜索引擎绑定太死,无法满足后期业务扩展需要,暂时不采用. 3. 基于Compass+Lu

Solr开发文档

Solr 是一种可供企业使用的.基于 Lucene 的搜索服务器,它支持层面搜索.命中醒目显示和多种输出格式.在这篇文章中,将介绍 Solr 并展示如何轻松地将其表现优异的全文本搜索功能加入到 Web 应用程序中. 开发环境: System:Windows WebBrowser:IE6+.Firefox3+ JDK:1.6+ JavaEE Server:tomcat5.0.2.8.tomcat6 IDE:eclipse.MyEclipse 8 开发依赖库: JavaEE 5.solr 3.4 个

solr入门教程

Solr 本文介绍solr的功能使用及相关注意事项;主要包括以下内容:环境搭建及调试;两个核心配置文件介绍;维护索引;查询索引,和在查询中可以应用的高亮显示.拼写检查.搜索建议.分组统计.拼音检索等功能的使用方法. 1. Solr 是什么? Solr它是一种开放源码的.基于 Lucene Java 的搜索服务器,易于加入到 Web 应用程序中.Solr 提供了层面搜索(就是统计).命中醒目显示并且支持多种输出格式(包括XML/XSLT 和JSON等格式).它易于安装和配置,而且附带了一个基于HT

Solr4.8.0源码分析(4)之Eclipse Solr调试环境搭建

Solr4.8.0源码分析(4)之Eclipse Solr调试环境搭建 由于公司里的Solr调试都是用远程jpda进行的,但是家里只有一台电脑所以不能jpda进行调试,这是因为jpda的端口冲突.所以只能在Eclipse 搭建Solr的环境,折腾了一小时终于完成了. 1. JDPA远程调试 搭建换完成Solr环境后,对${TOMCAT_HOME}/bin/startup.sh 最后一行进行修改,如下所示: 1 set JPDA_ADDRESS=7070 2 exec "$PRGDIR"

solr学习

当 Solr 在 Tomcat 服务器上部署成功后,我们可以登录 Solr 网页版的管理界面进行基本的操作. 一.首先来了解一下 Solr 页面各个功能模块的基本功能是什么?这里主要包括 Dashboard(仪表盘).Logging(日志). Core Admin(索引库管理). JavaProperties(Java 属性). Thread Dump(线程管道). Core Selector(Core 选择器)几部分组成,接下来将一一介绍. 二.Dashboard(仪表盘):包含 solr 搭

solr 集群(SolrCloud 分布式集群部署步骤)

SolrCloud 分布式集群部署步骤 安装软件包准备 apache-tomcat-7.0.54 jdk1.7 solr-4.8.1 zookeeper-3.4.5 注:以上软件都是基于 Linux 环境的 64位 软件,以上软件请到各自的官网下载. 服务器准备 为搭建这个集群,准备三台服务器,分别为 192.168.0.2 -- master 角色192.168.0.3 -- slave 角色192.168.0.4 -- slave 角色 搭建基础环境 安装 jdk1.7 - 这个大家都会安装

solr单机部署tomcat

所需软件:solr4.8.1.Tomcat7 下载完相应软件后开始单机部署(windows下) 在F盘根目录创建solr文件夹,并解压solr4.8和tomcat7到该文件夹 在F盘根目录创建solrhome文件夹,将F:\solr\solr-4.8.1\example\solr下的所有文件复制到solrhome文件夹中 将F:\solr\solr-4.8.1\dist下的solr-4.8.1.war复制到tomcat7的webapps下并更名为solr.war 在F:\solr\apache-

solr源码分析之solrclound

一.简介 SolrCloud是Solr4.0版本以后基于Solr和Zookeeper的分布式搜索方案.SolrCloud是Solr的基于Zookeeper一种部署方式.Solr可以以多种方式部署,例如单机方式,多机Master-Slaver方式. 二.特色功能 SolrCloud有几个特色功能: 集中式的配置信息使用ZK进行集中配置.启动时可以指定把Solr的相关配置文件上传Zookeeper,多机器共用.这些ZK中的配置不会再拿到本地缓存,Solr直接读取ZK中的配置信息.配置文件的变动,所有