Creating a Solr collection

Learn how to create a collection so that you can start indexing data with Solr.

  • If you have enabled Ranger for authorization, you must have Solr Admin permission to be able to create collections.
  • Before you can create a Solr collection you need to generate a collection configuration using either a config or an instance directory.
  1. If you are using Kerberos, kinit as a user with permission to create the collection:
    kinit solradmin@[***EXAMPLE.COM***]

    Replace [***EXAMPLE.COM***] with your Kerberos realm name.

  2. On a host running a Solr server, make sure that the SOLR_ZK_ENSEMBLE environment variable is set in /etc/solr/conf/solr-env.sh. For example:
    cat /etc/solr/conf/solr-env.sh
    export SOLR_ZK_ENSEMBLE=zk01.example.com:2181,zk02.example.com:2181,zk03.example.com:2181/solr

    This is automatically set on hosts with a Solr Server or Gateway role in Cloudera Manager.

  3. Create a new collection using the following command:
    solrctl collection --create [***COLLECTION NAME***] -s [***NUMBER OF SHARDS***] -c [***COLLECTION CONFIGURATION***]

    where

    [***COLLECTION NAME***] User-defined name of the collection.
    [***NUMBER OF SHARDS***] The number of shards you want to split your collection into.
    [***COLLECTION CONFIGURATION***] The name of an existing collection configuration.
    For example:
    solrctl collection --create logs -s 3 -c logs_config