1、安装Tomcat
(1)下载并解压至/opt/tomcat中
[[email protected] solr]# cd /opt [[email protected] opt]# tar -zxvf apache-tomcat-7.0.54.tar.gz [[email protected] opt]# mv apache-tomcat-7.0.54 tomcat 将目录重命名为tomcat [[email protected] 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并验证
[[email protected] 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
[[email protected] opt]# mkdir -p /opt/solr/example [[email protected] 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
[[email protected] solr]# pwd /opt/solr/example/solr [[email protected] solr]# cp ~jediael/solr-4.9.0/dist/solr-4.9.0.war solr.war [[email protected] solr]# ls bin collection1 README.txt solr.war solr.xml zoo.cfg
(3)配置solrconfig.xml ,指定数据目录
[[email protected] collection1]# pwd /opt/solr/example/solr/collection1 [[email protected] 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/创建一个新文件: [[email protected] tomcat]# cd /opt/tomcat/conf/Catalina/localhost/ [[email protected] localhost]# ls [[email protected] 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的配置文件
[[email protected] tomcat]# cp ~jediael/solr-4.9.0/example/lib/ext/* /opt/tomcat/lib/ [[email protected] solr]# mkdir logs [[email protected] solr]# pwd /opt/solr/example/solr [[email protected] tomcat]# cp ~jediael/solr-4.9.0/example/resources/log4j.properties /opt/tomcat/lib/ [[email protected] tomcat]# vi /opt/tomcat/lib/log4j.properties
修改:
solr.log=/opt/solr/example/solr/logs/
(6)复制jar包
[[email protected] solr]# pwd /opt/solr/example/solr [[email protected] solr]# mkdir lib [[email protected] solr]# cp ~jediael/solr-4.9.0/dist/*.jar lib/ [[email protected] 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的配置文件
[[email protected] tomcat]# cp ~jediael/solr-4.9.0/example/lib/ext/* /opt/tomcat/lib/
[[email protected] solr]# mkdir logs
[[email protected] solr]# pwd
/opt/solr/example/solr
[[email protected] tomcat]# cp ~jediael/solr-4.9.0/example/resources/log4j.properties /opt/tomcat/lib/
[[email protected] tomcat]# vi /opt/tomcat/lib/log4j.properties
修改:solr.log=/opt/solr/example/solr/logs/
(6)复制jar包
[[email protected] solr]# pwd
/opt/solr/example/solr
[[email protected] solr]# mkdir lib
[[email protected] solr]# cp ~jediael/solr-4.9.0/dist/*.jar lib/
[[email protected] 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
时间: 2024-12-15 06:49:39