This is the documentation for Cloudera Enterprise 5.8.x. Documentation for other versions is available at Cloudera Documentation.

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.

Continue reading:

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

Adding a New Shard to a Solr Server

You can use solrctl to add a new shard to a specified solr server.

$ solrctl --solr http://<target_solr_server>:8983/solr core --create <core_name> \
-p dataDir=hdfs://<nameservice>/<index_hdfs_path> -p collection.configName=<config_name> \
-p collection=<collection_name> -p numShards=<int> -p shard=<shard_id>

Where:

  • target_solr_server: The server to host the new shard
  • core_name: <collection_name><shard_id><replica_id>
  • shard_id: New shard identifier

For example, to add a new second shard named shard2 to a solr server named mySolrServer, where the collection is named myCollection, you would use the following command:

$ solrctl --solr http://mySolrServer:8983/solr core --create myCore \
-p dataDir=hdfs://namenode/solr/myCollection/index -p collection.configName=myConfig \
-p collection=myCollection -p numShards=2 -p shard=shard2

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.
Page generated July 8, 2016.