系統環境
win7 64位
jdk 7
solr 4.7.2
apache-tomcat-7.0.69
下載地址
http://archive.apache.org/dist/lucene/solr/
下載解壓
D:\Soft\solr-4.7.2
目錄說明
contrib:solr功能模塊需要的庫,根據需要引用
dist:發佈目錄
docs:Solr 文檔及教程目錄
example:官方提供的Solr使用例子
D:\Soft\solr-4.7.2\example\webapps\solr.war (solr admin web application)
D:\Soft\solr-4.7.2\example\multicore ( solr core 例子)
solr_core:自己新建的目錄,存儲solrcore用的
環境搭建
1) tomcat配置 server.xml
新增URIEncoding="UTF-8" 配置防止中文亂碼
<Connector port="8899" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" />
2) 將D:\Soft\solr-4.7.2\example\webapps\solr.war放到tomcat\webapps目錄中,解壓出來
3) 配置索引庫路徑
修改apache-tomcat-7.0.69\webapps\solr\WEB-INF\web.xml 文件
tomcat 和 sorl 都在D盤,使用絕對路徑
<!-- 配置solr core 的路徑 -->
<env-entry>
<env-entry-name>solr/home</env-entry-name>
<env-entry-value>/Soft/solr-4.7.2/solr_core/solr</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
4) 增加依賴jar包
將D:\Soft\solr-4.7.2\example\lib\ext中的jar拷貝到apache-tomcat-7.0.69\webapps\solr\WEB-INF\lib目錄中
5) 新增日誌配置文件
將D:\Soft\solr-4.7.2\example\resources\log4j.properties拷貝到apache-tomcat-7.0.69\webapps\solr\WEB-INF\classes目錄中,修改配置文件改成絕對路徑,會在D:\solrlogs生成日誌文件
solr.log=/solrlogs
6) 拷貝core文件
將D:\Soft\solr-4.7.2\example\solr拷貝到D:\Soft\solr-4.7.2\solr_core\solr目錄中
D:\Soft\solr-4.7.2\solr_core\solr 在上面第3步配置的
這樣啓動tomcat後將會看到默認的collection1
7)啓動tomcat
7) 默認core
能看到默認collection1說明core目錄配置正確
8) 創建core
將D:\Soft\solr-4.7.2\example\multicore目錄中的core0整個目錄拷貝到D:\Soft\solr-4.7.2\solr_core\solr目錄中
什麼都不改,然後add core將能看到core0
重新拷貝core0,將core0文件夾改成testcore,同時修改testcore\conf\solrconfig.xml
將 ${solr.core0.data.dir:} 改成 ${solr.testcore.data.dir:}
然後add core,將能看到testcore