Solr Control Script Reference

Solr includes a script known as “bin/solr” that allows you to perform many common operations on your Solr installation or cluster.

You can start and stop Solr, create and delete collections or cores, perform operations on ZooKeeper and check the status of Solr and configured shards.

You can find the script in the bin/ directory of your Solr installation. The bin/solr script makes Solr easier to work with by providing simple commands and options to quickly accomplish common goals.

More examples of bin/solr in use are available throughout the Solr Reference Guide, but particularly in the sections Running Solr and Getting Started with SolrCloud.

Starting and Stopping

Start and Restart

The start command starts Solr. The restart command allows you to restart Solr while it is already running or if it has been stopped already.

The start and restart commands have several options to allow you to run in SolrCloud mode, use an example configuration set, start with a hostname or port that is not the default and point to a local ZooKeeper ensemble.

bin/solr start [options]

bin/solr start -help

bin/solr restart [options]

bin/solr restart -help

When using the restart command, you must pass all of the parameters you initially passed when you started Solr. Behind the scenes, a stop request is initiated, so Solr will be stopped before being started again. If no nodes are already running, restart will skip the step to stop and proceed to starting Solr.

Available Parameters

The`bin/solr` script provides many options to allow you to customize the server in common ways, such as changing the listening port. However, most of the defaults are adequate for most Solr installations, especially when just getting started.

Parameter Description Example

-a "<string>"

Start Solr with additional JVM parameters, such as those starting with -X. If you are passing JVM parameters that begin with "-D", you can omit the -a option.

bin/solr start -a "-Xdebug -Xrunjdwp:transport=dt_socket, server=y,suspend=n,address=1044"

-cloud

Start Solr in SolrCloud mode, which will also launch the embedded ZooKeeper instance included with Solr.

This option can be shortened to simply -c.

If you are already running a ZooKeeper ensemble that you want to use instead of the embedded (single-node) ZooKeeper, you should also pass the -z parameter.

For more details, see the section SolrCloud Mode below.

bin/solr start -c

-d <dir>

Define a server directory, defaults to server (as in, $SOLR_HOME/server). It is uncommon to override this option. When running multiple instances of Solr on the same host, it is more common to use the same server directory for each instance and use a unique Solr home directory using the -s option.

bin/solr start -d newServerDir

-e <name>

Start Solr with an example configuration. These examples are provided to help you get started faster with Solr generally, or just try a specific feature.

The available options are:

  • cloud

  • techproducts

  • dih

  • schemaless

See the section Running with Example Configurations below for more details on the example configurations.

bin/solr start -e schemaless

-f

Start Solr in the foreground; you cannot use this option when running examples with the -e option.

bin/solr start -f

-h <hostname>

Start Solr with the defined hostname. If this is not specified, 'localhost' will be assumed.

bin/solr start -h search.mysolr.com

-m <memory>

Start Solr with the defined value as the min (-Xms) and max (-Xmx) heap size for the JVM.

bin/solr start -m 1g

-noprompt

Start Solr and suppress any prompts that may be seen with another option. This would have the side effect of accepting all defaults implicitly.

For example, when using the "cloud" example, an interactive session guides you through several options for your SolrCloud cluster. If you want to accept all of the defaults, you can simply add the -noprompt option to your request.

bin/solr start -e cloud -noprompt

-p <port>

Start Solr on the defined port. If this is not specified, '8983' will be used.

bin/solr start -p 8655

-s <dir>

Sets the solr.solr.home system property; Solr will create core directories under this directory. This allows you to run multiple Solr instances on the same host while reusing the same server directory set using the -d parameter. If set, the specified directory should contain a solr.xml file, unless solr.xml exists in ZooKeeper. The default value is server/solr.

This parameter is ignored when running examples (-e), as the solr.solr.home depends on which example is run.

bin/solr start -s newHome

-v

Be more verbose. This changes the logging level of log4j from INFO to DEBUG, having the same effect as if you edited log4j.properties accordingly.

bin/solr start -f -v

-q

Be more quiet. This changes the logging level of log4j from INFO to WARN, having the same effect as if you edited log4j.properties accordingly. This can be useful in a production setting where you want to limit logging to warnings and errors.

bin/solr start -f -q

-V

Start Solr with verbose messages from the start script.

bin/solr start -V

-z <zkHost>

Start Solr with the defined ZooKeeper connection string. This option is only used with the -c option, to start Solr in SolrCloud mode. If this option is not provided, Solr will start the embedded ZooKeeper instance and use that instance for SolrCloud operations.

bin/solr start -c -z server1:2181,server2:2181

-force

If attempting to start Solr as the root user, the script will exit with a warning that running Solr as "root" can cause problems. It is possible to override this warning with the -force parameter.

sudo bin/solr start -force

To emphasize how the default settings work take a moment to understand that the following commands are equivalent:

bin/solr start

bin/solr start -h localhost -p 8983 -d server -s solr -m 512m

It is not necessary to define all of the options when starting if the defaults are fine for your needs.

Setting Java System Properties

The bin/solr script will pass any additional parameters that begin with -D to the JVM, which allows you to set arbitrary Java system properties.

For example, to set the auto soft-commit frequency to 3 seconds, you can do:

bin/solr start -Dsolr.autoSoftCommit.maxTime=3000

SolrCloud Mode

The -c and -cloud options are equivalent:

bin/solr start -c

bin/solr start -cloud

If you specify a ZooKeeper connection string, such as -z 192.168.1.4:2181, then Solr will connect to ZooKeeper and join the cluster.

If you do not specify the -z option when starting Solr in cloud mode, then Solr will launch an embedded ZooKeeper server listening on the Solr port + 1000, i.e., if Solr is running on port 8983, then the embedded ZooKeeper will be listening on port 9983.

If your ZooKeeper connection string uses a chroot, such as localhost:2181/solr, then you need to create the /solr znode before launching SolrCloud using the bin/solr script.

+ To do this use the mkroot command outlined below, for example: bin/solr zk mkroot /solr -z 192.168.1.4:2181

When starting in SolrCloud mode, the interactive script session will prompt you to choose a configset to use.

For more information about starting Solr in SolrCloud mode, see also the section Getting Started with SolrCloud.

Running with Example Configurations

bin/solr start -e <name>

The example configurations allow you to get started quickly with a configuration that mirrors what you hope to accomplish with Solr.

Each example launches Solr with a managed schema, which allows use of the Schema API to make schema edits, but does not allow manual editing of a Schema file If you would prefer to manually modify a schema.xml file directly, you can change this default as described in the section Schema Factory Definition in SolrConfig.

Unless otherwise noted in the descriptions below, the examples do not enable SolrCloud nor schemaless mode.

The following examples are provided:

  • cloud: This example starts a 1-4 node SolrCloud cluster on a single machine. When chosen, an interactive session will start to guide you through options to select the initial configset to use, the number of nodes for your example cluster, the ports to use, and name of the collection to be created. When using this example, you can choose from any of the available configsets found in $SOLR_HOME/server/solr/configsets.

  • techproducts: This example starts Solr in standalone mode with a schema designed for the sample documents included in the $SOLR_HOME/example/exampledocs directory. The configset used can be found in $SOLR_HOME/server/solr/configsets/sample_techproducts_configs.

  • dih: This example starts Solr in standalone mode with the DataImportHandler (DIH) enabled and several example dataconfig.xml files pre-configured for different types of data supported with DIH (such as, database contents, email, RSS feeds, etc.). The configset used is customized for DIH, and is found in $SOLR_HOME/example/example-DIH/solr/conf. For more information about DIH, see the section Uploading Structured Data Store Data with the Data Import Handler.

  • schemaless: This example starts Solr in standalone mode using a managed schema, as described in the section Schema Factory Definition in SolrConfig, and provides a very minimal pre-defined schema. Solr will run in Schemaless Mode with this configuration, where Solr will create fields in the schema on the fly and will guess field types used in incoming documents. The configset used can be found in $SOLR_HOME/server/solr/configsets/data_driven_schema_configs.

The run in-foreground option (-f) is not compatible with the -e option since the script needs to perform additional tasks after starting the Solr server.

Stop

The stop command sends a STOP request to a running Solr node, which allows it to shutdown gracefully. The command will wait up to 5 seconds for Solr to stop gracefully and then will forcefully kill the process (kill -9).

bin/solr stop [options]

bin/solr stop -help

Available Parameters

Parameter Description Example

-p <port>

Stop Solr running on the given port. If you are running more than one instance, or are running in SolrCloud mode, you either need to specify the ports in separate requests or use the -all option.

bin/solr stop -p 8983

-all

Stop all running Solr instances that have a valid PID.

bin/solr stop -all

-k <key>

Stop key used to protect from stopping Solr inadvertently; default is "solrrocks".

bin/solr stop -k solrrocks

System Information

Version

The version command simply returns the version of Solr currently installed and immediately exists.

$ bin/solr version
X.Y.0

Status

The status command displays basic JSON-formatted information for any Solr nodes found running on the local system.

The status command uses the SOLR_PID_DIR environment variable to locate Solr process ID files to find running Solr instances, which defaults to the bin directory.

bin/solr status

The output will include a status of each node of the cluster, as in this example:

Found 2 Solr nodes:

Solr process 39920 running on port 7574
{
  "solr_home":"/Applications/Solr/example/cloud/node2/solr/",
  "version":"X.Y.0",
  "startTime":"2015-02-10T17:19:54.739Z",
  "uptime":"1 days, 23 hours, 55 minutes, 48 seconds",
  "memory":"77.2 MB (%15.7) of 490.7 MB",
  "cloud":{
    "ZooKeeper":"localhost:9865",
    "liveNodes":"2",
    "collections":"2"}}

Solr process 39827 running on port 8865
{
  "solr_home":"/Applications/Solr/example/cloud/node1/solr/",
  "version":"X.Y.0",
  "startTime":"2015-02-10T17:19:49.057Z",
  "uptime":"1 days, 23 hours, 55 minutes, 54 seconds",
  "memory":"94.2 MB (%19.2) of 490.7 MB",
  "cloud":{
    "ZooKeeper":"localhost:9865",
    "liveNodes":"2",
    "collections":"2"}}

Healthcheck

The healthcheck command generates a JSON-formatted health report for a collection when running in SolrCloud mode. The health report provides information about the state of every replica for all shards in a collection, including the number of committed documents and its current state.

bin/solr healthcheck [options]

bin/solr healthcheck -help

Available Parameters

Parameter Description Example

-c <collection>

Name of the collection to run a healthcheck against (required).

bin/solr healthcheck -c gettingstarted

-z <zkhost>

ZooKeeper connection string, defaults to localhost:9983. If you are running Solr on a port other than 8983, you will have to specify the ZooKeeper connection string. By default, this will be the Solr port + 1000.

bin/solr healthcheck -z localhost:2181

Below is an example healthcheck request and response using a non-standard ZooKeeper connect string, with 2 nodes running:

$ bin/solr healthcheck -c gettingstarted -z localhost:9865

{
  "collection":"gettingstarted",
  "status":"healthy",
  "numDocs":0,
  "numShards":2,
  "shards":[
    {
      "shard":"shard1",
      "status":"healthy",
      "replicas":[
        {
          "name":"core_node1",
          "url":"http://10.0.1.10:8865/solr/gettingstarted_shard1_replica2/",
          "numDocs":0,
          "status":"active",
          "uptime":"2 days, 1 hours, 18 minutes, 48 seconds",
          "memory":"25.6 MB (%5.2) of 490.7 MB",
          "leader":true},
        {
          "name":"core_node4",
          "url":"http://10.0.1.10:7574/solr/gettingstarted_shard1_replica1/",
          "numDocs":0,
          "status":"active",
          "uptime":"2 days, 1 hours, 18 minutes, 42 seconds",
          "memory":"95.3 MB (%19.4) of 490.7 MB"}]},
    {
      "shard":"shard2",
      "status":"healthy",
      "replicas":[
        {
          "name":"core_node2",
          "url":"http://10.0.1.10:8865/solr/gettingstarted_shard2_replica2/",
          "numDocs":0,
          "status":"active",
          "uptime":"2 days, 1 hours, 18 minutes, 48 seconds",
          "memory":"25.8 MB (%5.3) of 490.7 MB"},
        {
          "name":"core_node3",
          "url":"http://10.0.1.10:7574/solr/gettingstarted_shard2_replica1/",
          "numDocs":0,
          "status":"active",
          "uptime":"2 days, 1 hours, 18 minutes, 42 seconds",
          "memory":"95.4 MB (%19.4) of 490.7 MB",
          "leader":true}]}]}

Collections and Cores

The bin/solr script can also help you create new collections (in SolrCloud mode) or cores (in standalone mode), or delete collections.

Create

The create command detects the mode that Solr is running in (standalone or SolrCloud) and then creates a core or collection depending on the mode.

bin/solr create [options]

bin/solr create -help

Available Parameters

Parameter Description Example

-c <name>

Name of the core or collection to create (required).

bin/solr create -c mycollection

-d <confdir>

The configuration directory. This defaults to data_driven_schema_configs.

See the section Configuration Directories and SolrCloud below for more details about this option when running in SolrCloud mode.

bin/solr create -d basic_configs

-n <configName>

The configuration name. This defaults to the same name as the core or collection.

bin/solr create -n basic

-p <port>

Port of a local Solr instance to send the create command to; by default the script tries to detect the port by looking for running Solr instances.

This option is useful if you are running multiple standalone Solr instances on the same host, thus requiring you to be specific about which instance to create the core in.

bin/solr create -p 8983

-s <shards>

-shards

Number of shards to split a collection into, default is 1; only applies when Solr is running in SolrCloud mode.

bin/solr create -s 2

-rf <replicas>

-replicationFactor

Number of copies of each document in the collection. The default is 1 (no replication).

bin/solr create -rf 2

-force

If attempting to run create as "root" user, the script will exit with a warning that running Solr or actions against Solr as "root" can cause problems. It is possible to override this warning with the -force parameter.

bin/solr create -c foo -force

Configuration Directories and SolrCloud

Before creating a collection in SolrCloud, the configuration directory used by the collection must be uploaded to ZooKeeper. The create command supports several use cases for how collections and configuration directories work. The main decision you need to make is whether a configuration directory in ZooKeeper should be shared across multiple collections.

Let’s work through a few examples to illustrate how configuration directories work in SolrCloud.

First, if you don’t provide the -d or -n options, then the default configuration ($SOLR_HOME/server/solr/configsets/data_driven_schema_configs/conf) is uploaded to ZooKeeper using the same name as the collection. For example, the following command will result in the data_driven_schema_configs configuration being uploaded to /configs/contacts in ZooKeeper: bin/solr create -c contacts. If you create another collection, by doing bin/solr create -c contacts2, then another copy of the data_driven_schema_configs directory will be uploaded to ZooKeeper under /configs/contacts2. Any changes you make to the configuration for the contacts collection will not affect the contacts2 collection. Put simply, the default behavior creates a unique copy of the configuration directory for each collection you create.

You can override the name given to the configuration directory in ZooKeeper by using the -n option. For instance, the command bin/solr create -c logs -d basic_configs -n basic will upload the server/solr/configsets/basic_configs/conf directory to ZooKeeper as /configs/basic.

Notice that we used the -d option to specify a different configuration than the default. Solr provides several built-in configurations under server/solr/configsets. However you can also provide the path to your own configuration directory using the -d option. For instance, the command bin/solr create -c mycoll -d /tmp/myconfigs, will upload /tmp/myconfigs into ZooKeeper under /configs/mycoll . To reiterate, the configuration directory is named after the collection unless you override it using the -n option.

Other collections can share the same configuration by specifying the name of the shared configuration using the -n option. For instance, the following command will create a new collection that shares the basic configuration created previously: bin/solr create -c logs2 -n basic.

Data-driven Schema and Shared Configurations

The data_driven_schema_configs schema can mutate as data is indexed. Consequently, we recommend that you do not share data-driven configurations between collections unless you are certain that all collections should inherit the changes made when indexing data into one of the collections.

Delete

The delete command detects the mode that Solr is running in (standalone or SolrCloud) and then deletes the specified core (standalone) or collection (SolrCloud) as appropriate.

bin/solr delete [options]

bin/solr delete -help

If running in SolrCloud mode, the delete command checks if the configuration directory used by the collection you are deleting is being used by other collections. If not, then the configuration directory is also deleted from ZooKeeper. For example, if you created a collection by doing bin/solr create -c contacts, then the delete command bin/solr delete -c contacts will check to see if the /configs/contacts configuration directory is being used by any other collections. If not, then the /configs/contacts directory is removed from ZooKeeper.

Available Parameters

Parameter Description Example

-c <name>

Name of the core / collection to delete (required).

bin/solr delete -c mycoll

-deleteConfig <true|false>

Delete the configuration directory from ZooKeeper. The default is true.

If the configuration directory is being used by another collection, then it will not be deleted even if you pass -deleteConfig as true.

bin/solr delete -deleteConfig false

-p <port>

The port of a local Solr instance to send the delete command to. By default the script tries to detect the port by looking for running Solr instances.

This option is useful if you are running multiple standalone Solr instances on the same host, thus requiring you to be specific about which instance to delete the core from.

bin/solr delete -p 8983

Authentication

The bin/solr script allows enabling or disabling Basic Authentication, allowing you to configure authentication from the command line.

Currently, this script only enables Basic Authentication, and is only available when using SolrCloud mode.

Enabling Basic Authentication

The command bin/solr auth enable configures Solr to use Basic Authentication when accessing the User Interface, using bin/solr and any API requests.

For more information about Solr’s authentication plugins, see the section Securing Solr. For more information on Basic Authentication support specifically, see the section Basic Authentication Plugin.

The bin/solr auth enable command makes several changes to enable Basic Authentication:

  • Creates a security.json file and uploads it to ZooKeeper. The security.json file will look similar to:

    {
      "authentication":{
       "blockUnknown": false,
       "class":"solr.BasicAuthPlugin",
       "credentials":{"user":"vgGVo69YJeUg/O6AcFiowWsdyOUdqfQvOLsrpIPMCzk= 7iTnaKOWe+Uj5ZfGoKKK2G6hrcF10h6xezMQK+LBvpI="}
      },
      "authorization":{
       "class":"solr.RuleBasedAuthorizationPlugin",
       "permissions":[
     {"name":"security-edit", "role":"admin"},
     {"name":"collection-admin-edit", "role":"admin"},
     {"name":"core-admin-edit", "role":"admin"}
       ],
       "user-role":{"user":"admin"}
      }
    }
  • Adds two lines to bin/solr.in.sh or bin\solr.in.cmd to set the authentication type, and the path to basicAuth.conf:

    # The following lines added by ./solr for enabling BasicAuth
    SOLR_AUTH_TYPE="basic"
    SOLR_AUTHENTICATION_OPTS="-Dsolr.httpclient.config=/path/to/solr-6.6.0/server/solr/basicAuth.conf"
  • Creates the file server/solr/basicAuth.conf to store the credential information that is used with bin/solr commands.

The command takes the following parameters:

-credentials

The username and password in the format of username:password of the initial user.

If you prefer not to pass the username and password as an argument to the script, you can choose the -prompt option. Either -credentials or -prompt must be specified.

-prompt

If prompt is preferred, pass true as a parameter to request the script to prompt the user to enter a username and password.

Either -credentials or -prompt must be specified.

-blockUnknown

When true, blocks all unauthenticated users from accessing Solr. This defaults to false, which means unauthenticated users will still be able to access Solr.

-updateIncludeFileOnly

When true, only the settings in bin/solr.in.sh or bin\solr.in.cmd will be updated, and security.json will not be created.

-z

Defines the ZooKeeper connect string. This is useful if you want to enable authentication before all your Solr nodes have come up.

-d

Defines the Solr server directory, by default $SOLR_HOME/server. It is not common to need to override the default, and is only needed if you have customized the $SOLR_HOME directory path.

-s

Defines the location of solr.solr.home, which by default is server/solr. If you have multiple instances of Solr on the same host, or if you have customized the $SOLR_HOME directory path, you likely need to define this.

Disabling Basic Authentication

You can disable Basic Authentication with bin/solr auth disable.

If the -updateIncludeFileOnly option is set to true, then only the settings in bin/solr.in.sh or bin\solr.in.cmd will be updated, and security.json will not be removed.

If the -updateIncludeFileOnly option is set to false, then the settings in bin/solr.in.sh or bin\solr.in.cmd will be updated, and security.json will be removed. However, the basicAuth.conf file is not removed with either option.

ZooKeeper Operations

The bin/solr script allows certain operations affecting ZooKeeper. These operations are for SolrCloud mode only. The operations are available as sub-commands, which each have their own set of options.

bin/solr zk [sub-command] [options]

bin/solr zk -help

Solr should have been started at least once before issuing these commands to initialize ZooKeeper with the znodes Solr expects. Once ZooKeeper is initialized, Solr doesn’t need to be running on any node to use these commands.

Upload a Configuration Set

Use the zk upconfig command to upload one of the pre-configured configuration set or a customized configuration set to ZooKeeper.

Available Parameters (all parameters are required)

Parameter Description Example

-n <name>

Name of the configuration set in ZooKeeper. This command will upload the configuration set to the "configs" ZooKeeper node giving it the name specified.

You can see all uploaded configuration sets in the Admin UI via the Cloud screens. Choose Cloud → Tree → configs to see them.

If a pre-existing configuration set is specified, it will be overwritten in ZooKeeper.

-n myconfig

-d <configset dir>

The path of the configuration set to upload. It should have a "conf" directory immediately below it that in turn contains solrconfig.xml etc.

If just a name is supplied, $SOLR_HOME/server/solr/configsets will be checked for this name. An absolute path may be supplied instead.

-d directory_under_configsets

-d /path/to/configset/source

-z <zkHost>

The ZooKeeper connection string. Unnecessary if ZK_HOST is defined in solr.in.sh or solr.in.cmd.

-z 123.321.23.43:2181

An example of this command with these parameters is:

bin/solr zk upconfig -z 111.222.333.444:2181 -n mynewconfig -d /path/to/configset

Reload Collections When Changing Configurations

This command does not automatically make changes effective! It simply uploads the configuration sets to ZooKeeper. You can use the Collection API’s RELOAD command to reload any collections that uses this configuration set.

Download a Configuration Set

Use the zk downconfig command to download a configuration set from ZooKeeper to the local filesystem.

Available Parameters (all parameters are required)

Parameter Description Example

-n <name>

Name of config set in ZooKeeper to download. The Admin UI Cloud → Tree → configs node lists all available configuration sets.

-n myconfig

-d <configset dir>

The path to write the downloaded configuration set into. If just a name is supplied, $SOLR_HOME/server/solr/configsets will be the parent. An absolute path may be supplied as well.

In either case, pre-existing configurations at the destination will be overwritten!

-d directory_under_configsets

-d /path/to/configset/destination

-z <zkHost>

The ZooKeeper connection string. Unnecessary if ZK_HOST is defined in solr.in.sh or solr.in.cmd.

-z 123.321.23.43:2181

An example of this command with the parameters is:

bin/solr zk downconfig -z 111.222.333.444:2181 -n mynewconfig -d /path/to/configset

A "best practice" is to keep your configuration sets in some form of version control as the system-of-record. In that scenario, downconfig should rarely be used.

Copy between Local Files and ZooKeeper znodes

Use the zk cp command for transferring files and directories between ZooKeeper znodes and your local drive. This command will copy from the local drive to ZooKeeper, from ZooKeeper to the local drive or from ZooKeeper to ZooKeeper.

Available Parameters

Parameter Description Example

-r

Optional. Do a recursive copy. The command will fail if the <src> has children unless '-r' is specified.

-r

<src>

The file or path to copy from. If prefixed with zk: then the source is presumed to be ZooKeeper. If no prefix or the prefix is 'file:' this is the local drive. At least one of <src> or <dest> must be prefixed by ‘zk:’ or the command will fail.

zk:/configs/myconfigs/solrconfig.xml

file:/Users/apache/configs/src

<dest>

The file or path to copy to. If prefixed with zk: then the source is presumed to be ZooKeeper. If no prefix or the prefix is 'file:' this is the local drive. At least one of <src> or <dest> must be prefixed by zk: or the command will fail. If <dest> ends in a slash character it names a directory.

zk:/configs/myconfigs/solrconfig.xml file:/Users/apache/configs/src

-z <zkHost>

The ZooKeeper connection string. Unnecessary if ZK_HOST is defined in solr.in.sh or solr.in.cmd.

-z 123.321.23.43:2181

An example of this command with the parameters is:

Recursively copy a directory from local to ZooKeeper.

bin/solr zk cp -r file:/apache/confgs/whatever/conf zk:/configs/myconf -z 111.222.333.444:2181

Copy a single file from ZooKeeper to local.

bin/solr zk cp zk:/configs/myconf/managed_schema /configs/myconf/managed_schema -z 111.222.333.444:2181

Remove a znode from ZooKeeper

Use the zk rm command to remove a znode (and optionally all child nodes) from ZooKeeper

Available Parameters

Parameter Description Example

-r

Optional. Do a recursive removal. The command will fail if the <path> has children unless '-r' is specified.

-r

<path>

The path to remove from ZooKeeper, either a parent or leaf node.

There are limited safety checks, you cannot remove '/' or '/zookeeper' nodes.

The path is assumed to be a ZooKeeper node, no zk: prefix is necessary.

/configs

/configs/myconfigset

/configs/myconfigset/solrconfig.xml

-z <zkHost>

The ZooKeeper connection string. Unnecessary if ZK_HOST is defined in solr.in.sh or solr.in.cmd.

-z 123.321.23.43:2181

An example of this command with the parameters is:

bin/solr zk rm -r /configs

bin/solr zk rm /configs/myconfigset/schema.xml

Move One ZooKeeper znode to Another (Rename)

Use the zk mv command to move (rename) a ZooKeeper znode

Available Parameters

Parameter Description Example

<src>

The znode to rename. The zk: prefix is assumed.

/configs/oldconfigset

<dest>

The new name of the znode. The zk: prefix is assumed.

/configs/newconfigset

-z <zkHost>

The ZooKeeper connection string. Unnecessary if ZK_HOST is defined in solr.in.sh or solr.in.cmd.

-z 123.321.23.43:2181

An example of this command is:

bin/solr zk mv /configs/oldconfigset /configs/newconfigset

List a ZooKeeper znode’s Children

Use the zk ls command to see the children of a znode.

Available Parameters

Parameter Description Example

-r

Optional. Recursively list all descendants of a znode.

-r

<path>

The path on ZooKeeper to list.

/collections/mycollection

-z <zkHost>

The ZooKeeper connection string. Unnecessary if ZK_HOST is defined in solr.in.sh or solr.in.cmd.

-z 123.321.23.43:2181

An example of this command with the parameters is:

bin/solr zk ls -r /collections/mycollection

bin/solr zk ls /collections

Create a znode (supports chroot)

Use the zk mkroot command to create a znode. The primary use-case for this command to support ZooKeeper’s "chroot" concept. However, it can also be used to create arbitrary paths.

Available Parameters

Parameter Description Example

<path>

The path on ZooKeeper to create. Intermediate znodes will be created if necessary. A leading slash is assumed even if not specified.

/solr

-z <zkHost>

The ZooKeeper connection string. Unnecessary if ZK_HOST is defined in solr.in.sh or solr.in.cmd.

-z 123.321.23.43:2181

Examples of this command:

bin/solr zk mkroot /solr -z 123.321.23.43:2181

bin/solr zk mkroot /solr/production