• 【solr专题之四】在Tomcat 中部署Solr4.x


    1、安装Tomcat

    (1)下载并解压至/opt/tomcat中
    # cd /opt/jediael
    # tar -zxvf apache-tomcat-7.0.54.tar.gz 
    # mv apache-tomcat-7.0.54 tomcat   将目录重命名为tomcat
    # ls
    apache-tomcat-7.0.54.tar.gz rh tomcat

    (2)配置conf/tomcat-users.xml ,以方便管理及通过页面进行配置
    <role rolename="manager-gui"/>
    <user username="tomcat" password="tomcat" roles="manager-gui"/>

    (3)启动tomcat并验证
    # bin/startup.sh
    Using CATALINA_BASE: /opt/jediael/tomcat
    Using CATALINA_HOME: /opt/jediael/tomcat
    Using CATALINA_TMPDIR: /opt/jediael/tomcat/temp
    Using JRE_HOME: /usr/java/jdk1.7.0_51
    Using CLASSPATH: /opt/jediael/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
    Tomcat started.

    打开http://ip:8080/,正常登录
    打开http://ip:8080/manager/html,使用用户名密码tomcat/tomcat进行登录

    2、部署Solr
    (1)将solr解压后的example/solr目录复制至/opt/jediael/solr/example/solr
    # mkdir -p /opt/jediael/solr/example
    # cp -rf /opt/jediael/solr-4.9.0/example/solr /opt/jediael/solr/example

    (2)将dist/solr-4.9.0.war复制至/opt/jediael/solr/example/solr,并重命名为solr.war
    # pwd
    /opt/jediael/solr/example/solr
    # cp /opt/jediael/solr-4.9.0/dist/solr-4.9.0.war solr.war
    # ls
    bin collection1 README.txt solr.war solr.xml zoo.cfg

    (3)配置solrconfig.xml ,指定数据目录
    # pwd
    /opt/jediael/solr/example/solr/collection1
     vi conf/solrconfig.xml 
    修改以下内容:
      <dataDir>${solr.data.dir:}</dataDir>
      <dataDir>${solr.data.dir:/opt/jediael/solr/example/solr/collection1/data}</dataDir>
    解释如下:which is true for running the Jetty server provided with the example, but incorrect for Tomcat running as a service.
    例上述配置马上生效:
    
    
    export JAVA_OPTS="$JAVA_OPTS -Dsolr.data.dir=/opt/jediael/solr/example/solr/collection1/data"
    (4)在tomcat中指向上述程序包
    至少启动一次tomcat,才会生成此目录
    在/opt/jediael/tomcat/conf/Catalina/localhost/创建一个新文件:
    # cd /opt/jediael/tomcat/conf/Catalina/localhost/
    # ls
    # vi solr.xml
    内容如下:
    <?xml version="1.0" encoding="utf-8"?>
    <Context docBase="/opt/jediael/solr/example/solr/solr.war" debug="0" crossContext="true">
      <Environment name="solr/home" type="java.lang.String" value="/opt/jediael/solr/example/solr" override="true"/>
    </Context>
    
    
    (5)复制jar文件及log4j的配置文件
    # cp /opt/jediael/solr-4.9.0/example/lib/ext/* /opt/jediael/tomcat/lib/
    # mkdir logs
    # pwd
    /opt/jediael/solr/example/solr
    # cp /opt/jediael/solr-4.9.0/example/resources/log4j.properties /opt/jediael/tomcat/lib/
    # vi  /opt/jediael/tomcat/lib/log4j.properties 
    修改:
    solr.log=/opt/jediael/solr/example/solr/logs/
    (6)复制jar包
    [# pwd
    /opt/jediael/solr/example/solr
    # mkdir lib
    # cp /opt/jediael/solr-4.9.0/dist/*.jar lib/
    # cp /opt/jediael/solr-4.9.0/contrib/velocity/lib/* lib/ 

    3、启动并验证
    (1)启动tomcat
    bin/startup.sh

    (2)验证以下页面
    http://ip:8080/manager/html  查看运行状态
    http://ip:8080/solr/
    http://ip:8080/solr/collection1/browse



    
    

    4、分析

    (1)上述war包被解压至 /opt/jediael/tomcat/webapps/solr,其内容如下:

    # ls
    admin.html  css  favicon.ico  img  js  META-INF  tpl  WEB-INF

    除war包外的内容:

    # lsbin collection1 lib logs README.txt solr.war solr.xml zoo.cfg

    保留在原来位置,并没变化。

    Repeat the above steps with different installation directories to run multiple instances of Solr side-by-side.






  • 相关阅读:
    MySQL基础之第9章 触发器
    Windows系统安装————windows7 企业版 无法安装 NET.framework4.52-4.6版本在WIN7下解决办法
    流媒体技术学习笔记之(十二)Linux(Ubuntu)环境运行EasyDarwin
    流媒体服务器之————EasyDarwin开源流媒体服务器:编译、配置、部署
    流媒体技术学习笔记之(十一)Windows环境运行EasyDarwin
    流媒体技术学习笔记之(十)HLS协议直播延时优化(35s到10S)
    流媒体技术学习笔记之(九)减少VLC 延迟的方法
    流媒体技术学习笔记之(八)海康、大华IpCamera RTSP地址和格式
    流媒体技术学习笔记之(七)进阶教程OBS参数与清晰度流畅度的关系
    Phalcon框架之———— 2.0升级到3.0 问题Model验证问题解决
  • 原文地址:https://www.cnblogs.com/jediael/p/4304092.html
Copyright © 2020-2023  润新知