ZooKeeper Utilities
The Solr Command Line Interface (CLI) script is available to allow you to interact directly with Solr configuration files stored in ZooKeeper.
While Solr’s Admin UI includes pages dedicated to the state of your SolrCloud cluster, it does not allow you to download or modify related configuration files.
| See the section Cloud Screens for more information about using the Admin UI screens. |
The ZooKeeper specific commands are provided by the Solr Control Script.
|
Solr’s zkcli.sh vs ZooKeeper’s zkCli.sh
The deprecated ZooKeeper’s
|
Using Solr’s ZooKeeper CLI
Use the help option to get a list of available ZooKeeper specific commands from the script itself, as in bin/solr zk -h.
ZooKeeper Connection String
All bin/solr zk sub-commands require a ZooKeeper connection string to function. You can provide this in three ways, in order of precedence:
-
Explicitly pass the
-zor--zk-hostoption:bin/solr zk <command> -z <zkHost> -
Set the
ZK_HOSTenvironment variable:export ZK_HOST=<zkHost> -
Define
ZK_HOSTinsolr.in.sh(orsolr.in.cmdon Windows) -
If none are provided, the tools will default to
localhost:2181
This means if you have ZK_HOST configured in your environment, you do not need to pass the -z option to every command.
Solr CLI Examples
Below are some examples of using the bin/solr CLI which assume you have already started the SolrCloud example (bin/solr start -e cloud --no-prompt)
Upload a Configuration Directory
bin/solr zk upconfig -z 127.0.0.1:9983 -n my_new_config -d server/solr/configsets/_default/conf
Put a Local File into a New ZooKeeper File
./bin/solr zk cp ./my_local_file.txt zk:/my_zk_file.txt -z 127.0.0.1:9983
Link a Collection to a Configset
./bin/solr zk linkconfig --conf-name my_new_config -c gettingstarted -z 127.0.0.1:9983
Create a New ZooKeeper Path
This can be useful to create a chroot path in ZooKeeper before first cluster start.
bin/solr zk mkroot /solr -z 127.0.0.1:9983
Set a Cluster Property
This command will add or modify a single cluster property in clusterprops.json.
Unlike the CLUSTERPROP command on the Collections API, this command does not require a running Solr cluster.
bin/solr cluster --property urlScheme --value https -z 127.0.0.1:9983
This command is not nested under bin/solr zk like the others.
|