solr cloud zk管理

1.ZK CLI

ZooKeeper's Command Line Utility (CLI).

zkcli Parameters

Short

Parameter Usage

Meaning

 

-cmd <arg>

CLI Command to be executed: bootstrapupconfigdownconfiglinkconfigmakepathgetgetfileput,putfilelist or clear
This parameter is mandatory

-z

-zkhost <locations>

ZooKeeper host address. 
This parameter is mandatory for all CLI commands.

-c

-collection <name>

For linkconfig: name of the collection.

-d

-confdir <path>

For upconfig: a directory of configuration files.

-h

-help

Display help text.

-n

-confname <arg>

For upconfiglinkconfig: name of the configuration set.

-r

-runzk <port>

Run ZooKeeper internally by passing the Solr run port; only for clusters on one machine.

-s

-solrhome <path>

For bootstrap or when using -runzk: the mandatory solrhome location.

ZooKeeper CLI Examples

Below are some examples of using the zkcli CLI:
Uploading a Configuration Directory

java -classpath example/solr-webapp/WEB-INF/lib/*
org.apache.solr.cloud.ZkCLI -cmd upconfig -zkhost 127.0.0.1:9983
-confdir example/solr/collection1/conf -confname conf1 -solrhome example/solr

Put arbitrary data into a new ZK file

java -classpath example/solr-webapp/WEB-INF/lib/*
org.apache.solr.cloud.ZkCLI -zkhost 127.0.0.1:9983 -put /data.txt 'some data'

Put a local file into a new ZK file

java -classpath example/solr-webapp/WEB-INF/lib/*
org.apache.solr.cloud.ZkCLI -zkhost 127.0.0.1:9983 -putfile /data.txt /some/local/file.txt

Linking a Collection to a Configuration Set

java -classpath example/solr-webapp/webapp/WEB-INF/lib/*
org.apache.solr.cloud.ZkCLI -cmd linkconfig -zkhost 127.0.0.1:9983
-collection collection1 -confname conf1 -solrhome example/solr

Bootstrapping All the Configuration Directories in solr.xml

java -classpath example/solr-webapp/webapp/WEB-INF/lib/*
org.apache.solr.cloud.ZkCLI -cmd bootstrap -zkhost 127.0.0.1:9983
-solrhome example/solr

Scripts

There are scripts in /solr-7.2.1/server/scripts/cloud-scripts/zkcli.sh that handle the classpath and class name for you if you are using Solr out of the box with Jetty. Commands then become:

sh zkcli.sh -cmd linkconfig -zkhost 127.0.0.1:9983
-collection collection1 -confname conf1 -solrhome example/solr

 

 

2.Managing collections via the collections API

CREATE---

http://localhost:8983/solr/admin/collections?action=CREATE&name=mycollection&numShards=3&replicationFactor=4

name:collection的名称

numShards:指定分片数量(slices)

replicationFactor:副本数量

maxShardsPerNode:默认值为1,注意三个数值:numShards、replicationFactor、liveSolrNode,一个正常的solrCloud集群不容许同一个liveSolrNode上部署同一个shard的多个replic,因此当maxShardsPerNode=1时,numShards*replicationFactor>liveSolrNode时,报错。因此正确时因满足以下条件:
numShards*replicationFactor<liveSolrNode*maxShardsPerNode

createNodeSet:

collection.configName:指定该collection使用那份config,这份config必须存在于zk中。

DELETE---

http://localhost:8983/solr/admin/collections?action=DELETE&name=mycollection

RELOAD---

http://localhost:8983/solr/admin/collections?action=RELOAD&name=mycollection

SPLIT SHARD---

http://localhost:8983/solr/admin/collections?action=SPLITSHARD&collection=<collection_name>&shard=shardId

 

3.Creating cores via CoreAdmin

curl 'http://localhost:8983/solr/admin/cores?action=CREATE&name=mycore&collection=collection1&shard=shard2'

 

 

-------------------------------

Q1:Multiple schemas in the same SolrCloud ?

java -classpath .:/home/solrcloud/solr-lib/* org.apache.solr.cloud.ZkCLI -cmd upconfig -zkhost 10.200.51.190:2224,10.200.51.192:2224,10.200.51.194:2224 -confdir /home/solrcloud/fox-config-files/ -confname foxconf

指定配置文件,上传到zk。

curl 'http://10.200.51.194:2223/solr/admin/collections?action=CREATE&name=fox4&numShards=1&replicationFactor=5&collection.configName=foxconf'

为创建的collection指定collection.configName。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值