1、安装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
<role rolename="manager-gui"/> <user username="tomcat" password="tomcat" roles="manager-gui"/>
[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.
[root@jediael44 opt]# mkdir -p /opt/solr/example [root@jediael44 opt]# cp -rf ~jediael/solr-4.9.0/example/solr /opt/solr/example
[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
[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>
export JAVA_OPTS="$JAVA_OPTS -Dsolr.data.dir=/opt/solr/example/solr/collection1/data"
在/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
原文地址:http://blog.csdn.net/jediael_lu/article/details/37908885