VMware12.0+Ubuntu16.04+jdk1.8.0_171+Tomcat8.0.53+solr7.4.0

Solr6.5在Centos7上的装置与配置 (一)
这篇文章首借使介绍在Centos6上Solr6.5的安装与配置。
① 、安装准备及各软件应用版本说明:
1、JDK8,版本jdk1.8.0_定时更新索引,5在Centos7上的安装与安顿。121下载地址:jdk-8u121-linux-x64.tar.gz
贰 、Apache 汤姆cat,版本8.5.13 下载地址:apache-tomcat-8.5.13.tar.gz
叁 、Solr,版本solr-6.5.0,下载地址:solr-6.5.0.tgz
此文使用的是centos6.6的种类。在系统根目录下树立down目录。然后挨家挨户下载上边的八个软件。下载完毕后如下:
/down
├── apache-tomcat-8.5.12.tar.gz
├── jdk-8u121-linux-x64.tar.gz
└── solr-6.5.0.tgz
② 、jdk安装与陈设:
1、安装

在Linux环境下,将Solr布署到tomcat7中,导入Mysql数据库数据, 定时更新索引,solrtomcat7

Solr6.5在Centos6上的装置与配置 (一),solr6.5centos6

那篇文章主要是介绍在Centos6上Solr6.5的设置与布局。

先是看望安装成功的界面,回看一下,哈哈哈……

cd /down
tar -zxvf jdk-8u121-linux-x64.tar.gz //解压缩jdk包
解压后jdk的路径应该为
/down/jdk1.8.0_121/

什么是solr

solr是基于Lucene的全文字笔迹检验索服务器,对Lucene实行了扩张优化。

一 、安装准备及各软件应用版本表明:

1、JDK8,版本jdk1.8.0_121下载地址:jdk-8u121-linux-x64.tar.gz

② 、Apache 汤姆cat,版本8.5.13 下载地址:apache-tomcat-8.5.13.tar.gz

叁 、Solr,版本solr-6.5.0,下载地址:solr-6.5.0.tgz

此文使用的是centos6.6的系统。在系统根目录下树立down目录。然后挨家挨户下载下面的多少个软件。下载达成后如下:

/down
├── apache-tomcat-8.5.12.tar.gz
├── jdk-8u121-linux-x64.tar.gz
└── solr-6.5.0.tgz

澳门金沙国际 1

2、配置:

准备干活

率先,去下载以下软件包:

JDK8:jdk-8u60-linux-x64.tar.gz

TOMCAT8:apache-tomcat-8.5.4.zip

SOLR5.5.3:solr-5.5.3.zip

并上传出到linux服务器某些路径下,如下图,小编放置在/usr/local/solr目录下:

澳门金沙国际 2

安装solr:解压solr-5.5.3.zip即可;

安装tomcat、jdk:略,网上资料很多,基本上解压,设置个环境变量就可以;

澳门金沙国际 3

然后,安装mysql:略,小编设置的是Mysql 5.5;

开创数据库及表结构:自笔者创造了2个数据库solrdemo,以及user表,如下图,

updatetime:最终更新时间;

valid:是不是管用,0意味着已去除的多少,不要求建立目录。

澳门金沙国际 4

贰 、jdk安装与布局:

1、安装

cd /down
tar -zxvf jdk-8u121-linux-x64.tar.gz //解压缩jdk包
解压后jdk的路径应该为
/down/jdk1.8.0_121/

澳门金沙国际,2、配置:

修改系统环境变量文件:

vi /etc/profile

向文件之中追加以下内容:

JAVA_HOME=/down/jdk1.8.0_121
JRE_HOME=/down/jdk1.8.0_121/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH

使修改生效:

[[email protected] local]# source /etc/profile   //使修改立即生效 
[[email protected] local]# echo $PATH   //查看PATH值

查看系统环境气象:

[[email protected] down]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/down/jdk1.8.0_121/bin:/down/jdk1.8.0_121/jre/bin:/root/bin
[root@localhost down]# 

查看JAVA版本:

[[email protected] down]# java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
[root@localhost down]# 

时至明天jdk安装收尾。

在装置配置solr以前,先安装好jdk1.8和汤姆cat8.0的条件,然后对下载好的solr举办解压:

修改系统环境变量文件:

始建二个solr core

有关怎么叫做core,小编认为便是三个管理数据的东西,里面有一部分配置文件,索引的事物。具体成立步骤如下:

跻身solr的bin目录,输入以下命令,运行solr:

./solr start

可观望如下日志:

[[email protected] bin]# ./solr start
Waiting up to 30 seconds to see Solr running on port 8983 [-]  
Started Solr server on port 8983 (pid=9951). Happy searching!

接下来输入./solr create -c demo命令,创造3个core叫demo;

./solr create -c demo

可观察如下日志:

Copying configuration to new core instance directory:
/usr/local/solr/solr-5.5.3/server/solr/demo

Creating new core 'demo' using command:
http://localhost:8983/solr/admin/cores?action=CREATE&name=demo&instanceDir=demo

{
  "responseHeader":{
    "status":0,
    "QTime":7258},
  "core":"demo"}

创立达成;

关闭solr服务:

输入命令./solr stop -all

./solr stop -all

可观看如下日志:

Sending stop command to Solr running on port 8983 ... waiting 5 seconds to allow Jetty process 9951 to stop gracefully.

在/usr/local/solr/solr-5.5.3/server/solr目录下得以看看我们成立的demo
core

澳门金沙国际 5

二 、Solr安装与配置:

 1、解压apache-tomcat-8.5.12.tar.gz和solr-6.5.0.tgz

[[email protected] down]# tar -zxvf apache-tomcat-8.5.12.tar.gz 
[[email protected] down]# tar -zxvf solr-6.5.0.tgz 

解压后的目录结构:
[[email protected] down]# ls
apache-tomcat-8.5.12         jdk1.8.0_121                solr-6.5.0
apache-tomcat-8.5.12.tar.gz  jdk-8u121-linux-x64.tar.gz  solr-6.5.0.tgz

 

② 、复制Solr文件夹中的一些文书到apache-tomcat下:

1)将 solr 压缩包中
solr\server\solr-webapp\文件夹下有个webapp文件夹,将之复制到tomcat\webapps\目录下,文件夹名改成solr(任意)

2)将 solr 压缩包中 solr\server\lib\ext 中的 jar 全部复制到 汤姆cat\
webapps\solr\WEB-INF\lib 目录中; 

3)将solr压缩包中solr/server/lib/metrics* 初步的jar全体复制到 汤姆cat\
webapps\solr\WEB-INF\lib 目录中; 

4)将solr压缩包中solr/server/lib/solr-dataimporthandler-* 伊始的jar全体复制到
汤姆cat\ webapps\solr\WEB-INF\lib 目录中; 

5)在Tomcat\
webapps\solr\WEB-INF\下建立classes目录,并将solr/server/resources/log4j.properties文件复制当中;

6)在tomcat目录下创设solrhome目录(也得以放在别的目录中)

7)复制solr/server/solr/*
全体文件到tomcat/solrhome目录,用到开创solr的core时使用。

操作shell如下:

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

 

3、配置Solr:

编辑web.xml文件:

[[email protected] 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>

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

全套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

     http://www.apache.org/licenses/LICENSE-2.0

 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 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         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 http://www.w3.org/TR/2006/PR-xslt20-20061121/ -->
    <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的布局工作完毕.

 

澳门金沙国际 6

vi /etc/profile

部署到tomcat

在tomcat的webapp目录下新建1个文书夹,叫solr;

拷贝/usr/local/solr/solr-5.5.3/server/solr-webapp/webapp目录下的剧情到/usr/local/solr/apache-tomcat-8.5.4/webapps/solr目录下;

然后在/usr/local/solr/apache-tomcat-8.5.4/webapps/solr目录下新建四个solrhome文件夹,拷贝/usr/local/solr/solr-5.5.3/server/solr(里面有贰个我们正好创设好的core,“demo”)目录下的始末到/usr/local/solr/apache-tomcat-8.5.4/webapps/solr/solrhome目录下。

拷贝/usr/local/solr/solr-5.5.3/server/lib/ext目录下的jar包到/usr/local/solr/apache-tomcat-8.5.4/webapps/solr/WEB-INF/lib下;

拷贝/usr/local/solr/solr-5.5.3/dist目录下的solr-dataimporthandler-5.5.3.jar和solr-dataimporthandler-extras-5.5.3.jar到/usr/local/solr/apache-tomcat-8.5.4/webapps/solr/WEB-INF/lib下;

拷贝/usr/local/solr/solr-5.5.3/server/resources目录下的log4j.properties文件到/usr/local/solr/apache-tomcat-8.5.4/webapps/solr/WEB-INF/classes目录,没有classes文件夹的友爱创立三个。

修改/usr/local/solr/apache-tomcat-8.5.4/webapps/solr/WEB-INF/web.xml文件内容,添加solr/home的计划音信:

    <env-entry>
       <env-entry-name>solr/home</env-entry-name>
       <env-entry-value>/usr/local/solr/apache-tomcat-8.5.4/webapps/solr/solrhome</env-entry-value>
       <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>

修改/usr/local/solr/apache-tomcat-8.5.4/webapps/solr/solrhome/demo/conf/solrconfig.xml文件,将75-85行修改为如下内容,因为大家是拷贝过来的,路径变了,笔者那里直接用相对路径。

  <lib dir="/usr/local/solr/solr-5.5.3/contrib/extraction/lib" regex=".*\.jar" />
  <lib dir="/usr/local/solr/solr-5.5.3/dist/" regex="solr-cell-\d.*\.jar" />

  <lib dir="/usr/local/solr/solr-5.5.3/contrib/clustering/lib/" regex=".*\.jar" />
  <lib dir="/usr/local/solr/solr-5.5.3/dist/" regex="solr-clustering-\d.*\.jar" />

  <lib dir="/usr/local/solr/solr-5.5.3/contrib/langid/lib/" regex=".*\.jar" />
  <lib dir="/usr/local/solr/solr-5.5.3/dist/" regex="solr-langid-\d.*\.jar" />

  <lib dir="/usr/local/solr/solr-5.5.3/contrib/velocity/lib" regex=".*\.jar" />
  <lib dir="/usr/local/solr/solr-5.5.3/dist/" regex="solr-velocity-\d.*\.jar" />

最终,运行tomcat,记得开放8080端口,能够修改/etc/sysconfig/iptables,添加-A
CR-VH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j
ACCEPT,然后输入service iptables restart重启iptables服务。

随着,浏览器输入
demo,如下图:

澳门金沙国际 7

三、运行Solr:

 运营推行:/down/apache-tomcat-8.5.12/bin/startup.sh

[[email protected] down]# /down/apache-tomcat-8.5.12/bin/startup.sh
Using CATALINA_BASE:   /down/apache-tomcat-8.5.12
Using CATALINA_HOME:   /down/apache-tomcat-8.5.12
Using CATALINA_TMPDIR: /down/apache-tomcat-8.5.12/temp
Using JRE_HOME:        /down/jdk1.8.0_121/jre
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/down/apache-tomcat-8.5.12/bin/tomcat-juli.jar
Tomcat started.
[root@localhost down]# 

在浏览器输入 

澳门金沙国际 8

关门solr只须求关闭tomcat即可:

[[email protected] down]# /down/apache-tomcat-8.5.12/bin/shutdown.sh

 

于今solr的安装收尾。

下一篇将介绍创设core并丰富普通话分词的配备。

(一),solr6.5centos6 那篇作品重借使介绍在Centos6上Solr6.5的安装与布置。
一 、安装准备及各软件使用版本表达:…

解压后的公文夹有以下内容:

向文件之中追加以下内容:

导入mysql数据库数据,并创设索引

一 、下载mysql连接驱动,如mysql-connector-java-5.1.22-bin.jar,拷贝到/usr/local/solr/apache-tomcat-8.5.4/webapps/solr/WEB-INF/lib目录;

② 、在/usr/local/solr/apache-tomcat-8.5.4/webapps/solr/solrhome/demo/conf目录下新建2个文书data_config.xml,内容如下:

<dataConfig>
<dataSource name="solrdemo" type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://192.168.229.1:3306/solrdemo" user="root" password="root"/>
  <document>
    <entity dataSource="solrdemo"  
            name="user" 
            query="select id, name, address from user where valid=1 " 
            deltaImportQuery="select  id,name,address  from user where ID='${dataimporter.delta.id}'"  
            deltaQuery="select id  from user where updatetime > '${dataimporter.last_index_time}'"  
            deletedPkQuery="select id  from user where valid=0">

        <field  column="id"  name="id"/>
        <field  column="name"  name="name"/>
        <field  column="address"  name="address"/>
     </entity>
  </document>
</dataConfig>

修改/usr/local/solr/apache-tomcat-8.5.4/webapps/solr/solrhome/demo/conf目录下的managed-schema文件,添加如下两行,id已经有了,不用添加:

    <field name="address" type="string" indexed="true" stored="true" required="true"/>
    <field name="name" type="string" indexed="true" stored="true" required="true" />

修改/usr/local/solr/apache-tomcat-8.5.4/webapps/solr/solrhome/demo/conf目录下的managed-schema文件,添加如下内容:

    <requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">  
        <lst name="defaults">  
            <str name="config">data-config.xml</str>  
        </lst>  
    </requestHandler>  

然后,重新开动tomcat,并走访
core,打开dataimport标签页,点击execute,更新索引,如下图:

澳门金沙国际 9

 

 打开query标签页,能够看到我们数据库中的数据,那里我们的参数q为*.*,匹配全部,如下:

澳门金沙国际 10

澳门金沙国际 11

JAVA_HOME=/down/jdk1.8.0_121
JRE_HOME=/down/jdk1.8.0_121/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH

定时更新索引

下载apache-solr-dataimportscheduler.jar库,并将其拷贝到/usr/local/solr/apache-tomcat-8.5.4/webapps/solr/WEB-INF/lib目录。

修改/usr/local/solr/apache-tomcat-8.5.4/webapps/solr/WEB-INF/web.xml文件,添加监听器:

    <listener>
       <listener-class>
          org.apache.solr.handler.dataimport.scheduler.ApplicationListener
       </listener-class>
    </listener>

在/usr/local/solr/apache-tomcat-8.5.4/webapps/solr/solrhome/目录新建二个conf文件夹,并在该文件夹下新建dataimport.properties文件,文件内容如下:

#################################################
#                                               #
#       dataimport scheduler properties         #
#                                               #
#################################################

#  to sync or not to sync
#  1 - active; anything else - inactive
syncEnabled=1

#  which cores to schedule
#  in a multi-core environment you can decide which cores you want syncronized
#  leave empty or comment it out if using single-core deployment
syncCores=demo

#  solr server name or IP address
#  [defaults to localhost if empty]
server=192.168.229.100

#  solr server port
#  [defaults to 80 if empty]
port=8080

#  application name/context
#  [defaults to current ServletContextListener's context (app) name]
webapp=solr

#  URL params [mandatory]
#  remainder of URL
params=/dataimport?command=delta-import&clean=false&commit=true

#  schedule interval
#  number of minutes between two runs
#  [defaults to 30 if empty]
interval=1

#  重做索引的时间间隔,单位分钟,默认7200,即1天; 
#  为空,为0,或者注释掉:表示永不重做索引
reBuildIndexInterval=2

#  重做索引的参数
reBuildIndexParams=/dataimport?command=full-import&clean=true&commit=true

#  重做索引时间间隔的计时开始时间,第一次真正执行的时间=reBuildIndexBeginTime+reBuildIndexInterval*60*1000;
#  两种格式:2012-04-11 03:10:00 或者  03:10:00,后一种会自动补全日期部分为服务启动时的日期
reBuildIndexBeginTime=03:00:00

那里,大家安顿两分钟更新索引。

重启tomcat,观望日志,发现每隔两分钟会自动更新索引;

也能够本人做个小测试,往数据库插入数据,然后搜索,发现找不到,可是等过了两分钟再一次寻找,发现可以找到。

然后大家进去到/server/solr-webapp目录,里面有二个webapp,将以此webapp复制到/usr/local/solr/tomcat/apache-tomcat-8.0.53/webapps下并从命名为solr(名字随便起),那里命名为solr。

使修改生效:

财富文件

 

参考:

定时更新索引,solrtomcat7 什么是solr
solr是基于Lucene的全文字笔迹检验索服务器,对Lucen…

澳门金沙国际 12

[root@admin local]# source /etc/profile   //使修改立即生效 
[root@admin local]# echo $PATH   //查看PATH值

澳门金沙国际 13

翻看系统环境情况:

将~/Downloads/solr-7.4.0/server/lib/ext下的持有jar都复制到/usr/local/solr/tomcat/apache-tomcat-8.0.53/webapps/solr/WEB-INF/lib下边。(这一个solr正是上面一步的solr)

[root@localhost down]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/down/jdk1.8.0_121/bin:/down/jdk1.8.0_121/jre/bin:/root/bin
[root@localhost down]# 

澳门金沙国际 14

查看JAVA版本:

 将~/Downloads/solr-7.4.0/server/lib目录下metrics相关的jar都复制到/usr/local/solr/tomcat/apache-tomcat-8.0.53/webapps/solr/WEB-INF/lib下边。

[root@localhost down]# java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
[root@localhost down]# 

澳门金沙国际 15

于今jdk安装收尾。

将~/Downloads/solr-7.4.0/server/resources下的jetty-logging.properties和log4j2.xml五个文本复制到/usr/local/solr/tomcat/apache-tomcat-8.0.53/webapps/solr/WEB-INF/classes上面。(classes文件夹倘若没有索要协调创立,那是日记文件)

二 、Solr安装与布局:

 澳门金沙国际 16

 1、解压apache-tomcat-8.5.12.tar.gz和solr-6.5.0.tgz

创建solrhome:复制~/Downloads/solr-7.4.0/server下的solr文件夹,到自由目录处(可以重新命名,小编未曾重新命名,小编的solrhome路径为:/usr/local/solr/solrhome),自定义solrhome

[root@localhost down]# tar -zxvf apache-tomcat-8.5.12.tar.gz 
[root@localhost down]# tar -zxvf solr-6.5.0.tgz 




解压后的目录结构:
[root@localhost down]# ls
apache-tomcat-8.5.12         jdk1.8.0_121                solr-6.5.0
apache-tomcat-8.5.12.tar.gz  jdk-8u121-linux-x64.tar.gz  solr-6.5.0.tgz

 澳门金沙国际 17

② 、复制Solr文件夹中的一些文书到apache-tomcat下:

配置solrhome路径,修改/usr/local/solr/tomcat/apache-tomcat-8.0.53/webapps/solr/WEB-INF下面的web.xml文件。

澳门金沙国际 18

 这一片段原来是注释的,把注释去掉就好了。

 澳门金沙国际 19

裁撤权限控制,注释web.xml中的最终几行代码,不然项目会包403。

澳门金沙国际 20

其余,也需修改/usr/local/tomcat/apache-tomcat-8.0.53/bin里面包车型地铁catalina.sh*文件,不修改运转会报以下错误:

澳门金沙国际 21

 修改内容为下图框框内的文字:

澳门金沙国际 22

修改后,汤姆cat运行成功。

 澳门金沙国际 23

走访localhost:8080,出现转手页面说成功。

澳门金沙国际 24

伊始化solr-home的数码,在solr-home文件下建二个core1(名字随意取),复制solr-home/configsets/_default/下的conf文件夹,到新建的core1下,在core1下创制文件夹data(空文件加即可)和core.properties(内容只安插name=core1即可,那里的name的值也便是在页面要出示的solrhome名称)

 澳门金沙国际 25

澳门金沙国际 26

澳门金沙国际 27

访问#/

 澳门金沙国际 28

  选择自定义的core1,能够见到core1的连带新闻,实现布署! 

1)将 solr 压缩包中
solr\server\solr-webapp\文件夹下有个webapp文件夹,将之复制到tomcat\webapps\目录下,文件夹名改成solr(任意)

2)将 solr 压缩包中 solr\server\lib\ext 中的 jar 全体复制到 汤姆cat\
webapps\solr\WEB-INF\lib 目录中; 

3)将solr压缩包中solr/server/lib/metrics* 早先的jar全部复制到 汤姆cat\
webapps\solr\WEB-INF\lib 目录中; 

4)将solr压缩包中solr/server/lib/solr-dataimporthandler-* 起初的jar全体复制到
汤姆cat\ webapps\solr\WEB-INF\lib 目录中; 

5)在Tomcat\
webapps\solr\WEB-INF\下建立classes目录,并将solr/server/resources/log4j.properties文件复制当中;

6)在tomcat目录下建立solrhome目录(也得以置身别的目录中)

7)复制solr/server/solr/*
全部文件到tomcat/solrhome目录,用到成立solr的core时使用。

操作shell如下:

[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 

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>

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

一体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

     http://www.apache.org/licenses/LICENSE-2.0

 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 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         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 http://www.w3.org/TR/2006/PR-xslt20-20061121/ -->
    <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

[root@localhost down]# /down/apache-tomcat-8.5.12/bin/startup.sh
Using CATALINA_BASE:   /down/apache-tomcat-8.5.12
Using CATALINA_HOME:   /down/apache-tomcat-8.5.12
Using CATALINA_TMPDIR: /down/apache-tomcat-8.5.12/temp
Using JRE_HOME:        /down/jdk1.8.0_121/jre
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/down/apache-tomcat-8.5.12/bin/tomcat-juli.jar
Tomcat started.
[root@localhost down]# 

在浏览器输入 

澳门金沙国际 29

关门solr只必要关闭tomcat即可:

[root@localhost down]# /down/apache-tomcat-8.5.12/bin/shutdown.sh

时至前日solr的装置完成。

相关文章