Rahul Sharma
Rahul Sharma

Reputation: 5834

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?

Upvotes: 4

Views: 7709

Answers (2)

Persimmonium
Persimmonium

Reputation: 15791

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 
    

Upvotes: 7

Gus
Gus

Reputation: 6871

Sets of configuration are usually found in a directory called /configs. If the zookeeper is dedicated to solr this is usually at the top level, if it's used by multiple applications it's common to "zk chroot" the configs to a sub directory.

Once you find the right location in zookeeper, one directory in the configs directory should match the name shown as "config-name" in the admin UI under Collections > name_of_your_collection

If your project uses gradle, the up/down load of configs from the project (where you might want to check these things into version control) can be smoothed somewhat by a plugin (disclaimer: I wrote this plugin)

https://plugins.gradle.org/plugin/com.needhamsoftware.solr-gradle

There's an additional complication to be aware of however, if the collection is using managed schema, the acutal schema in use will not be in schema.xml, but in a file called "managed-schema"

Fields may have been added via the Schema Rest API, so "files used to create the collection" is a bit fuzzy in that respect, but the managed_schema can be renamed to schema.xml and the solr config modified to take things out of managed mode if you want.

Upvotes: 2

Related Questions