solr-cloud集群配置

solr官网下载solr-4.9.0,下文的solr-4.9.0目录指的是解压后的solr-4.9.0目录
下文的/data/solr目录指的是服务器的文件目录
solr4.9.0需要jdk7及以上版本
红色字符 随环境变化而变

node1为一个节点
可以按照node1配置其他节点

索引collection配置

1. 创建目录:/data/solr/index/node1
2. 拷贝solr-4.9.0/example/solr下的文件到/data/solr/index/node1,删除/data/solr/index/node1/bin目录
3. 重命名/data/solr/index/node1/collection为google
索引文件的默认目录为:/data/solr/index/node1/ google/data
4. 修改/data/solr/index/node1/ google/core.properties中name=google

5. 修改/data/solr/index/node1/solr.xml中:
<int name="hostPort">${jetty.port:18070}</int>端口改为tomcat的端口

注意:
这个端口体现在node的name中
{
  "operation":"state",
  "state":"active",
  "base_url":"http://10.241.14.114:18070/solr",
  "core":"google",
  "roles":null,
  "node_name":"10.241.14.114:18070_solr",
  "shard":"shard1",
  "collection":"google",
  "numShards":"2",
  "core_node_name":"core_node1"}

{
  "operation":"state",
  "state":"active",
  "base_url":"http://10.241.14.114:18071/solr",
  "core":"google",
  "roles":null,
  "node_name":"10.241.14.114:18071_solr",
  "shard":"shard2",
  "collection":"google",
  "numShards":"2",
  "core_node_name":"core_node2"}

6. 打开/data/solr/index/node1/google/conf/solrconfig.xml, 删除如下内容,不然重启时间长:
<searchComponent name="suggest" class="solr.SuggestComponent">
  <lst name="suggester">
      <str name="name">mySuggester</str>
      <str name="lookupImpl">FuzzyLookupFactory</str>      <!-- org.apache.solr.spelling.suggest.fst -->
      <str name="dictionaryImpl">DocumentDictionaryFactory</str>     <!-- org.apache.solr.spelling.suggest.HighFrequencyDictionaryFactory -->
      <str name="field">cat</str>
      <str name="weightField">price</str>
      <str name="suggestAnalyzerFieldType">string</str>
    </lst>
  </searchComponent>

  <requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy">
    <lst name="defaults">
      <str name="suggest">true</str>
      <str name="suggest.count">10</str>
    </lst>
    <arr name="components">
      <str>suggest</str>
    </arr>
  </requestHandler>
tomcat配置
1. apache-tomcat-1/bin/catalina.sh加
 主节点:
JAVA_OPTS='-server -Xmx32g -Xms6g -DzkHost=127.0.0.1:2181 -Dbootstrap_conf=true  -DnumShards=2'

windows:
setlocal
set "JAVA_OPTS=-server -Xmx32g -Xms6g -DzkHost=127.0.0.1:2181 -Dbootstrap_conf=true  -DnumShards=2"
 从节点:
JAVA_OPTS='-server -Xmx32g -Xms6g -DzkHost=127.0.0.1:2181  -DnumShards=2'

windows:

setlocal
set "JAVA_OPTS=-server -Xmx1024m -Xms256m  -DzkHost=127.0.0.1:2181  -DnumShards=2"

注意:
DzkHost为zookeeper的地址和端口
DnumShards为分片数量

2. 修改apache-tomcat-1/conf/server.xml中所有端口


webapp配置
1. 拷贝solr-4.9.0/example/webapps/ solr.war到apache-tomcat-1/ webapps目录,解压,删除solr.war
2. apache-tomcat-1/webapps/solr/WEB-INF/web.xml中增加:
<env-entry>
       <env-entry-name>solr/home</env-entry-name>
       <env-entry-value>/data/solr/index/node1</env-entry-value><!--  collection配置目录 -->
       <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>
3. 创建apache-tomcat-1/webapps/solr/WEB-INF/classes/log4j.properties,内容如下(注意红色):
#  Logging level
solr.log=/data/logs/solr/
log4j.rootLogger=INFO, file, CONSOLE

log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender

log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%-4r [%t] %-5p %c %x \u2013 %m%n

#-
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender

#- File to log to and log format
log4j.appender.file.File=${solr.log}/solr-18070.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%-5p - %d{yyyy-MM-dd HH:mm:ss.SSS}; %C; %m\n

log4j.logger.org.apache.zookeeper=WARN
log4j.logger.org.apache.hadoop=WARN

# set to INFO to enable infostream log messages
log4j.logger.org.apache.solr.update.LoggingInfoStream=OFF

4. 拷贝solr-4.9.0/example/lib/ext下的jar到/data/solr/tomcat-18070/webapps/solr/WEB-INF/lib

你可能感兴趣的:(Solr)