Solr+tomcat
一、安装tomcat:
(1)、安装jdk:
http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u3-download-1501626.html
[root@localhost java]# mkdir -p /usr/java
[root@localhost java]# tar zxvf jdk-7u3-linux-x64.tar.gz -C /usr/java/
[root@localhost java]# vi /etc/profile
JAVA_HOME="/usr/java/jdk1.7.0_03"
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
Export ………JAVA_HOME CLASSPATH
[root@localhost java]# source /etc/profile
[root@localhost java]# java -version
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)
一、
安装tomcat、solr:
Tomcat
下载:
http://tomcat.apache.org/
Solr
下载:
http://apache.etoak.com//lucene/solr/
(1)安装配置SOLR:
[root@nagios home]# unzip apache-solr-3.5.0.zip
[root@nagios home]# mkdir -p /usr/local/solr_all/
[root@nagios home]# mv apache-solr-3.5.0 /usr/local/solr_all/3c_solr
[root@nagios home]# mv apache-solr-3.5.0 /usr/local/solr_all/tc_solr
[root@nagios home]# cd /usr/local/solr_all/3c_solr/
[root@nagios 3c_solr]# ls
CHANGES.txt client contrib dist docs example LICENSE.txt NOTICE.txt README.txt
[root@nagios 3c_solr]# cd example/
[root@nagios example]# mv ./webapps/solr.war ./solr/
[root@nagios example]# mv ./solr/ ../
[root@nagios 3c_solr]# ls
CHANGES.txt client contrib dist docs example LICENSE.txt NOTICE.txt README.txt solr
(2)安装配置tomcat(单独):
# tar zxvf apache-tomcat-7.0.26.tar.gz -C /usr/local/
# cd /usr/local/
# mkdir -p /usr/local/tomcat_all
# mv apache-tomcat-7.0.26 /usr/local/tomcat_all/
# mv apache-tomcat-7.0.26 tomcat
# mkdir –p /usr/local/tomcat_all/3c
# mkdir –p /usr/local/tomcat_all/tc
# cd /usr/local/tomcat_all/tomcat
[root@nagios tomcat]# cp -r conf logs temp ../3c/
[root@nagios 3c]# vi ./conf/server.xml
<?xml version='1.0' encoding='utf-8'?>
<Server port="8010" shutdown="SHUTDOWN">
<Service name="Catalina">
<Connector port="8580" maxHttpHeaderSize="8192"
maxThreads="500" minSpareThreads="50" maxSpareThreads="100"
enableLookups="false" redirectPort="9440" acceptCount="100"
connectionTimeout="200" disableUploadTimeout="true" URIEncoding="UTF-8" />
<Connector port="8900"
protocol="HTTP/1.1" enableLookups="false" redirectPort="9440" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm" />
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidatio="falsh" xmlNamespaceAware="falsh">
<Context path="" docBase="/usr/local/solr_all/3c_solr/solr/solr.war" debug="0" reloadable="true" crossContext="true" />
</Host>
</Engine>
</Service>
</Server>
[root@nagios 3c]# mkdir ./conf/Catalina/localhost
[root@nagios 3c]# cd ./conf/Catalina/localhost/
[root@nagios localhost]# vi solr.xml
<?xml version="1.0" encoding="utf-8"?>
<Context docBase="/usr/local/solr_all/3c_solr/solr/solr.war" debug="0" crossContext="true">
<Environment name="solr/home" type="java.lang.String" value="/usr/local/solr_all/3c_solr/solr" override="true"/>
</Context>
[root@nagios localhost]# cd /usr/local/tomcat_all/tomcat/bin/
[root@nagios bin]# vi start_3c.sh
export CATALINA_HOME=/usr/local/tomcat_all/tomcat
export CATALINA_BASE=/usr/local/tomcat_all/3c
$CATALINA_HOME/bin/startup.sh -D catalina.sh
[root@nagios bin]# vi stop_3c.sh
export CATALINA_HOME=/usr/local/tomcat_all/tomcat
export CATALINA_BASE=/usr/local/tomcat_all/3c
$CATALINA_HOME/bin/shutdown.sh -D catalina.sh
[root@localhost tomcat]# vi ./bin/catalina.sh
---------------------
JAVA_OPTS="-Xms3072m -Xmx3072m -Xss1024K -XX:PermSize=128m -XX:MaxPermSize=512m"
# OS specific support. $var _must_ be set to either true or false.
统一tomcat配置:
[root@localhost tomcat]# vi ./conf/server.xml
<?xml version='1.0' encoding='utf-8'?>
<Server port="8015" shutdown="SHUTDOWN">
<Service name="3c">
<Connector port="8587" maxHttpHeaderSize="8192"
maxThreads="500" minSpareThreads="50" maxSpareThreads="100"
enableLookups="false" redirectPort="9443" acceptCount="100"
connectionTimeout="200" disableUploadTimeout="true" URIEncoding="UTF-8" />
<Connector port="8809"
protocol="HTTP/1.1" enableLookups="false" redirectPort="9443" />
<Engine name="3c" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm" />
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidatio="falsh" xmlNamespaceAware="falsh">
<Context path="" docBase="/usr/local/tomcat_www/3c" debug="0" reloadable="true" crossContext="true" />
</Host>
</Engine>
</Service>
<Service name="clothing">
<Connector port="8585" maxHttpHeaderSize="8192"
maxThreads="500" minSpareThreads="50" maxSpareThreads="100"
enableLookups="false" redirectPort="9445" acceptCount="100"
connectionTimeout="200" disableUploadTimeout="true" URIEncoding="UTF-8"/>
<Connector port="8811"
protocol="HTTP/1.1" enableLookups="false" redirectPort="9445" />
<Engine name="clothing" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm" />
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidatio="falsh" xmlNamespaceAware="falsh">
<Context path="" docBase="/usr/local/tomcat_www/clothing" debug="0" reloadable="true" crossContext="true" />
</Host>
</Engine>
</Service>
<Service name="beauty">
<Connector port="8584" maxHttpHeaderSize="8192"
maxThreads="500" minSpareThreads="50" maxSpareThreads="100"
enableLookups="false" redirectPort="9444" acceptCount="100"
connectionTimeout="200" disableUploadTimeout="true" URIEncoding="UTF-8" />
<Connector port="8810"
protocol="HTTP/1.1" enableLookups="false" redirectPort="9444" />
<Engine name="beauty" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm" />
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidatio="falsh" xmlNamespaceAware="falsh">
<Context path="" docBase="/usr/local/tomcat_www/beauty" debug="0" reloadable="true" crossContext="true" />
</Host>
</Engine>
</Service>
<Service name="jiaju">
<Connector port="8589" maxHttpHeaderSize="8192"
maxThreads="500" minSpareThreads="50" maxSpareThreads="100"
enableLookups="false" redirectPort="9447" acceptCount="100"
connectionTimeout="200" disableUploadTimeout="true" URIEncoding="UTF-8"/>
<Connector port="8813"
protocol="HTTP/1.1" enableLookups="false" redirectPort="9447" />
<Engine name="jiaju" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm" />
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidatio="falsh" xmlNamespaceAware="falsh">
<Context path="" docBase="/usr/local/tomcat_www/jiaju" debug="0" reloadable="true" crossContext="true" />
</Host>
</Engine>
</Service>
<Service name="muying">
<Connector port="8588" maxHttpHeaderSize="8192"
maxThreads="500" minSpareThreads="50" maxSpareThreads="100"
enableLookups="false" redirectPort="9446" acceptCount="100"
connectionTimeout="200" disableUploadTimeout="true" URIEncoding="UTF-8"/>
<Connector port="8812"
protocol="HTTP/1.1" enableLookups="false" redirectPort="9446" />
<Engine name="muying" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm" />
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidatio="falsh" xmlNamespaceAware="falsh">
<Context path="" docBase="/usr/local/tomcat_www/muying" debug="0" reloadable="true" crossContext="true" />
</Host>
</Engine>
</Service>
<Service name="techan">
<Connector port="8590" maxHttpHeaderSize="8192"
maxThreads="500" minSpareThreads="50" maxSpareThreads="100"
enableLookups="false" redirectPort="9448" acceptCount="100"
connectionTimeout="200" disableUploadTimeout="true" URIEncoding="UTF-8"/>
<Connector port="8814"
protocol="HTTP/1.1" enableLookups="false" redirectPort="9448" />
<Engine name="techan" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm" />
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidatio="falsh" xmlNamespaceAware="falsh">
<Context path="" docBase="/usr/local/tomcat_www/techan" debug="0" reloadable="true" crossContext="true" />
</Host>
</Engine>
</Service>
<Service name="baike">
<Connector port="8591" maxHttpHeaderSize="8192"
maxThreads="500" minSpareThreads="50" maxSpareThreads="100"
enableLookups="false" redirectPort="9449" acceptCount="100"
connectionTimeout="200" disableUploadTimeout="true" URIEncoding="UTF-8"/>
<Connector port="8815"
protocol="HTTP/1.1" enableLookups="false" redirectPort="9449" />
<Engine name="baike" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm" />
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidatio="falsh" xmlNamespaceAware="falsh">
<Context path="" docBase="/usr/local/tomcat_www/baike" debug="0" reloadable="true" crossContext="true" />
</Host>
</Engine>
</Service>
</Server>
[root@localhost tomcat]# cd conf/
[root@localhost conf]# ls
3c
Catalina clothing logging.properties techan
baike
catalina.policy context.xml muying tomcat-users.xml
beauty catalina.properties jiaju
server.xml web.xml
[root@localhost conf]# vi ./3c/localhost/solr.xml
<?xml version="1.0" encoding="utf-8"?>
<Context docBase="/usr/local/tomcat_www/3c/solr/solr" debug="0" crossContext="true">
<Environment name="solr/home" type="java.lang.String" value="/usr/local/tomcat_www/3c/solr" override="true"/>
</Context>
[root@localhost tomcat]# ./bin/startup.sh
[root@localhost tomcat]# ./bin/shutdown.sh
如果报错:
http://wiki.apache.org/solr/SolrTomcat (官网错误)
[root@nagios 3c_solr]# vi /usr/local/solr_all/3c_solr/solr/conf/solrconfig.xml
将
${solr.velocity.enabled:true}"/修改为${solr.velocity.enabled:false}"/