设为首页 收藏本站
查看: 1660|回复: 0

[经验分享] 13.1SolrCloud集群使用手册之Collections API

[复制链接]

尚未签到

发表于 2017-12-20 11:32:06 | 显示全部楼层 |阅读模式
  转载请出自出处:http://www.cnblogs.com/hd3013779515/
  1.创建collection
  

name:指明collection名字  

  
router.name:指定路由策略,默认为compositeId路由
  

  
numShards:collection的逻辑分片数量
  

  
shards:指定具体的shard列表
  

  
replicationFactor:一个分片的replicas数量
  

  
maxShardsPerNode :一个solr节点上可以创建的逻辑分片数量,默认值为1
  

  
createNodeSet:可以指定在那些solr节点上创建collection
  


路由规则
  SolrCloud中对于文档分布在哪个shard上,提供了两种路由算法:compositeId和implicit
  在创建Collection时,需要通过router.name指定路由策略,默认为compositeId路由。

compositeId
  该路由为一致性哈希路由,shards的哈希范围从80000000~7fffffff。初始创建collection是必须指定numShards个数,compositeId路由算法根据numShards的个数,计算出每个shard的哈希范围,因此路由策略不可以扩展shard。

implicit
  该路由方式指定索引具体落在路由到哪个Shard,这与compositeId路由方式索引可均匀分布在每个shard上不同。同时只有在implicit路由策略下才可创建shard。
  利用solrJ新建索引时,需要在代码中指定索引具体落在哪个shard上,添加代码:
  doc.addField("_route_", "shard_X");
  同时在schema.xml添加字段
  <field name="_route_" type="string"/>
  当我们想指定配置文件,索引目录时,可以加入如下参数
  property.name=value
  string
  No
  Set core property name to value. See core.properties file contents.
  可选参数如下:
  key
  Description
  name
  The name of the SolrCore. You'll use this name to reference the SolrCore when running commands with the CoreAdminHandler.
  config
  The configuration file name for a given core. The default is solrconfig.xml.
  schema
  The schema file name for a given core. The default is schema.xml
  dataDir

  Core's data directory as a path>  configSet
  If set, the name of the configset to use to configure the core (see Config Sets).
  properties

  The name of the properties file for this core. The value can be an absolute pathname or a path>  transient
  If true, the core can be unloaded if Solr reaches the transientCacheSize. The default if not specified is false. Cores are unloaded in order of least recently used first.
  loadOnStartup
  If true, the default if it is not specified, the core will loaded when Solr starts.
  coreNodeName
  Added in Solr 4.2, this attributes allows naming a core. The name can then be used later if you need to replace a machine with a new one. By assigning the new machine the same coreNodeName as the old core, it will take over for the old SolrCore.
  ulogDir

  The absolute or>  shard
  The shard to assign this core to (SolrCloud)
  collection
  The name of the collection this core is part of (SolrCloud)
  roles
  Future param for SolrCloud or a way for users to mark nodes for their own use.
  使用Collections API:CREATE来创建collection时需要符合下面的条件。
  shards*replicationFactor <= maxShardsPerNode*Node数
  http://192.168.137.171:8080/solr-cloud/admin/collections?action=CREATE&name=myc&numShards=2&replicationFactor=3&maxShardsPerNode=2
DSC0000.png

  http://192.168.137.171:8080/solr-cloud/admin/collections?action=CREATE&name=myc2&numShards=2&replicationFactor=2&maxShardsPerNode=2&createNodeSet=192.168.137.171:8080_solr-cloud,192.168.137.172:8080_solr-cloud
DSC0001.png

  http://192.168.137.171:8080/solr-cloud/admin/collections?action=CREATE&name=myc3&router.name=implicit&shards=shard1,shard2&replicationFactor=3&maxShardsPerNode=3
DSC0002.png

  指定配置文件
  http://192.168.137.171:8080/solr-cloud/admin/collections?action=CREATE&name=myc2&numShards=2&replicationFactor=3&maxShardsPerNode=2&collection.configName=myconf2&property.config=solrconfig2.xml&property.schema=schema2.xml
DSC0003.png

DSC0004.png

  2.删除collection
  http://192.168.137.171:8080/solr-cloud/admin/collections?action=DELETE&name=myc2
DSC0005.png

  3.RELOAD collection
  如果schema中的属性有变动,只需要将正确的schema上传到服务器上之后重启solr即可
  http://192.168.137.171:8080/solr-cloud/admin/collections?action=RELOAD&name=myc
  4. SPLITSHARD(纵向扩容)
  使用Collections API:SPLITSHARD来创建SHARD时不需要符合下面的条件。
  shards*replicationFactor <= maxShardsPerNode*Node数
  整体逻辑:无缝连接和无downtime
  旧shard此时继续提供服务并把旧索引转到新的shard上
  旧shard同时继续索引新文档
  旧shard同时把新文档转发给新shard,新shard索引新文档
  旧索引全部迁移到新shard之后,旧shard关闭,新文档直接转发到新的shard上了
  手动利用DELETESHARD API删除旧shard
  implicit路由:只要创建Shard即可: 新建索引时,将索引建到新建Shard上,查询操作时,指定collection名称,得到的仍是整个集群返回的结果。
  compositeId路由:通过分裂(SPLITSHARD)操作实现。
  http://192.168.137.171:8080/solr-cloud/admin/collections?action=SPLITSHARD&collection=myc&shard=shard1
DSC0006.png

  5.CREATESHARD

路由规则为implicit 时才可以使用。
  使用Collections API:CREATESHARD来创建shard时需要符合下面的条件。
  shards*replicationFactor <= maxShardsPerNode*Node数
  http://192.168.137.171:8080/solr-cloud/admin/collections?action=CREATESHARD&collection=myc3&shard=shard3
DSC0007.png

  6. DELETESHARD
  删除inactive shard
  http://192.168.137.171:8080/solr-cloud/admin/collections?action=DELETESHARD&collection=myc2&shard=shard1
DSC0008.png

  7.CREATEALIAS
  实现跨collection查询,新建和修改都是使用CREATEALIAS。
  http://192.168.137.171:8080/solr-cloud/admin/collections?action=CREATEALIAS&name=newc&collections=myc,myc2
DSC0009.png

  8.DELETEALIAS
  http://192.168.137.171:8080/solr-cloud/admin/collections?action=DELETEALIAS&name=newc
DSC00010.png

  9.DELETEREPLICA
  

http://192.168.137.171:8080/solr-cloud/admin/collections?action=DELETEREPLICA&collection=myc2&shard=shard2&replica=192.168.137.171:8080_solr-cloud_myc2_shard2_replica2  

DSC00011.png   

  

10.ADDREPLICA  

http://192.168.137.171:8080/solr-cloud/admin/collections?action=ADDREPLICA&collection=myc2&shard=shard2&node=192.168.137.171:8080_solr-cloud  

DSC00012.png

  使用Collections API:ADDREPLICA来创建replica时不需要符合下面的条件。
  shards*replicationFactor <= maxShardsPerNode*Node数

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-426025-1-1.html 上篇帖子: sorl教程 下篇帖子: SolrCloud部署和使用手册
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表