Shell Client Operation Commands
Before using the Solr shell script, you need to install the Solr client.
Operation Commands of the Solr Configuration Set
Operation |
Command |
Parameter |
Example |
---|---|---|---|
Generating a Solr configuration set in a specified local path |
solrctl confset --generate path [_default | -confWithHBase | -confWithHDFS | -confWithDisk | -confWithSchema ] |
|
solrctl confset --generate /home/solrDir or solrctl confset --generate /home/solrDir -schemaless or solrctl confset --generate /home/solrDir -confWithHBase or solrctl confset --generate /home/solrDir -confWithHDFS or solrctl confset --generate /home/solrDir -confWithDisk or solrctl confset --generate /home/solrDir _default |
Uploading the local configuration file set to ZooKeeper, and specifying the name |
solrctl confset --create name path -force |
|
solrctl confset --create myconf /home/solrDir/ |
Updating the Solr configuration set |
solrctl confset --update name path -force |
|
solrctl confset --update myconf /home/solrDir/ |
Obtaining the Solr configuration set and saving it to the local client |
solrctl confset --get name path |
|
solrctl confset --get myconf /home/solrTest/ |
Uploading a file to the specified path on ZooKeeper |
solrctl confset --putfile path localpath |
|
solrctl confset --putfile /configs/confWithSchema/test.xml /opt/test.xml |
Obtaining a file of the specified path in the configuration set and save it to a local node |
solrctl confset --getfile path filename |
|
solrctl confset --getfile /configs/confWithSchema/schema.xml schema.xml |
Deleting a file in the specified path |
solrctl confset --clearfile path |
|
solrctl confset --clearfile /configs/confWithSchema/test.xml |
Deleting the specified configuration set |
solrctl confset --delete name |
|
solrctl confset --delete myconf |
Listing the Solr configuration sets |
solrctl confset --list |
list is a command used to list the configuration sets. |
solrctl confset --list |
- When you use the solrctl confset --get name path command to obtain a Solr file of a configuration set from ZooKeeper, a conf folder is generated in the specified path. The conf directory stores the configuration files, including schema.xml and solrconfig.xml.
- When you run the command to delete a configuration set, enter y as prompted to confirm the deletion.
Collection Operation Commands
Operation |
Command |
Parameter |
Example |
---|---|---|---|
Creating a collection |
solrctl collection --create name [-s <numShards>] [-a Create collection with autoAddReplicas=true] [-S <true|false> Create collection true or false with sharedFsReplication] [-b <true|false> Create collection true or false with autoShardBalance] [-c <collection.configName>] [-r <replicationFactor>] [-m <maxShardsPerNode>] [-n <createNodeSet>] [-f <router.field>] [-p name=value ...] |
|
solrctl collection --create collectionTest -c myconf -s 3 -r 1 -m 1 -n solrIp1:port1_solr,solrIp2:port2_solr,solrIp3:port3_solr |
Modifying a collection |
solrctl collection --modify name [-a <true|false> Modify collection true or false with autoAddReplicas] [-b <true|false> Modify collection true or false with autoShardBalance] [-r <replicationFactor>] [-m <maxShardsPerNode>] |
|
solrctl collection --modify collectionTest -b true |
Deleting a collection |
solrctl collection --delete name |
|
solrctl collection --delete collectionTest |
Reloading a collection |
solrctl collection --reload name |
|
solrctl collection --reload collection1 |
Splitting a shard of a collection |
solrctl collection --splitshard collection shard [-async <async task id>] |
NOTE:
The async parameter must be specified. Tasks are asynchronously executed on the server. You can run the requeststatus command to query the task status. Different values of the async parameter must be specified for each task. |
solrctl collection --splitshard collection1 shard1 -async 1 |
Adding a shard to a collection |
solrctl collection --createshard collection shard |
|
solrctl collection --createshard collection1 shard1 |
Deleting a shard from a collection |
solrctl collection --deleteshard collection shard |
|
solrctl collection --deleteshard collection1 shard1 |
Creating an alias for a collection |
solrctl collection --createalias aliasname collections |
|
solrctl collection --createalias mycollection collections1 |
Deleting the alias of a collection |
solrctl collection --deletealias aliasname |
|
solrctl collection --deletealias mycollection |
Deleting the replica of a collection |
solrctl collection --deletereplica [-p name=value]... |
|
solrctl collection --deletereplica -p collection=collection1 -p shard=shard1 -p replica=core_node2 |
Adding a replica to a collection |
solrctl collection --addreplica [-p name=value]... |
NOTE:
You need to specify the collection and shard to which the replica belongs. |
solrctl collection --addreplica -p collection=collection1 -p shard=shard1 -p node=192.168.0.22:21101_solr |
Deleting the index data of a collection |
solrctl collection --deletedocs name |
|
solrctl collection --deletedocs collection1 |
Listing all collections |
solrctl collection --list |
list is a command used to list all collections. |
solrctl collection --list |
Querying the cluster status |
solrctl collection --clusterstatus |
clusterstatus indicates the cluster status. |
solrctl collection --clusterstatus |
Obtaining the status and statistics of overseer |
solrctl collection --overseerstatus |
overseerstatus indicates the overseer status and statistics. |
solrctl collection --overseerstatus |
Migrating all replicas from the source SolrServer instance to the target one |
solrctl collection --replacenode source_node target_node [-async <async task id>] [-p Replace node with parallel=true] [-t <timeout in s>] [-c Replace node with skipCheck=false] [-sotimeout <socket timeout in ms>] |
|
solrctl collection --replacenode 192.168.229.137:21101_solr 192.168.229.219:21104_solr -async 2 |
Querying the asynchronous task execution status |
solrctl collection --requeststatus requestid |
requestid is the ID of the asynchronous task to be queried.
NOTE:
If the value of msg is found [requestid] in running tasks in the query result, the task is being executed. If the value is found [requestid] in completed tasks, the task is complete. |
solrctl collection --requeststatus 1 |
- If the schema.xml configuration set file is incorrectly configured, the collection may fail to be created and junk data remains. In this case, you need to manually clear the junk data under the index data save path of the collection in each instance, remove the /solr/clusterstate.json file from ZooKeeper, and restart Solr. You are advised to create a collection with a single shard and check whether the configuration is correct after configuring the schema.xml file.
- When the Solr index data is stored in HDFS, you can set the number of index data replicas by modifying <int name="solr.hdfs.replication.number">${solr.hdfs.replication.number:3}</int> in the solrconfig.xml file. The default value is 3. In addition, you can set the number of tlog replicas by modifying <int name="tlogDfsReplication">${solr.ulog.tlogDfsReplication:3}</int> in the solrconfig.xml file. The default value is 3.
- When you run commands to delete collections, shards, aliases, replicas, and data, enter y as prompted to confirm the deletion.
Cluster Operation Commands
Operation |
Command |
Parameter |
Example |
---|---|---|---|
Obtaining the solr.xml file |
solrctl cluster --get-solrxml file |
|
solrctl cluster --get-solrxml /opt/client/solrtest.xml |
Upload the solr.xml file: |
solrctl cluster --put-solrxml file |
|
solrctl cluster --put-solrxml /opt/client/solrtest.xml |
Setting properties in clusterprops. |
solrctl cluster --set-property name value |
|
solrctl cluster --set-property urlScheme http |
Removing specified properties from clusterprops |
solrctl cluster --remove-property name |
|
solrctl cluster --remove-property urlScheme |
Displaying a list of idle nodes |
solrctl cluster --list-free-node |
list-free-node is a command used to provide a list of idle nodes. |
solrctl cluster --list-free-node |
Displaying a list of active nodes supporting local disks |
solrctl cluster --list-local-disk-live-node |
list-local-disk-live-node is a command used to provide a list of active nodes supporting local disks. |
solrctl cluster --list-local-disk-live-node |
Displaying information about the state.json file of a collection |
solrctl cluster --get-coll-state or solrctl cluster --get-coll-state collection |
|
solrctl cluster --get-coll-state or solrctl cluster --get-coll-state collection1 |
Displaying information about all Solr instances |
solrctl cluster --list-node |
list-node indicates that information about all Solr instances are displayed. |
solrctl cluster --list-node |
Displaying information about all Solr instances |
solrctl cluster --list-live-node |
list-live-node indicates that information about all live Solr instances are displayed. |
solrctl cluster --list-live-node |
The --list-free-node command is used to query the nodes that can be securely decommissioned when Solr is out of service.
HBaseIndexer Operation Commands
Operation |
Command |
Parameter |
Example |
---|---|---|---|
Viewing the status of the newly created indexers |
hbase-indexer list-indexers |
list-indexers indicates the status of the newly created indexers can be viewed. |
hbase-indexer list-indexers |
Deleting the created indexers |
hbase-indexer delete-indexer -n indexer_name |
|
hbase-indexer delete-indexer -n userIndexer |
Creating an indexer |
hbase-indexer add-indexer -n indexer_name -c path/index.xml -cp solr.collection=collection_name -cp solr.zk=hostips:zkport/solr |
|
hbase-indexer add-indexer -n userIndexer -c /opt/client/Solr/hbase-indexer/conf/hbase-demo-indexer.xml -cp solr.collection=collection1 -cp solr.zk=192.168.1.1:2181,192.168.1.2:2181,192.168.1.3:2181/solr |
Creating an index task |
hbase-indexer batch-indexer --hbase-indexer-zk hostip:zkport --hbase-indexer-name indexer_name --out-put-dir hdfs_url --go-live --overwrite-output-dir --verbose --reducers number --zk-host hostip:zkport/solr --rowkey-dir hdfs_url --hbase-indexer-file configfilepath |
|
hbase-indexer batch-indexer --hbase-indexer-zk 192.168.1.1:2181,192.168.1.2:2181,192.168.1.3:2181 --hbase-indexer-name userIndexer --output-dir hdfs://hacluster/user/solr/test --go-live --overwrite-output-dir --verbose --reducers 10 --zk-host 192.168.1.1:2181,192.168.1.2:2181,192.168.1.3:2181/solr --rowkey-dir hdfs://hacluster/user/solr/rowkey --hbase-indexer-file /opt/client/Solr/hbase-indexer/conf/user.xml |
Checking the collection task status in real time |
hbase-indexer replication-status -z hostip:zkport --hbase-instance-file configfile_uri --enable-jmx |
|
hbase-indexer replication-status -z 192.168.1.1:2181 --hbase-instance-file /opt/client/Solr/hbase-indexer/conf/hbase-site.xml --enable-jmx |
In a cluster in security mode, if you want to run the hbase-indexer replication-status command, perform authentication as user hbase.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot