首页 > 代码库 > 在Tomcat 中部署Solr4.x
在Tomcat 中部署Solr4.x
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=http://www.mamicode.com/"/opt/solr/example/solr" override="true"/>>(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)启动tomcatbin/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=http://www.mamicode.com/"/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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。