如何从用户创建的 Windows 服务启动和停止 SOLR [英] How to start and Stop SOLR from A user created windows service

查看:49
本文介绍了如何从用户创建的 Windows 服务启动和停止 SOLR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个 bat 文件 start.bat 和 stop.bat 用于手动启动和停止 SOLR 服务器,我是否可以创建一个 Windows 服务,它会在启动服务时调用 start.bat 并在停止服务时调用 stop.bat

I had a two bat files start.bat and stop.bat for starting and stopping SOLR server manually, Is it possible for me to create a windows serive which will call start.bat on starting the service and also call stop.bat on stopping the sERVICE

推荐答案

考虑使用 Tomcat 的 Solr 多核功能.每个核心就像一个完全成熟的安装,单独的配置和索引,对于非常不同的应用程序有自己的配置和架构,但仍然具有统一管理的便利"http://wiki.apache.org/solr/CoreAdmin

Consider Solr Multicore feature with Tomcat. Each core is like a fully fledged installation, "separate configurations and indexes, with their own config and schema for very different applications, but still have the convenience of unified administration" http://wiki.apache.org/solr/CoreAdmin

即使您不使用多个索引,设置起来也更加优雅.如果以这种方式设置 Tomcat,则 Solr 在启动时可用.我假设您使用的是 Solr 1.4.

Even if you dont use multiple indexes, it's much more elegant to set up. Solr is available on startup if Tomcat is set that way. I assume you are using Solr 1.4.

您需要执行以下步骤:

概述

c:\solr 
 |-lib
 |-solr.war
 |-solr.xml

  1. 创建 c:\solr
  2. 从 Solr 包目录中,将 lib 目录复制到根目录.
  3. 从 Solr 包目录的 \example\webapps 中,复制 solr.war
  4. solr.xml 有以下内容

  1. Create c:\solr
  2. from the Solr package directory, copy the lib directory to the root dir.
  3. from \example\webapps of Solr package directory, copy the solr.war
  4. solr.xml has the following contents

<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="false" sharedLib="lib">
  <cores adminPath="/admin/cores">

    <core name="myindex" instanceDir="myindexdir" />

  </cores>
</solr>

core 参数指定一个新的核心.属性指定为服务 http//localhost:8080/mysearchapp/myindex,索引目录为 myindexdir,这将我们带到下一步.

The core parameter specifies a new core. The attributes specify that for serving http//localhost:8080/mysearchapp/myindex, the index directory is myindexdir, which brings us to the next step.

概述

c:\solr 
 |-lib
 |-solr.war
 |-solr.xml
 |-myindexdir
   |-bin
   |-conf
   |-data

  1. 将您已完成配置的conf 目录复制到myindexdir.不要费心创建 bin 和 data,它会自动创建.
  1. copy the conf directory, where you have done your configuration to myindexdir. Dont bother creating bin and data, it will be automatically created.

设置tomcat

  1. 安装Tomcat,运行一次(不要跳过)并打开http://localhost:8080 查看是否安装成功
  2. 当然,使用 services.msc 将其设置为启动时启动
  3. 打开这个目录Apache Software Foundation\Tomcat 6.0\conf\Catalina\localhost
  4. 创建文件 mysearchapp.xml

  1. install Tomcat, run it once (dont skip this) and open http://localhost:8080 to see if it is successfully installed
  2. Of course, set it to start on boot by using services.msc
  3. Open this directory Apache Software Foundation\Tomcat 6.0\conf\Catalina\localhost
  4. Create the file mysearchapp.xml

Context docBase="c:\solr\solr.war" debug="0" crossContext="true" >
   <Environment name="solr/home" type="java.lang.String" value="c:\solr\" override="true" />
</Context>

  • 重启tomcat并打开http://localhost:8080/mysearchapp/如果一切顺利,它将显示

  • Restart tomcat and open http://localhost:8080/mysearchapp/ If all goes well it will display

    Welcome to Solr!
    Solr Admin myindex
    

  • 现在在你的核心上做你的操作,比如 http://localhost:8080/mysearchapp/myindex/select?q=MY-QUERY

    Now do your operations on your core like http://localhost:8080/mysearchapp/myindex/select?q=MY-QUERY

    这篇关于如何从用户创建的 Windows 服务启动和停止 SOLR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆