$ ${SOLR_ROOT}/bin/solr create_collection -help
Usage: solr create_collection [-c collectionName] [-n configName] [-d configDir] [-shards #] [-replicationFactor #] [-p port] [-V] -c collectionName Name of the collection to create. -n configName Name of the configuration directory in ZooKeeper. By default, if this option is not specified, the configuration will be uploaded to ZooKeeper using the collection name. -d configDir Configuration directory to copy when creating the new collection: Built-in options are: ► _default: Minimal Solr configuration, which supports enabling/disabling field-guessing support. ► sample_techproducts_configs: Example configuration with many optional features enabled to demonstrate the full power of Solr If not specified, default is: _default Alternatively, you can pass the path to your own configuration directory instead of using one of the built-in configurations, such as: bin\solr create_collection -c mycoll -d /tmp/myconfig By default the script will upload the specified confdir directory into Zookeeper using the same name as the collection (-c) option. Alternatively, if you want to reuse an existing directory or create a confdir in Zookeeper that can be shared by multiple collections, use the -n option. -shards # Number of shards to split the collection into. Default: 1 -replicationFactor # Number of copies of each document in the collection. Default: 1 (no replication) -p port Port of a local Solr instance where you want to create the new collection. If not specified, the script will search the local system for a running Solr instance and will use the port of the first server it finds. -V Enables more verbose output.
$ ${SOLR_ROOT}/bin/solr create_collection -c collection1 -n solr_config1
Re-using existing configuration directory solr_config1 Created collection 'collection1' with 1 shard(s), 1 replica(s) with config-set 'solr_config1'
solr_config1
" doesn't exist (it wasn't created/uploaded to ZooKeeper),
Solr will then try to create a new configuration with the name "solr_config1
" by using the configuration "_default
".
You will get the following output:Created collection 'collection1' with 1 shard(s), 1 replica(s) with config-set 'solr_config1'
${SOLR_HOME}/configsets/_default
" directory must exist, otherwise you will get this error:
Specified configuration directory _default not found!$ ${SOLR_ROOT}/server/scripts/cloud-scripts/zkcli.sh \ -zkhost "localhost:2181/solr" \ -cmd ls /collections
_default
"
("${SOLR_HOME}/configsets/_default
").$ ${SOLR_ROOT}/bin/solr create_collection -c collection2
WARNING: Using _default configset with data driven schema functionality. NOT RECOMMENDED for production use. To turn off: bin/solr config -c collection2 -p 8984 -action set-user-property -property update.autoCreateFields -value false Created collection 'collection2' with 1 shard(s), 1 replica(s) with config-set 'collection2'
collection2
" is created in ZooKeeper:$ ${SOLR_ROOT}/server/scripts/cloud-scripts/zkcli.sh \ -zkhost "localhost:2181/solr" \ -cmd ls /configs
collection2
" is created in ZooKeeper:$ ${SOLR_ROOT}/server/scripts/cloud-scripts/zkcli.sh \ -zkhost "localhost:2181/solr" \ -cmd ls /collections
-d DIRECTORY_NAME
") that will be used to create and upload the Solr configuration to ZooKeeper.${SOLR_HOME}/configsets/
):collection3
"$ ${SOLR_ROOT}/bin/solr create_collection -c collection3 -d _default
WARNING: Using _default configset with data driven schema functionality. NOT RECOMMENDED for production use. To turn off: bin/solr config -c collection3 -p 8984 -action set-user-property -property update.autoCreateFields -value false Created collection 'collection3' with 1 shard(s), 1 replica(s) with config-set 'collection3'
-d DIRECTORY_PATH
") that will be used to create and upload the Solr configuration to ZooKeeper.DIRECTORY_PATH/
".conf/
" folder under the provided directory "DIRECTORY_PATH/conf/
".server/solr/configsets/conf/
" folder under the provided directory "DIRECTORY_PATH/server/solr/configsets/conf/
".collection4
"$ ${SOLR_ROOT}/bin/solr create_collection -c collection4 -d ${SOLR_HOME}/configsets/_default/conf
Created collection 'collection4' with 1 shard(s), 1 replica(s) with config-set 'collection4'
$ ${SOLR_ROOT}/bin/solr create_collection -c collection5 -d _default -n solr_default_5
Created collection 'collection5' with 1 shard(s), 1 replica(s) with config-set 'solr_default_5'
$ ${SOLR_ROOT}/bin/solr create_collection -c collection6 -n solr_config1 -shards 2 -replicationFactor 2
Re-using existing configuration directory solr_config1 Created collection 'collection6' with 2 shard(s), 2 replica(s) with config-set 'solr_config1'
/solr/collections/collection6
" (Solr collection) will be creacted in ZooKeeper and will contain the following znodes:counter leader_elect leaders state.json terms
/solr/configs/solr_config1
" (Solr configuration) contain the following znodes:managed-schema solrconfig.xml currency.xml elevate.xml params.json protwords.txt stopwords.txt synonyms.txt ...
$ ls -1 ${SOLR_ROOT_INSTANCE_1}/server/solr/
collection6_shard1_replica_n2 collection6_shard2_replica_n6
$ ls -1 ${SOLR_ROOT_INSTANCE_2}/server/solr/
collection6_shard1_replica_n1 collection6_shard2_replica_n4
${SOLR_ROOT_INSTANCE_1}/server/solr/collection6_shard1_replica_n2/core.properties
${SOLR_ROOT_INSTANCE_1}/server/solr/collection6_shard2_replica_n6/core.properties
${SOLR_ROOT_INSTANCE_2}/server/solr/collection6_shard1_replica_n1/core.properties
${SOLR_ROOT_INSTANCE_2}/server/solr/collection6_shard2_replica_n4/core.properties
$ cat ${SOLR_ROOT_INSTANCE_1}/server/solr/collection6_shard1_replica_n2/core.properties
name=collection6_shard1_replica_n2 collection=collection6 collection.configName=solr_config1 numShards=2 shard=shard1 coreNodeName=core_node5 replicaType=NRT