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,使用usernamepasswordtomcat/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,才会生成此文件夹
至少启动一次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.
版权声明:本文博客原创文章,博客,未经同意,不得转载。