CentOS 6.6上安装与配置Solr 6.5(2)

[root@localhost down]# cd /down 
[root@localhost down]# cp -R /down/solr-6.5.0/server/solr-webapp/webapp /down/apache-tomcat-8.5.12/webapps/solr 
[root@localhost down]# cp -R /down/solr-6.5.0/server/lib/ext/*  /down/apache-tomcat-8.5.12/webapps/solr/WEB-INF/lib/ 
[root@localhost down]# cp -R /down/solr-6.5.0/server/lib/metrics*.*  /down/apache-tomcat-8.5.12/webapps/solr/WEB-INF/lib/ 
[root@localhost down]# cp /down/solr-6.5.0/dist/solr-dataimporthandler-*  /down/apache-tomcat-8.5.12/webapps/solr/WEB-INF/lib/ 
[root@localhost down]# mkdir /down/apache-tomcat-8.5.12/webapps/solr/WEB-INF/classes 
[root@localhost down]# cp /down/solr-6.5.0/server/resources/log4j.properties  /down/apache-tomcat-8.5.12/webapps/solr/WEB-INF/classes/ 
[root@localhost down]# mkdir /down/apache-tomcat-8.5.12/solrhome 
[root@localhost down]# cp -R /down/solr-6.5.0/server/solr/*  /down/apache-tomcat-8.5.12/solrhome/ 

[root@localhost down]# cd /down [root@localhost down]# cp -R /down/solr-6.5.0/server/solr-webapp/webapp /down/apache-tomcat-8.5.12/webapps/solr [root@localhost down]# cp -R /down/solr-6.5.0/server/lib/ext/* /down/apache-tomcat-8.5.12/webapps/solr/WEB-INF/lib/ [root@localhost down]# cp -R /down/solr-6.5.0/server/lib/metrics*.* /down/apache-tomcat-8.5.12/webapps/solr/WEB-INF/lib/ [root@localhost down]# cp /down/solr-6.5.0/dist/solr-dataimporthandler-* /down/apache-tomcat-8.5.12/webapps/solr/WEB-INF/lib/ [root@localhost down]# mkdir /down/apache-tomcat-8.5.12/webapps/solr/WEB-INF/classes [root@localhost down]# cp /down/solr-6.5.0/server/resources/log4j.properties /down/apache-tomcat-8.5.12/webapps/solr/WEB-INF/classes/ [root@localhost down]# mkdir /down/apache-tomcat-8.5.12/solrhome [root@localhost down]# cp -R /down/solr-6.5.0/server/solr/* /down/apache-tomcat-8.5.12/solrhome/

3、配置Solr:

编辑web.xml文件:

[root@localhost down]# vi /down/apache-tomcat-8.5.12/webapps/solr/WEB-INF/web.xml   

[root@localhost down]# vi /down/apache-tomcat-8.5.12/webapps/solr/WEB-INF/web.xml

1)配置solr下core路径,找如下配置内容(初始状态下该内容是被注释掉的):

<env-entry> 
  <env-entry-name>solr/home</env-entry-name> 
  <env-entry-value>/down/apache-tomcat-8.5.12/solrhome</env-entry-value> //将路径指向我们创建的solrhome目录。 
  <env-entry-type>java.lang.String</env-entry-type> 
</env-entry> 

<env-entry> <env-entry-name>solr/home</env-entry-name> <env-entry-value>/down/apache-tomcat-8.5.12/solrhome</env-entry-value> //将路径指向我们创建的solrhome目录。 <env-entry-type>java.lang.String</env-entry-type> </env-entry>

2)配置访问权限:找到如下内容,并注释掉:

<!-- 
  <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> 
--> 

<!-- <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> -->

整个web.xml的配置文件内容如下:

<?xml version="1.0" encoding="UTF-8"?> 
<!-- 
 Licensed to the Apache Software Foundation (ASF) under one or more 
 contributor license agreements.  See the NOTICE file distributed with 
 this work for additional information regarding copyright ownership. 
 The ASF licenses this file to You under the Apache License, Version 2.0 
 (the "License"); you may not use this file except in compliance with 
 the License.  You may obtain a copy of the License at 
 
     
 
 Unless required by applicable law or agreed to in writing, software 
 distributed under the License is distributed on an "AS IS" BASIS, 
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 See the License for the specific language governing permissions and 
 limitations under the License. 
--> 
<web-app xmlns="http://java.sun.com/xml/ns/javaee" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee " 
        version="2.5" 
        metadata-complete="true" 

 
 
  <!-- Uncomment if you are trying to use a Resin version before 3.0.19. 
    Their XML implementation isn't entirely compatible with Xerces. 
    Below are the implementations to use with Sun's JVM. 
  <system-property javax.xml.xpath.XPathFactory= 
            "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl"/> 
  <system-property javax.xml.parsers.DocumentBuilderFactory= 
            "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"/> 
  <system-property javax.xml.parsers.SAXParserFactory= 
            "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"/> 
  --> 
 
  <!-- People who want to hardcode their "Solr Home" directly into the 
      WAR File can set the JNDI property here... 
  --> 
    <env-entry> 
      <env-entry-name>solr/home</env-entry-name> 
      <env-entry-value>/down/apache-tomcat-8.5.12/solrhome</env-entry-value> 
      <env-entry-type>java.lang.String</env-entry-type> 
    </env-entry> 
   
  <!-- Any path (name) registered in solrconfig.xml will be sent to that filter --> 
  <filter> 
    <filter-name>SolrRequestFilter</filter-name> 
    <filter-class>org.apache.solr.servlet.SolrDispatchFilter</filter-class> 
    <!-- 
    Exclude patterns is a list of directories that would be short circuited by the 
    SolrDispatchFilter. It includes all Admin UI related static content. 
    NOTE: It is NOT a pattern but only matches the start of the HTTP ServletPath. 
    --> 
    <init-param> 
      <param-name>excludePatterns</param-name> 
      <param-value>/libs/.+,/css/.+,/js/.+,/img/.+,/tpl/.+</param-value> 
    </init-param> 
  </filter> 
 
  <filter-mapping> 
    <!-- 
      NOTE: When using multicore, /admin JSP URLs with a core specified 
      such as /solr/coreName/admin/stats.jsp get forwarded by a 
      RequestDispatcher to /solr/admin/stats.jsp with the specified core 
      put into request scope keyed as "org.apache.solr.SolrCore". 
 
      It is unnecessary, and potentially problematic, to have the SolrDispatchFilter 
      configured to also filter on forwards.  Do not configure 
      this dispatcher as <dispatcher>FORWARD</dispatcher>. 
    --> 
    <filter-name>SolrRequestFilter</filter-name> 
    <url-pattern>/*</url-pattern> 
  </filter-mapping> 
 
  <servlet> 
    <servlet-name>LoadAdminUI</servlet-name> 
    <servlet-class>org.apache.solr.servlet.LoadAdminUiServlet</servlet-class> 
  </servlet> 
   
  <!-- Remove in Solr 5.0 --> 
  <!-- This sends SC_MOVED_PERMANENTLY (301) for resources that changed in 4.0 --> 
  <servlet> 
    <servlet-name>RedirectOldAdminUI</servlet-name> 
    <servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class> 
    <init-param> 
      <param-name>destination</param-name> 
      <param-value>${context}/#/</param-value> 
    </init-param> 
  </servlet> 
   
  <servlet> 
    <servlet-name>RedirectOldZookeeper</servlet-name> 
    <servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class> 
    <init-param> 
      <param-name>destination</param-name> 
      <param-value>${context}/admin/zookeeper</param-value> 
    </init-param> 
  </servlet> 
 
  <servlet> 
    <servlet-name>RedirectLogging</servlet-name> 
    <servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class> 
    <init-param> 
      <param-name>destination</param-name> 
      <param-value>${context}/#/~logging</param-value> 
    </init-param> 
  </servlet> 
 
  <servlet> 
    <servlet-name>SolrRestApi</servlet-name> 
    <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class> 
    <init-param> 
      <param-name>org.restlet.application</param-name> 
      <param-value>org.apache.solr.rest.SolrSchemaRestApi</param-value> 
    </init-param> 
  </servlet> 
 
  <servlet-mapping> 
    <servlet-name>RedirectOldAdminUI</servlet-name> 
    <url-pattern>/admin/</url-pattern> 
  </servlet-mapping> 
  <servlet-mapping> 
    <servlet-name>RedirectOldAdminUI</servlet-name> 
    <url-pattern>/admin</url-pattern> 
  </servlet-mapping> 
  <servlet-mapping> 
    <servlet-name>RedirectOldZookeeper</servlet-name> 
    <url-pattern>/zookeeper.jsp</url-pattern> 
  </servlet-mapping> 
  <servlet-mapping> 
    <servlet-name>RedirectOldZookeeper</servlet-name> 
    <url-pattern>/zookeeper</url-pattern> 
  </servlet-mapping> 
  <servlet-mapping> 
    <servlet-name>RedirectLogging</servlet-name> 
    <url-pattern>/logging</url-pattern> 
  </servlet-mapping> 
 
  <servlet-mapping> 
    <servlet-name>LoadAdminUI</servlet-name> 
    <url-pattern>/old.html</url-pattern> 
  </servlet-mapping> 
 
  <servlet-mapping> 
    <servlet-name>LoadAdminUI</servlet-name> 
    <url-pattern>/index.html</url-pattern> 
  </servlet-mapping> 
 
  <servlet-mapping> 
    <servlet-name>SolrRestApi</servlet-name> 
    <url-pattern>/schema/*</url-pattern> 
  </servlet-mapping> 
   
  <mime-mapping> 
    <extension>.xsl</extension> 
    <!-- per --> 
    <mime-type>application/xslt+xml</mime-type> 
  </mime-mapping> 
 
  <welcome-file-list> 
    <welcome-file>index.html</welcome-file> 
  </welcome-file-list> 
 
  <!-- Get rid of error message --> 
  <!-- 
  <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> 
  --> 
</web-app> 

<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee " version="2.5" metadata-complete="true" > <!-- Uncomment if you are trying to use a Resin version before 3.0.19. Their XML implementation isn't entirely compatible with Xerces. Below are the implementations to use with Sun's JVM. <system-property javax.xml.xpath.XPathFactory= "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl"/> <system-property javax.xml.parsers.DocumentBuilderFactory= "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"/> <system-property javax.xml.parsers.SAXParserFactory= "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"/> --> <!-- People who want to hardcode their "Solr Home" directly into the WAR File can set the JNDI property here... --> <env-entry> <env-entry-name>solr/home</env-entry-name> <env-entry-value>/down/apache-tomcat-8.5.12/solrhome</env-entry-value> <env-entry-type>java.lang.String</env-entry-type> </env-entry> <!-- Any path (name) registered in solrconfig.xml will be sent to that filter --> <filter> <filter-name>SolrRequestFilter</filter-name> <filter-class>org.apache.solr.servlet.SolrDispatchFilter</filter-class> <!-- Exclude patterns is a list of directories that would be short circuited by the SolrDispatchFilter. It includes all Admin UI related static content. NOTE: It is NOT a pattern but only matches the start of the HTTP ServletPath. --> <init-param> <param-name>excludePatterns</param-name> <param-value>/libs/.+,/css/.+,/js/.+,/img/.+,/tpl/.+</param-value> </init-param> </filter> <filter-mapping> <!-- NOTE: When using multicore, /admin JSP URLs with a core specified such as /solr/coreName/admin/stats.jsp get forwarded by a RequestDispatcher to /solr/admin/stats.jsp with the specified core put into request scope keyed as "org.apache.solr.SolrCore". It is unnecessary, and potentially problematic, to have the SolrDispatchFilter configured to also filter on forwards. Do not configure this dispatcher as <dispatcher>FORWARD</dispatcher>. --> <filter-name>SolrRequestFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>LoadAdminUI</servlet-name> <servlet-class>org.apache.solr.servlet.LoadAdminUiServlet</servlet-class> </servlet> <!-- Remove in Solr 5.0 --> <!-- This sends SC_MOVED_PERMANENTLY (301) for resources that changed in 4.0 --> <servlet> <servlet-name>RedirectOldAdminUI</servlet-name> <servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class> <init-param> <param-name>destination</param-name> <param-value>${context}/#/</param-value> </init-param> </servlet> <servlet> <servlet-name>RedirectOldZookeeper</servlet-name> <servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class> <init-param> <param-name>destination</param-name> <param-value>${context}/admin/zookeeper</param-value> </init-param> </servlet> <servlet> <servlet-name>RedirectLogging</servlet-name> <servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class> <init-param> <param-name>destination</param-name> <param-value>${context}/#/~logging</param-value> </init-param> </servlet> <servlet> <servlet-name>SolrRestApi</servlet-name> <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class> <init-param> <param-name>org.restlet.application</param-name> <param-value>org.apache.solr.rest.SolrSchemaRestApi</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>RedirectOldAdminUI</servlet-name> <url-pattern>/admin/</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>RedirectOldAdminUI</servlet-name> <url-pattern>/admin</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>RedirectOldZookeeper</servlet-name> <url-pattern>/zookeeper.jsp</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>RedirectOldZookeeper</servlet-name> <url-pattern>/zookeeper</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>RedirectLogging</servlet-name> <url-pattern>/logging</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>LoadAdminUI</servlet-name> <url-pattern>/old.html</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>LoadAdminUI</servlet-name> <url-pattern>/index.html</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>SolrRestApi</servlet-name> <url-pattern>/schema/*</url-pattern> </servlet-mapping> <mime-mapping> <extension>.xsl</extension> <!-- per --> <mime-type>application/xslt+xml</mime-type> </mime-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> <!-- Get rid of error message --> <!-- <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> --> </web-app>

至此solr的配置工作完成

四、运行Solr:

启动执行:/down/apache-tomcat-8.5.12/bin/startup.sh

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/2d3975748594b8edfd08c0cb11deecd8.html