gpt4 book ai didi

php - 如何在 ubuntu 中将 SOLR 从正常的 8983 端口移动到 Apache Tomcat 7 服务器?

转载 作者:行者123 更新时间:2023-12-04 18:47:10 30 4
gpt4 key购买 nike

我已经在 usr/shared/tomcat7 文件夹中安装了 Tomcat 7。之后在我的 ubuntu 的/var/www/文件夹中安装了 Solr 4.7。我的 solr 现在在 http://localhost:8983/solr/ 上运行url,但我现在想将其移动到 tomcat 服务器并希望通过 http://localhost:8080/solr/ 访问它网址。

该怎么办?请帮帮我。

最佳答案

您可以将 Solr 与 Solr 附带的 Jetty 一起使用,只需更改 jetty.xml 文件中的端口号。如果您想将 Solr 与 Tomcat 一起使用,您需要做的还不止这些。这是一个完整的说明:

  • 使用 apt-get
  • 安装 tomcat7
    sudo apt-get install tomcat7
  • 将 solr 下载到/tmp(例如:4.0.0)
  • cd /tmp wget http://{mirror site}/apache/lucene/solr/4.0.0/apache-solr-4.0.0.tgz
  • 将 solr war 文件复制到 tomcat webapps。 (dist 路径在 future 版本中可能已更改)
  • cp /tmp/apache-solr-4.0.0/dist/apache-solr-4.0.0.war /var/lib/tomcat7/webapps/solr.war
  • 创建一个 solr 主目录
  • mkdir /usr/share/solr
  • 将示例 solr 中的所有内容复制到新的 solr 主目录。
  • cp -R /tmp/apache-solr-4.0.0/example/solr/* /usr/share/solr/
  • 在 tomcat 中为 solr 创建一个配置文件并插入以下行。
  • sudo pico /etc/tomcat7/Catalina/localhost/solr.xml
        <Context docBase="/var/lib/tomcat7/webapps/solr.war" debug="0" privileged="true" allowLinking="true" crossContext="true" >    <Environment name="solr/home" type="java.lang.String" value="/usr/share/solr" override="true" />    </Context>
    1. Create the coresCreating example core:

      1. Create example directory in /var/lib/solr and copy another conf file from another core like /usr/share/solr/collection1

      mkdir /var/lib/solr/example

      cp -R /usr/share/solr/collection1 /var/lib/solr/example/

      1. create a data directory for example core and set the in /var/lib/solr/example/conf/solrconfig.xml
      2. mkdir /var/lib/solr/data/example
      3. Give tomcat7 the permissions

      chown -R tomcat7:tomcat7 /var/lib/solr

      1. To enable the core it needs a symlink in /usr/share/solr

      ln -s /var/lib/solr/example /usr/share/solr/example

      1. Add the following core configuration to /usr/share/solr.xml (only if there is configuration for other cores)

      <solr persistent="false">  <cores adminPath="/admin/cores" shareSchema="true">    <core name="example" instanceDir="example" />  </cores></solr>

    7. Solr cores are available at http://HOST_NAME:PORT/solr/admin/cores (http://example.com:8080/) 8. Add other cores the same way.

    1. Change tomcat port from 8080 in /etc/tomcat7/server.xml

    2. Security: set solr a password

      a. Open /etc/tomcat7/tomcat-users.xml for editing.

      b. Add solr role and users within the element and save the changes:

      <role rolename="solradmin" /><user username="username" password="password" roles="solradmin" />

    c. Open /var/lib/tomcat7/webapps/solr/WEB-INF/web.xml for editing. Add the following lines within the element:

      <security-constraint>
    <web-resource-collection>
    <web-resource-name>Solr Lockdown</web-resource-name>
    <url-pattern>/</url-pattern>
    </web-resource-collection>
    <auth-constraint>
    <role-name>solradmin</role-name>
    </auth-constraint>
    </security-constraint>
    <login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>Solr</realm-name>
    </login-config>

    d。保存更改并重新启动 Tomcat(/etc/init.d/tomcat7 restart)。

    e.使用 http://username:password@example.com:8080/solr 访问 solr

    如果 tomcat 提示缺少像 logger 这样的库,请将所需的 jars 复制到/var/tomcat7/lib

    关于php - 如何在 ubuntu 中将 SOLR 从正常的 8983 端口移动到 Apache Tomcat 7 服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29960036/

    30 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com