首页 > 其他 > 详细

在Tomcat 中部署Solr4.x

时间:2014-07-17 21:10:55      阅读:483      评论:0      收藏:0      [点我收藏+]

1、安装Tomcat

(1)下载并解压至/opt/tomcat中
[root@jediael44 solr]# cd /opt
[root@jediael44 opt]# tar -zxvf apache-tomcat-7.0.54.tar.gz 
[root@jediael44 opt]# mv apache-tomcat-7.0.54 tomcat   将目录重命名为tomcat
[root@jediael44 opt]# 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并验证
[root@jediael44 tomcat]# bin/startup.sh
Using CATALINA_BASE: /opt/tomcat
Using CATALINA_HOME: /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.7.0_51
Using CLASSPATH: /opt/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)将example/solr目录复制至/opt/solr/example/solr
[root@jediael44 opt]# mkdir -p /opt/solr/example
[root@jediael44 opt]# cp -rf ~jediael/solr-4.9.0/example/solr /opt/solr/example

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

(3)配置solrconfig.xml ,指定数据目录
[root@jediael44 collection1]# pwd
/opt/solr/example/solr/collection1
[root@jediael44 collection1]# vi conf/solrconfig.xml 
修改以下内容:
  <dataDir>${solr.data.dir:}</dataDir>
  <dataDir>${solr.data.dir:/opt/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/solr/example/solr/collection1/data"
(4)在tomcat中指向上述程序包
在/opt/tomcat/conf/Catalina/localhost/创建一个新文件:
[root@jediael44 tomcat]# cd /opt/tomcat/conf/Catalina/localhost/
[root@jediael44 localhost]# ls
[root@jediael44 localhost]# vi solr.xml
内容如下:
<?xml version="1.0" encoding="utf-8"?>
<Context docBase="/opt/solr/example/solr/solr.war" debug="0" crossContext="true">
  <Environment name="solr/home" type="java.lang.String" value="/opt/solr/example/solr" override="true"/>
</Context>

(5)复制jar文件及log4j的配置文件
[root@jediael44 tomcat]# cp ~jediael/solr-4.9.0/example/lib/ext/* /opt/tomcat/lib/
[root@jediael44 solr]# mkdir logs
[root@jediael44 solr]# pwd
/opt/solr/example/solr
[root@jediael44 tomcat]# cp ~jediael/solr-4.9.0/example/resources/log4j.properties /opt/tomcat/lib/
[root@jediael44 tomcat]# vi  /opt/tomcat/lib/log4j.properties 
修改:
solr.log=/opt/solr/example/solr/logs/
(6)复制jar包
[root@jediael44 solr]# pwd
/opt/solr/example/solr
[root@jediael44 solr]# mkdir lib
[root@jediael44 solr]# cp ~jediael/solr-4.9.0/dist/*.jar lib/
[root@jediael44 solr]# cp ~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





<?xml version="1.0" encoding="utf-8"?>
<Context docBase="/opt/solr/example/solr/solr.war" debug="0" crossContext="true">
  <Environment name="solr/home" type="java.lang.String" value="/opt/solr/example/solr" override="true"/>
</Context>
(5)复制jar文件及log4j的配置文件
[root@jediael44 tomcat]# cp ~jediael/solr-4.9.0/example/lib/ext/* /opt/tomcat/lib/
[root@jediael44 solr]# mkdir logs
[root@jediael44 solr]# pwd
/opt/solr/example/solr

[root@jediael44 tomcat]# cp ~jediael/solr-4.9.0/example/resources/log4j.properties /opt/tomcat/lib/
[root@jediael44 tomcat]# vi  /opt/tomcat/lib/log4j.properties 
修改:solr.log=/opt/solr/example/solr/logs/

(6)复制jar包
[root@jediael44 solr]# pwd
/opt/solr/example/solr
[root@jediael44 solr]# mkdir lib
[root@jediael44 solr]# cp ~jediael/solr-4.9.0/dist/*.jar lib/
[root@jediael44 solr]# cp ~jediael/solr-4.9.0/contrib/velocity/lib/* lib/ 

3、启动并验证
(1)启动tomcat
bin/startup.sh
(2)验证以下页面
http://182.92.160.44:8080/manager/html  查看运行状态
http://182.92.160.44:8080/solr/
http://182.92.160.44:8080/solr/collection1/browse

在Tomcat 中部署Solr4.x,布布扣,bubuko.com

在Tomcat 中部署Solr4.x

原文:http://blog.csdn.net/jediael_lu/article/details/37908885

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!