SolrCloud 动态扩容方案

SolrCloud 动态扩容方案

 

1:改变id的hash策略

 

使用 implicit 路由,参加: http://www.cnblogs.com/rcfeng/p/4287031.html

 当没有匹配的shards时, 数据将会集中到一个shard

 

http://172.28.4.83:11010/solr/admin/collections?action=CREATE&name=post&router.name=implicit&shards=shard1,shard2,shard3&replicationFactor=3&maxShardsPerNode=1&collection.configName=post&router.field=objectType&async=110
 
http://172.28.4.83:11010/solr/admin/collections?action=REQUESTSTATUS&requestid=110
 

http://172.28.4.83:11060/solr/post_shard2_replica1/select?q=*%3A*&shards.info=true&shards.tolerant=true&shards=http://172.28.4.83:11050/solr/post_shard1_replica1

 
 

http://172.28.4.83:11060/solr/post_shard2_replica1/select?q=*%3A*&shards.info=true&shards.tolerant=true&shards=http://172.28.4.84:11090/solr/post_shard2_replica2

 
 

http://172.28.4.83:11060/solr/post_shard2_replica1/select?q=*%3A*&shards.info=true&shards.tolerant=true&shards=http://172.28.4.83:11040/solr/post_shard3_replica1

 

2:更改别名

 collection1 1---500万
collection2 500---1000万
alias:collection{collection1,collection2}
collection3 1000---1500万
alias:collection{collection1,collection2,collection3}

 

3:增加shard及拆分shard

发现问题:在内存溢出时, 无法继续,新增的shards一直处于construction状态,使用delete shards命令删不掉:

解决办法:

使用CoreAdmin API 去UNLOAD,注意不能使用 Collections API 去调用

http://172.28.4.83:11070/solr/admin/cores?action=UNLOAD&core=common_shard1_1_replica1&deleteIndex=true&deleteDataDir=true&deleteInstanceDir=true&async=3

http://172.28.4.83:11070/solr/admin/cores?action=REQUESTSTATUS&requestid=3

 

http://172.28.4.83:11010/solr/admin/collections?action=DELETESHARD&shard=shard1_0&collection=common

 

4:重建索引

 新建一个SolrCloud,新的索引好了再切到新的上面
重建索引是指从 DB 中完全导入到新的SolrCloud中

你可能感兴趣的:(solr)