准备工作:
JDK1.8 : http://www.oracle.com/technetwork/java/javase/downloads/index.html
Tomcat8 : http://tomcat.apache.org/
Solr6.6.1 : http://lucene.apache.org/solr/
部署:
1. 首先把solr-6.6.1\server\solr-webapp中的webapp目录拷贝到apache-tomcat-8.0.33下的webapps目录里,重命名为solr;
2. 将solr-6.6.1\server\lib\ext下的所有jar包,以及solr-6.6.1\server\lib下以metrics开头的jar包复制到apache-tomcat-8.0.33\webapps\solr\WEB-INF\lib下;
3. 在apache-tomcat-8.0.33\webapps\webapp\WEB-INF中,新建classes文件夹,将solr-6.6.1\server\resources下的log4j.properties文件拷贝到里面
4.创建新的数据文件夹(注意斜杠和反斜杠),创建后的文件在solr-6.6.1\server\solr下:
A.首先在solr-6.6.1目录运行命令启动solr:
Linux: $ bin/solr start;
windows: bin\solr.cmd start
B.创建mycore文件夹:
Linux: $ bin/solr create -c mycore
Windows: bin\solr.cmd create -c mycore
C.然后将solr-6.6.1\server中的solr目录拷贝到E盘,重命名为solrhome
5.配置lib标签
打开solrhome/mycore/conf文件夹下的solrconfig.xml,从中找到如下代码形式并修改为“${solr.install.dir:..}”:
<lib dir="${solr.install.dir:..}/contrib/extraction/lib" regex=".*\.jar" />
<lib dir="${solr.install.dir:..}/dist/" regex="solr-cell-\d.*\.jar" />
<lib dir="${solr.install.dir:..}/contrib/clustering/lib/" regex=".*\.jar" />
<lib dir="${solr.install.dir:..}/dist/" regex="solr-clustering-\d.*\.jar" />
<lib dir="${solr.install.dir:..}/contrib/langid/lib/" regex=".*\.jar" />
<lib dir="${solr.install.dir:..}/dist/" regex="solr-langid-\d.*\.jar" />
<lib dir="${solr.install.dir:..}/contrib/ltr/lib/" regex=".*\.jar" />
<lib dir="${solr.install.dir:..}/dist/" regex="solr-ltr-\d.*\.jar" />
<lib dir="${solr.install.dir:..}/contrib/velocity/lib" regex=".*\.jar" />
<lib dir="${solr.install.dir:..}/dist/" regex="solr-velocity-\d.*\.jar" />
6. 修改apache-tomcat-8.0.33\webapps\solr\WEB-INF中的web.xml文件:
打开如下注释,修改为solrhome路径
```
<env-entry>
<env-entry-name>solr/home</env-entry-name>
<env-entry-value>E:/solrhome</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
```
并注释掉如下代码
```
<!-- <security-constraint>
<web-resource-collection>
<web-resource-name>Disable TRACE</web-resource-name>
<url-pattern>/</url-pattern>
<http-method>TRACE</http-method>
</web-resource-collection>
<auth-constraint/>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Enable everything but TRACE</web-resource-name>
<url-pattern>/</url-pattern>
<http-method-omission>TRACE</http-method-omission>
</web-resource-collection>
</security-constraint>-->
7. 启动tomcat,访问http://localhost:8080/solr/index.html