导入Mysql数据库数据,04安装配备solr7

By admin in 美高梅手机版4858 on 2019年3月25日

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_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的装置与布置。

第3看望安装成功的界面,回忆一下,哈哈哈……

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

美高梅手机版4858 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目录下:

美高梅手机版4858 2

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

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

美高梅手机版4858 3

然后,安装mysql:略,笔者设置的是Mysql 5.5;

开创数据库及表结构:本身创制了三个数据库solrdemo,以及user表,如下图,

updatetime:最终更新时间;

valid:是不是可行,0象征已删除的数额,不要求树立目录。

美高梅手机版4858 4

二 、jdk安装与配置:

1、安装

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

导入Mysql数据库数据,04安装配备solr7。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命令,创造贰个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

美高梅手机版4858 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全体复制到
Tomcat\ 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的安插工作完成.

 

美高梅手机版4858 6

vi /etc/profile

部署到tomcat

在tomcat的webapp目录下新建二个文本夹,叫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(里面有3个大家正好创设好的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文件夹的融洽创办1个。

修改/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
凯雷德H-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j
ACCEPT,然后输入service iptables restart重启iptables服务。

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

美高梅手机版4858 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]# 

在浏览器输入 

美高梅手机版4858 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,更新索引,如下图:

美高梅手机版4858 9

 

 打开query标签页,能够看来大家数据库中的数据,那里大家的参数q为*.*,匹配全体,如下:

美高梅手机版4858 10

美高梅手机版4858 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…

美高梅手机版4858 12

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

美高梅手机版4858 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]# 

美高梅手机版4858 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]# 

美高梅手机版4858 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安装与配置:

 美高梅手机版4858 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

 美高梅手机版4858 17

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

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

美高梅手机版4858 18

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

 美高梅手机版4858 19

收回权限控制,注释web.xml中的末了几行代码,不然项目会包403。

美高梅手机版4858 20

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

美高梅手机版4858 21

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

美高梅手机版4858 22

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

 美高梅手机版4858 23

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

美高梅手机版4858 24

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

 美高梅手机版4858 25

美高梅手机版4858 26

美高梅手机版4858 27

访问#/

 美高梅手机版4858 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>
-->

美高梅手机版4858,全总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]# 

在浏览器输入 

美高梅手机版4858 29

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

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

迄今甘休solr的安装收尾。

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图
Copyright @ 2010-2019 美高梅手机版4858 版权所有