如何从用户创建的 Windows 服务启动和停止 SOLR

发布于 2024-12-01 11:49:06 字数 112 浏览 0 评论 0 原文

我有两个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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清秋悲枫 2024-12-08 11:49:06

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

即使您不使用多个索引,设置起来也要优雅得多。如果 Tomcat 如此设置,则 Solr 在启动时可用。我假设您使用的是 Solr 1.4。

您需要执行以下步骤:

设置 solr 根目录

概述

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

    
    
      ;
    
        <核心名称=“myindex”instanceDir=“myindexdir”/>
    
      
    
    

core 参数指定一个新的 core。这些属性指定,对于服务 http//localhost:8080/mysearchapp/myindex,索引目录为 myindexdir,这将我们带入下一步。

创建实际的核心

概述

c:\solr 
 |-lib
 |-solr.war
 |-solr.xml
 |-myindexdir
   |-bin
   |-conf
   |-data
  1. ,将已完成配置的 conf 目录复制到 myindexdir 中。不用费心创建 bin 和数据,它会自动创建。

设置tomcat

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

    Context docBase="c:\solr\solr.war" debug="0" crossContext="true" >
       <环境名称=“solr/home”类型=“java.lang.String”值=“c:\ solr \”覆盖=“true”/>/>
    
    
  5. 重新启动tomcat并打开 http://localhost:8080/mysearchapp/
    如果一切顺利,它将显示

    欢迎来到 Solr!
    Solr 管理 myindex
    

Now do your actions on your core like http://本地主机:8080/mysearchapp/myindex/select?q=MY-QUERY

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

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.

You need to do these steps:

Set up a solr root directory

Overview

c:\solr 
 |-lib
 |-solr.war
 |-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>
    

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.

Create the actual core

Overview

c:\solr 
 |-lib
 |-solr.war
 |-solr.xml
 |-myindexdir
   |-bin
   |-conf
   |-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.

Set up tomcat

  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>
    
  5. Restart tomcat and open http://localhost:8080/mysearchapp/
    If all goes well it will display

    Welcome to Solr!
    Solr Admin myindex
    

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

熊抱啵儿 2024-12-08 11:49:06

Solr 运行在 Tomcat 等 Servlet 容器之上。因此,要启动 Solr,您必须使用 Servlet 容器配置 Solr,然后启动。

是的,您当然可以创建 Windows 服务。但是您没有提到您使用哪个 Servlet 容器来运行 Solr?

如果是 Apache Tomcat,请执行以下操作:

1. Just go to tomcat/bin folder from command prompt
2. Say service.bat install
3. You can see the service being listed in the Microsoft Services
Application
4. Right click on the service and add solr home (in Start
parameters). For an example if your Solr home is in D drive then:
-Dsolr.solr.home="D:\solr"
5.You are done. Just right click on the service, start it or even you can set 
it to start automatically when your system starts.

Solr runs on top of a Servlet container like Tomcat. So for starting Solr you have to configure Solr with your Servlet container and then start.

Yes you can of course create a Windows Service. However you have not mentioned which Servlet container are you using for running Solr?

If it is Apache Tomcat here you go:

1. Just go to tomcat/bin folder from command prompt
2. Say service.bat install
3. You can see the service being listed in the Microsoft Services
Application
4. Right click on the service and add solr home (in Start
parameters). For an example if your Solr home is in D drive then:
-Dsolr.solr.home="D:\solr"
5.You are done. Just right click on the service, start it or even you can set 
it to start automatically when your system starts.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文