solr cloud zk管理
Posted sxhong
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了solr cloud zk管理相关的知识,希望对你有一定的参考价值。
1.ZK CLI
ZooKeeper's Command Line Utility (CLI).
zkcli
Parameters
Short |
Parameter Usage |
Meaning |
---|---|---|
|
| CLI Command to be executed: |
|
| ZooKeeper host address. |
|
| For |
|
| For |
|
| Display help text. |
|
| For |
|
| Run ZooKeeper internally by passing the Solr run port; only for clusters on one machine. |
|
| For |
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。
以上是关于solr cloud zk管理的主要内容,如果未能解决你的问题,请参考以下文章