solr_solrcloud集群动态添加节点
集群动态添加节点
前面的例子中用了三台zk,两台solr,现在添加一台solr(删除默认的example)。
1.修改solr配置:solr.in.sh
ZK_HOST="192.168.75.101:2181,192.168.75.102:2181,192.168.75.103:2181"
2.启动solr
可以看到没有core
3.创建core
① 与手动添加的core形成集群
之前集群中单个页面手动创建的core:test_core,再添加一个core与其形成集群:
创建一个同名的core,
创建完后就可以直接查询里面的数据:
可见,后添加的solr节点可以直接查询原集群中的数据。
添加一条数据:
在其他机器也可以查出数据:
② 与api生成的collection形成集群
之前使用api生成过一个集群:core有两个名字:
但collection是同一个:harvewificollection
也就是说core可以不同名,甚至是两个,只要collection是同一个,就是同一个集群:
添加一个core,名称起个新的:harvewificore101,collection为集群的harvewificollection
添加成功,添加数据,在其他solr中也能查出来,说明集群添加成功
2) 删除collection
如:删除rss
http://192.168.75.102:8983/solr/admin/collections?action=DELETE&name=rss
上面的ip地址可以是三台solr中的任一台,页面输出:
<?xml version="1.0" encoding="UTF-8" ?>
- <response>
- <lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">1039</int>
</lst>
- <lst name="failure">
<str name="192.168.75.103:8983_solr">org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:Error from server at http://192.168.75.103:8983/solr: Cannot unload non-existent core [rss]</str>
<str name="192.168.75.102:8983_solr">org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:Error from server at http://192.168.75.102:8983/solr: Cannot unload non-existent core [rss]</str>
<str name="192.168.75.101:8983_solr">org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:Error from server at http://192.168.75.101:8983/solr: Cannot unload non-existent core [rss]</str>
</lst>
</response>