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

系统 1596 0

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.


          

            




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


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论