Solr with Apache Tomcat
Solr runs fine with [WWW] Tomcat, see the instructions in the generic Solr installation page for general info before consulting this page.
1. Solr with Apache Tomcat
1. Simple Example Install
2. Optional Configuration
1. Logging
2. URI Charset Config
3. Configuring Solr Home with JNDI
3. Multiple Solr Webapps
4. Tomcat on Windows
1. Single Solr app
2. Multiple Solr apps
Simple Example Install
People have occasionally reported problems getting Solr to work with Tomcat -- usually as a result of confusion stemming from the multitudes of ways tomcat can be installed and configured (particularly if tomcat is installed by some package management system designed for the specific OS).
These steps illustrate the minimal possible steps needed to install both Tomcat and Solr from scratch by relying on the default "Solr Home Dir" ...
#if you copy this to a shell script, make sure to run dos2unix on it to ensure correct line-endings
mkdir solr-tomcat
cd solr-tomcat/
wget http://mirrors.ibiblio.org/pub/mirrors/apache/tomcat/tomcat-5/v5.5.25/bin/apache-tomcat-5.5.25.zip
NIGHTLY=solr-`/bin/date +%F`
wget http://people.apache.org/builds/lucene/solr/nightly/$NIGHTLY.zip
unzip apache-tomcat-5.5.25.zip
unzip $NIGHTLY.zip
cp apache-solr-nightly/dist/apache-solr-nightly.war apache-tomcat-5.5.25/webapps/solr.war
cp -r apache-solr-nightly/example/solr .
chmod a+x apache-tomcat-5.5.25/bin/*
./apache-tomcat-5.5.25/bin/startup.sh
echo "Now browse to http://localhost:8080/solr/admin/"
#Note that the startup.sh script is run from the directory containing your solr home ./solr
#since the solr webapp looks for $CWD/solr by default.
#You can use JNDI or a System property to configure the solr home directory (described below)
#If you want to run the startup.sh from a different working directory.
In addition to using the default behavior of relying on the Solr Home being in the current working directory (./solr) you can alternately add the solr.solr.home system property to your JVM settings before starting Tomcat...
export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/my/custom/solr/home/dir/"
...or use a Context file to configure the Solr Home using JNDI (see below)
Optional Configuration
Logging
For information about controlling JDK Logging (aka: java.util logging) in Tomcat, please consult the Tomcat docs... [WWW] http://tomcat.apache.org/tomcat-6.0-doc/logging.html
URI Charset Config
If you are going to query Solr using international characters (>127) using HTTP-GET, you must configure Tomcat to conform to the URI standard by accepting percent-encoded UTF-8.
Edit Tomcat's conf/server.xml and add the following attribute to the correct Connector element: URIEncoding="UTF-8".
<Server ...>
<Service ...>
<Connector ... URIEncoding="UTF-8"/>
...
</Connector>
</Service>
</Server>
This is only an issue when sending non-ascii characters in a query request... no configuration is needed for Solr/Tomcat to return non-ascii chars in a response, or accept non-ascii chars in an HTTP-POST body.
Configuring Solr Home with JNDI
A Tomcat context fragments can be used to configure the JNDI property needed to specify your Solr Home directory.
Just put a context fragment file under $CATALINA_HOME/conf/Catalina/localhost that looks something like this...
$ cat /tomcat55/conf/Catalina/localhost/solr.xml
<Context docBase="/some/path/solr.war" debug="0" crossContext="true" >
<Environment name="solr/home" type="java.lang.String" value="/my/solr/home" override="true" />
</Context>
A few things to keep in mind:
*
The "conf/Catalina/localhost" directory may not exist by default in your installation. You may have to create it.
*
"/some/path/solr.war" is the absolute path to where ever you want to keep the Solr war using the appropriate syntax for your Operating System. In Tomcat 5.5 and later, the war file must be stored outside of the webapps directory for this to work. Otherwise, this entire Context element is ignored.
*
"/my/solr/home" should be to where you have createed your Solr Home directory, using the appropriate syntax for your Operating System.
*
Prior to Tomcat 5.5, a "path" attribute was required for Context elements (starting with 5.5, the path attribute must not be used except when statically defining a Context in server.xml, as it will be inferred from the Context fragment filename.
Multiple Solr Webapps
Tomcat context fragments make configuring multiple Solr webapps (with JNDI) in a single Tomcat server easy.
Just follow the previous instructions for "Configuring Solr Home with JNDI" to create a seperate context fragment file under $CATALINA_HOME/conf/Catalina/localhost for each solr webapp you want to run:
$ cat /tomcat55/conf/Catalina/localhost/solr1.xml
<Context docBase="/some/path/solr.war" debug="0" crossContext="true" >
<Environment name="solr/home" type="java.lang.String" value="/some/path/solr1home" override="true" />
</Context>
$ cat /tomcat55/conf/Catalina/localhost/solr2.xml
<Context docBase="f:/solr.war" debug="0" crossContext="true" >
<Environment name="solr/home" type="java.lang.String" value="/some/path/solr2home" override="true" />
</Context>
Don't put anything related to Solr under the webapps directory.
The solr home directories are configured via JNDI in the context fragment, and in the examples above will be /some/path/solr1home and /some/path/solr2home The URLs to the two webapps will be http://host:port/solr1 and http://host:port/solr2
Tomcat on Windows
Single Solr app
*
Download and install [WWW] Tomcat for Windows using the MSI installer. Install it with the tcnative.dll file. Say you installed it in c:\tomcat\
*
Check if Tomcat is installed correctly by going to [WWW] http://localhost:8080/
*
Change the c:\tomcat\conf\server.xml file to add the URIEncoding Connector element as shown above.
*
Download and unzip the Solr distribution zip file into (say) c:\temp\solrZip\
*
Make a directory called solr where you intend the application server to function, say c:\web\solr\
*
Copy the contents of the example\solr directory c:\temp\solrZip\example\solr\ to c:\web\solr\
*
Stop the Tomcat service
*
Copy the *solr*.war file from c:\temp\solrZip\dist\ to the Tomcat webapps directory c:\tomcat\webapps\
*
Rename the *solr*.war file solr.war
*
Use the system tray icon to configure Tomcat to start with the following Java option: -Dsolr.solr.home=c:\web\solr
*
Start the Tomcat service
*
Go to the solr admin page to verify that the installation is working. It will be at [WWW] http://localhost:8080/solr/admin
Multiple Solr apps
*
Download and install [WWW] Tomcat for Windows using the MSI installer. Install it with the tcnative.dll file. Say you installed it in c:\tomcat\
*
Check if Tomcat is installed correctly by going to [WWW] http://localhost:8080/
*
Change the c:\tomcat\conf\server.xml file to add the URIEncoding Connector element as shown above.
*
Download and unzip the Solr distribution zip file into (say) c:\temp\solrZip\
*
Say you need two apps in c:\web\solr1 and c:\web\solr2; create these two directories
*
Copy the contents of the example\solr directory c:\temp\solrZip\example\solr\ to c:\web\solr1\ and to c:\web\solr2\
*
Stop the Tomcat service
*
Copy the *solr*.war file from c:\temp\solrZip\dist\ to the Tomcat lib directory c:\tomcat\lib\
*
Rename the *solr*.war file solr.war
*
Make a new text file in c:\tomcat\conf\Catalina\localhost called solr1.xml with the following code fragment
<Context docBase="c:\tomcat\lib\solr.war" debug="0" crossContext="true" >
<Environment name="solr/home" type="java.lang.String" value="c:\web\solr1" override="true" />
</Context>
*
Make a new text file in c:\tomcat\conf\Catalina\localhost called solr2.xml with the following code fragment
<Context docBase="c:\tomcat\lib\solr.war" debug="0" crossContext="true" >
<Environment name="solr/home" type="java.lang.String" value="c:\web\solr2" override="true" />
</Context>
*
Start the Tomcat service
*
Go to the solr admin pages for the 2 webapps to verify that the installation is working. It will be at [WWW] http://localhost:8080/solr1/admin and [WWW] http://localhost:8080/solr2/admin
分享到:
相关推荐
### Solr 4.10.2 与 Tomcat 6 的整合详解 #### 一、Solr 与 Tomcat 整合概述 Solr 是一个高性能、采用 Java 开发的全文搜索引擎,常用于网站搜索功能的搭建。而 Apache Tomcat 是一个免费开源的 Servlet 容器,...
1. **下载和解压**:首先,你需要从 Apache 官方网站下载 Solr 3.5 的压缩包,然后将其解压到一个合适的目录。解压后,你会看到一个名为 `solr` 的文件夹,其中包含 Solr 的核心组件。 2. **配置 Tomcat**:打开你...
在本场景中,我们关注的是将 Solr 集成到 Tomcat 服务器上,以便利用其强大的搜索能力。Tomcat 是一个流行的开源 Java 应用服务器,常用于部署 Web 应用程序。下面我们将详细介绍如何配置已集成 Solr 的 Tomcat ...
- 在整合Solr 4.9和Tomcat 8.0时,你需要在Tomcat的`webapps`目录下放置`solr.war`文件。 - 启动Tomcat服务器,这会自动解压`solr.war`,生成一个名为`solr`的目录。 - 创建一个新的`solr`文件夹作为Solr的home...
### Solr 3.5 与 Tomcat 6 集成及自定义分词器配置详解 #### 一、Solr与Tomcat集成概述 Solr 是一个高性能、采用 Java 开发的企业级搜索服务器,它基于 Lucene 库提供了一个完整的全文检索框架。而 Tomcat 是一个...
1. **下载与解压**:首先,你需要下载Apache Solr 4.7.2和Tomcat7的安装包。在提供的压缩包中,包含了已经集成好的版本,可以直接解压使用。 2. **配置Solr Home**:在解压后的目录中,找到`solr_home`目录,这是...
solr5.5.4.war&tomcat8.5.20,solr环境已经配置好。直接启动Tomcat即可使用,使用的java环境是1.8的版本,低版本没测试过。solrHhome配置在Tomcat目录下,solr日志配置在Tomcat日志目录下。
标题“solr与tomcat整合”涉及的是将Apache Solr搜索引擎集成到Apache Tomcat应用服务器的过程。Solr是一款基于Lucene的开源搜索平台,而Tomcat是Java Servlet和JavaServer Pages的容器。整合这两者可以方便地在Web...
### Solr 3.5与Tomcat的部署配置及与Java项目的集成 #### 一、Solr 3.5与Tomcat的部署配置 **1. 下载与安装Solr** 首先,需要从官方或其他可信任来源下载Apache Solr 3.5.0。根据描述中的链接(虽然不可用),...
在这个场景中,我们将Solr作为一个Web应用程序部署在Tomcat 8.5.45上,这是Apache Tomcat的一个稳定版本,它支持Java EE 8规范。 首先,安装Java开发工具(Java Development Kit,JDK)是部署Solr的前提,因为两者...
在Windows 7操作系统中安装Apache Solr 4.4并将其部署到Tomcat 8是一项重要的配置工作,这对于搭建基于Solr的全文检索系统至关重要。下面将详细解释这个过程涉及的关键知识点。 首先,我们需要安装Java Development...
- **Apache Tomcat**: 7.0(尽管描述中提到的是 Tomcat 8.0,但根据部分内容显示的是 Tomcat 7.0) ### 步骤详解 #### 第一步:部署 Solr Web 应用到 Tomcat 1. **复制 Solr Web App**: 打开 `solr-6.6.2/server/...
标题中的“tomcat下部署solr”意味着我们将讨论如何在Apache Tomcat服务器上安装和配置Apache Solr,这是一个流行的开源搜索引擎。Solr使得在大量数据中进行全文搜索、近似搜索、拼写检查以及多种其他高级功能变得...
Solr是Apache Lucene项目的一个子项目,是一个高性能、全文本搜索服务器,广泛应用于各种大数据检索场景。在4.9版本中,Solr引入了集群功能,以支持高可用性和可扩展性。在这个集群环境中,Tomcat作为Servlet容器...
Tomcat9是Apache的Java Servlet容器,用于部署和运行Web应用程序。首先,需要下载并安装Tomcat9,配置环境变量,确保JDK也已安装并设置好JAVA_HOME。接着,将Solr的war文件放入Tomcat的webapps目录下,启动Tomcat后...
### Solr 在 Tomcat 下的搭建与配置数据库详解 #### 一、Solr 在 Tomcat 下的搭建步骤 **步骤1:准备Solr环境** - 首先确保已安装了Tomcat服务器以及Solr软件。 - 假设`SOLR_HOME`设置为`E:\software\apache-solr...
Solr+Tomcat项目整合是将Apache Solr搜索引擎与Apache Tomcat应用服务器结合使用的过程,以便在Web环境中部署和运行Solr服务。Solr是一个基于Lucene的全文搜索服务器,而Tomcat则是一个轻量级Java应用服务器,常用于...
### Solr 4.7 在 Tomcat 6 中部署详细步骤及知识点解析 #### 一、Solr 和 Tomcat 简介 - **Solr**:Apache Solr 是一个高性能、采用 Java 开发的全文搜索引擎。它基于 Lucene 库,支持高度可扩展性而不牺牲性能,...