Example solrctl Usage

This topic includes some examples of:
  • Configuration changes that may be required for solrctl to function as desired.
  • Common tasks completed with solrctl.

Using solrctl with an HTTP proxy

Using solrctl to manage a deployment in an environment that uses an http_proxy fails because solrctl uses curl, which attempts to use the web proxy. You can disable the proxy so solrctl succeeds:

  • Modify the settings for the current shell by exporting the NO_PROXY. For example:
    $ export NO_PROXY='*'
  • Modify the settings for single commands by prefacing solrctl commands with NO_PROXY='*'. For example:
    $ NO_PROXY='*' solrctl collection --create yourCollectionName

Adding Another Collection with Replication

To support scaling for the query load, create a second collection with replication. Having multiple servers with replicated collections distributes the request load for each shard. Create one shard cluster with a replication factor of two. Your cluster must have at least two running servers to support this configuration, so ensure Cloudera Search is installed on at least two servers. A replication factor of two causes two copies of the index files to be stored in two different locations.

  1. Generate the config files for the collection:
    $ solrctl instancedir --generate $HOME/solr_configs2
  2. Upload the instance directory to ZooKeeper:
    $ solrctl instancedir --create collection1 $HOME/solr_configs2
  3. Create the second collection:
    $ solrctl collection --create collection1 -s 1 -r 2
  4. Verify that the collection is live and that the one shard is served by two hosts. For example, for the server myhost.example.com, you should receive content from: http://myhost.example.com:8983/solr/#/~cloud.

Creating Replicas of Existing Shards

You can create additional replicas of existing shards using a command of the following form:

$ solrctl --zk <zkensemble> --solr <target solr server> core \
--create <new core name> -p collection=<collection> -p shard=<shard to replicate>

For example to create a new replica of collection named collection1 that is comprised of shard1, use the following command:

$ solrctl --zk myZKEnsemble:2181/solr --solr mySolrServer:8983/solr core \
--create collection1_shard1_replica2 -p collection=collection1 -p shard=shard1

Converting instancedirs to configs

Cloudera Search supports converting existing deployments that use instancedirs to use configs.

To modify a collection to use configs
  1. Make note of the existing instancedir name. This information is required later. For example, myConfig.
  2. Delete the existing instancedir. For example:
    solrctl instancedir --delete myConfig
  3. Create a config using the same name as the instancedir you just deleted.
    solrctl config --create myConfig baseConfig -p immutable=false
  4. Reload the affected collection.