solrctl Reference

Use the solrctl utility to manage a SolrCloud deployment. You can manipulate SolrCloud collections, SolrCloud collection instance directories, and individual cores.

In general, if an operation succeeds, solrctl exits silently with a success exit code. If an error occurs, solrctl prints a diagnostics message combined with a failure exit code.

You can execute solrctl on any host that is configured as part of the SolrCloud. To execute any solrctl command on a host outside of SolrCloud deployment, ensure that SolrCloud hosts are reachable and provide --zk and --solr command line options.

If you are using solrctl to manage your deployment in an environment that requires Kerberos authentication, you must have a valid Kerberos ticket, which you can get using kinit.

You can see examples of using solrctl in Deploying Cloudera Search.

For collection configuration, users have the option of interacting directly with ZooKeeper using the instancedir option or using Solr's ConfigSet API using the config option. For more information on this topic, see Understanding configs and instancedirs.

Syntax

You can initialize the state of the entire SolrCloud deployment and each individual host within the SolrCloud deployment by using solrctl. The general solrctl command syntax is:

solrctl [options] command [command-arg] [command [command-arg]] ...

Each element and its possible values are described in the following sections.

Options

If used, the following options must precede commands:
  • --solr solr_uri: Directs solrctl to a SolrCloud web API available at a given URI. This option is required for hosts running outside of SolrCloud. A sample URI might be: http://host1.cluster.com:8983/solr.
  • --zk zk_ensemble: Directs solrctl to a particular ZooKeeper coordination service ensemble. This option is required for hosts running outside of SolrCloud. For example: host1.cluster.com:2181,host2.cluster.com:2181/solr.
  • --jaas jaas.conf: Used to identify a JAAS configuration that specifies the principal with permissions to modify solr metadata. The principal is typically "solr". In a Kerberos-enabled environment where solr metadata is protected using ZooKeeper ACLs, modifying metadata using solrctl requires this parameter.
  • --help: Prints help.
  • --quiet: Suppresses most solrctl messages.

Commands

The solrctl commands init, instancedir, config, collection, core, and cluster affect the entire SolrCloud deployment and are executed only once per required operation.

The solrctl core command affects a single SolrCloud host.

  • init [--force]: The init command, which initializes the overall state of the SolrCloud deployment, must be executed before starting solr-server daemons for the first time. Use this command cautiously because it erases all SolrCloud deployment state information. After successful initialization, you cannot recover any previous state.
  • instancedir [--generate path [-schemaless]] [--create name path] [--update name path] [--get name path] [--delete name] [--list]: Manipulates the instance directories. The following options are supported:
    • --generate path: Allows users to generate the template of the instance directory. The template is stored at a designated path in a local filesystem and has configuration files under ./conf.
    • --create name path: Pushes a copy of the instance directory from the local filesystem to SolrCloud. If an instance directory is already available to SolrCloud, this command fails. See --update for changing name paths that already exist.
    • --update name path: Updates an existing SolrCloud copy of an instance directory based on the files in a local filesystem. This command is analogous to first using --delete name followed by --create name path.
    • --get name path: Downloads the named collection instance directory at a specified path in a local filesystem. Once downloaded, files can be further edited.
    • --delete name: Deletes the instance directory name from SolrCloud.
    • --list: Prints a list of all available instance directories known to SolrCloud.
  • config [--create name baseConfig [-p name=value]...] [--delete name]: Manipulates configs. The following options are supported:
    • --create name baseConfig [-p name=value]...: Creates a new config based on an existing config. The config is created with the specified name, using baseConfig as the template. -p can be used to override a baseConfig setting. immutable is the only property that supports override. For more information on existing templates, see Included Immutable Config Templates.
    • --delete name: Deletes a config.
  • collection [--create name -s <numShards> [-c <collection.configName>] [-r <replicationFactor>] [-m <maxShardsPerHost>] [-n <createHostSet>]] [--delete name] [--reload name] [--stat name] [--list] [--deletedocs name]: Manipulates collections. The following options are supported:
    • --create name -s <numShards> [-a] [-c <collection.configName>] [-r <replicationFactor>] [-m <maxShardsPerHost>] [-n <createHostSet>]]: Creates a new collection.

      New collections are given the specified name, and are sharded to <numShards>.

      The -a option configures auto-addition of replicas if machines hosting existing shards become unavailable.

      SolrCloud hosts are configured using the <collection.configName> instance directory. Replication is configured by a factor of <replicationFactor>. The maximum shards per host is determined by <maxShardsPerHost>, and the collection is allocated to the hosts specified in <createHostSet>.

      The only required parameters are name and numShards. If collection.configName is not provided, it is assumed to be the same as the name of the collection.

    • --delete name: Deletes a collection.
    • --reload name: Reloads a collection.
    • --stat name: Outputs SolrCloud specific run-time information for a collection.
    • --list: Lists all collections registered in SolrCloud.
    • --deletedocs name: Purges all indexed documents from a collection.
  • core [--create name [-p name=value]...] [--reload name] [--unload name] [--status name]: Manipulates cores. This is one of two commands that you can execute on a particular SolrCloud host. The following options are supported:
    • --create name [-p name=value]...: Creates a new core on a specified SolrCloud host. The core is configured using name=values pairs. For more details on configuration options, see Solr documentation.
    • --reload name: Reloads a core.
    • --unload name: Unloads a core.
    • --status name: Prints status of a core.
  • cluster [--get-solrxml file] [--put-solrxml file] [--set-property name value] [--remove-property name] : Manages cluster configuration. The following options are supported:
    • --get-solrxml file: Downloads the cluster configuration file solr.xml from ZooKeeper to the local system.
    • --put-solrxml file: Uploads the specified file to ZooKeeper as the cluster configuration file solr.xml.
    • [--set-property name value]: Sets property names and values. Typically used in a deployment that is not managed by Cloudera Manager. For example, to configure a cluster to use TLS/SSL, you might use a command of the form:
      solrctl --zk <solr_zk_conf> cluster --set-property urlScheme https
    • [--remove-property name]: Removes properties.