Creating a Solr Collection

If you have enabled Ranger for authorization, you must have Solr Admin permission to be able to create collections.
  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

    If you are using Cloudera Manager, this is automatically set on hosts with a Solr Server or Gateway role.

  3. Generate configuration files for the collection:
    • Using Configs:
      solrctl config --create logs_config managedTemplate -p immutable=false
    • Using Instance Directories:
      solrctl instancedir --generate $HOME/logs_config
      # Edit the configuration files as needed
      solrctl instancedir --create logs_config $HOME/logs_config

    For more information on configs and instance directories, see Managing Configuration Using Configs or Instance Directories.

  4. Create a new collection using the specified configuration:
    solrctl collection --create logs -s <numShards> -c logs_config