| 参考网址:http://hadop.iteye.com/blog/1403337
 http://lianj-lee.iteye.com/blog/425414
 http://www.blogjava.net/conans/articles/379546.html
 。 一、试运行多核
 1.1     首先下载solr3.6.2 和 tomcat-7.0.40。解压后,solr3.6.2目录是:D:\Downloads\apache-solr-3.6.2
 tomcat7.0.40目录是:D:\Downloads\apache-tomcat-7.0.40
 
 1.2     设置solr.home 目录。本文章中solr.home 路径是:D:\Downloads\apache-tomcat-7.0.40\solr.home 
 1.3     将“\apache-solr-3.6.2\example\webapps”目录下的solr.war 复制到“apache-tomcat-7.0.40\webapps”下。 
 1.4     在“apache-tomcat-7.0.40\conf\Catalina\localhost”新建solr.xml文件。将其内容示例如下: | <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Context docBase="D:\Downloads\apache-tomcat-7.0.40\webapps\solr.war" debug="0" crossContext="true" >
 <Environment name="solr/home" type="java.lang.String" value="D:\Downloads\apache-tomcat-7.0.40\solr.home" override="true" />
 </Context>
 
 | 
 
 1.5     将“apache-solr-3.6.2\example\multicore”目录下的所有文件复制到“solr.home”目录:D:\Downloads\apache-tomcat-7.0.40\solr.home 
 1.6     输入http://localhost:8080/solr/ 可以查看到core0和core1。 
 说明:上面配置的核心是solr.xml文件,主要涉及两个路径docBase :solr.war文件路径。
 solr/home :solr.home路径,即多核数据的根目录。
 二、  配置多核Solr
 
 2.1      首先你得熟悉如何在配置一个单核的solr。可以参考: 《Solr 3.6.2索引MySQL数据库配置过程》 
 2.2      进入按照《Solr 3.6.2索引MySQL数据库配置过程》配置好的solr 3.6.2, 进入目录:“apache-solr-3.6.2\example\solr”,将该目录下的所有文件复制到“D:\Downloads\apache-tomcat-7.0.40\solr.home\core0”目录下。 
 2.3      正如《Solr 3.6.2索引MySQL数据库配置过程》提及到的几个配置文件:data-config.xml, schema.xml, solrconfig.xml。 其中data-config.xml, schema.xml是数据库的相关的文件,可以根据修改自行修改。我们细看一下solrconfig.xml文件的,找到lib标签中的如下内容: | <lib dir="../../dist/" regex="apache-solr-dataimporthandler-\d.*\.jar"/> <lib dir="../../dist/" regex="apache-solr-cell-\d.*\.jar" />
 <lib dir="../../contrib/extraction/lib" regex=".*\.jar" />
 
 <lib dir="../../dist/" regex="apache-solr-clustering-\d.*\.jar" />
 <lib dir="../../contrib/clustering/lib/" regex=".*\.jar" />
 <lib dir="../../dist/" regex="apache-solr-dataimporthandler-\d.*\.jar"/>
 <lib dir="../../contrib/dataimporthandler/lib/" regex=".*\.jar" />
 <lib dir="../../dist/" regex="apache-solr-langid-\d.*\.jar" />
 <lib dir="../../contrib/langid/lib/" regex=".*\.jar" />
 <lib dir="../../dist/" regex="apache-solr-velocity-\d.*\.jar" />
 <lib dir="../../contrib/velocity/lib" regex=".*\.jar" />
 
 | 
            这些目录都是相对路径,是运行solr需要一些jar包。它们的原路径是:apache-solr-3.6.2\dis; apache-solr-3.6.2\contrib.
            为了能够运行在tomcat下,需要将它们apache-solr-3.6.2\dis; apache-solr-3.6.2\contrib目录复制到solr.home目录下。solr.home的目录结构大致如下:            --solr.home                    --contrib--core0
 --core1
 ​--dist
 --exampledocs
 --readme.txt
 --solr.xml
 2.4      修改\solr.home\core0\conf\solrconfig.xml文件,将lib标签中dir属性改为”../dist/……”或”../contrib/……”。因为dist文件夹和contrib文件夹有变动。 
 2.5      在solr.home\core0目录下新建一个lib文件夹,其中放入IK分词器jar包“IKAnalyzer2012_u6.jar”和mysql驱动文件“mysql-connector-java-5.1.25-bin.jar”。 
 2.6      导入数据的URL地址是:http://localhost:8080/solr/core0/dataimport?command=full-import  
 2.7      在solr.home 目录下有个solr.xml文件,它的内容如下: 2.8      其中可能会有其他错误,查看tomcat控制台输出,自行google之。
 <solr persistent="false">      <!--    adminPath: RequestHandler path to manage cores.        If 'null' (or absent), cores will not be manageable via request handler    -->    <cores adminPath="/admin/cores">      <core name="core0" instanceDir="core0"/>      <core name="core1" instanceDir="core1"/>    </cores>  </solr>  
 参数说明如下:
 1)solr
 The <solr> tag accepts two attributes:
 persistent - By default, should runtime core manipulation be saved in solr.xml so that it is available after a restart.
 sharedLib - Path to a directory containing .jar files that are added to the classpath of every core. The path is relative to solr.home (where solr.xml sits)
 2)cores
 The <cores> tag accepts two attribute:
 adminPath - Relative path to access the CoreAdminHandler for dynamic core manipulation. For example, adminPath="/admin/cores" configures access via  http://localhost:8983/solr/admin/cores. If this attribute is not specified, dynamic manipulation is unavailable.
 3)core
 The <core> tag accepts two attributes:
 name - The registered core name. This will be how the core is accessed.
 instanceDir - The solr.home directory for a given core.
 dataDir - The data directory for a given core. The default is <instanceDir>/data . It can take an absolute path or a relative path w.r.t instanceDir .  Solr1.4
 4)property
 The <property> tag accepts two attributes:
 name - The name of the property
 value - The value of the property
 
 
 
 
 |