Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download Solr collection config from zookeeper

I have a collection in solrcloud which had been created using zookeeper managed configuration and I want all collection configuration files which were used to create the collection. Here are the options I found:

  1. Copy manually all files from Solrcloud UI.

    solrUI->cloud->tree->/collections/<collection-name>

  2. Download files from zookeeper

    /opt/solr/server/scripts/cloud-scripts/zkcli.sh -cmd downconfig -zkhost <zk hosts>/usecasedir -confname <configuration name> -confdir <dir to download>

2nd option would save my lot of time but the problem here my zookeeper has huge list of configurations and I am not sure which configuration directory was used to create collection.

Is there any way to figure out which collection configuration was used to create collection?

like image 885
Rahul Sharma Avatar asked Jan 04 '23 23:01

Rahul Sharma


1 Answers

the info of what config was used to create a collection is stored in zk itself. Some bash scripting (using the great jq utility) is enough to do what you need:

  1. find what config was used for the given XXX collection:

    CONFIGNAME=$(curl -L -s "http://localhost:8983/solr/admin/zookeeper?detail=true&path=/collections/XXX" | jq '.znode.data' | cut -d ":" -f2 | tr -d '}"\\') 
    
  2. now download the config:

    /opt/solr/bin/solr zk downconfig -n $CONFIGNAME -d config$CONFIGNAME -z localhost:2181 
    
like image 50
Persimmonium Avatar answered Jan 18 '23 10:01

Persimmonium