一、SolrCloud规划
collection:logcollection
shard:3
replica:3
二、安装solr以及zookeeper
zookeeper:192.168.129.102:2181,192.168.129.103:2181,192.168.129.104:2181。
三、SolrCloud配置
1. 上传配置文件至zookeeper
a)新建目录/usr/local/solrcloud/config-files、/usr/local/solrcloud/solr-libs。
b)cp /usr/local/solr-5.2.1/server/solr/configsets/data_driven_schema_configs/conf/* /usr/local/solrcloud/config-files。
c)cp /usr/local/tomcat-7.0.63/webapps/solr/WEB-INF/lib/* /usr/local/solrcloud/solr-libs。
d)上传配置文件:java -classpath .:/usr/local/solrcloud/solr-libs/* org.apache.solr.cloud.ZkCLI -cmd upconfig -zkhost 192.168.129.102:2181,192.168.129.103:2181,192.168.129.104:2181 -confdir /usr/local/solrcloud/config-files/ -confname logconf
e)查看zookeeper目录/configs/logconf中有对应配置文件,上传成功。
2. 将上传到ZooKeeper中配置文件与Collection相关联:java -classpath .:/usr/local/solrcloud/solr-libs/* org.apache.solr.cloud.ZkCLI -cmd linkconfig -collection logcollection -confname logconf -zkhost 192.168.129.102:2181,192.168.129.103:2181,192.168.129.104:2181。
3. 在tomcat/bin/catalina.sh中添加启动参数:JAVA_OPT="-Dsolr.solr.home=/usr/local/solr-5.2.1/solr -DzkHost=192.168.129.102:2181,192.168.129.103:2181,192.168.129.104:2181"。启动tomcat即可。
4. 创建分片以及副本:curl 'http://192.168.1.1:8080/solr/admin/cores?action=CREATE&name=mycollection_shard1_replica_2&collection=mycollection&shard=shard1'
192.168.129.101:shard1_replica1,shard2_replica2,shard3_replica3
192.168.129.102:shard1_replica2,shard2_replica3,shard3_replica1
192.168.129.103:shard1_replica3,shard2_replica1,shard3_replica2
至此,SolrCloud配置完毕。用户可以根据需要修改配置文件,并上传至zookeeper。
四、url方式创建collection
1. 上传schema.xml等配置文件至zookeeper
2. 创建collection
http://192.168.66.128:8081/solr/admin/collections?action=CREATE&name=collection1&numShards=3&replicationFactor=2&maxShardsPerNode=2&collection.configName=myconf
3.修改配置文件之后,reload
http://192.168.27.18:8081/solr/admin/collections?action=RELOAD&name=collection1
4.