Batch indexing into online Solr servers using GoLive

MapReduceIndexerTool is a MapReduce batch job driver that creates a set of Solr index shards from a set of input files and writes the indexes into HDFS in a flexible, scalable, and fault-tolerant manner. Using GoLive, MapReduceIndexerTool also supports merging the output shards into a set of live customer-facing Solr servers.

  1. If you are working with a secured cluster, configure your client JAAS file ($HOME/jaas.conf) as follows:
    Client { required
  2. If you are using Kerberos, kinit as a user that has privileges to update the collection:
    kinit solr@EXAMPLE.COM

    Replace EXAMPLE.COM with your Kerberos realm name.

  3. Delete any existing documents in the cloudera_tutorial_tweets collection. If your cluster does not have security enabled, run the following commands as the solr user by adding sudo -u solr before the command:
    solrctl collection --deletedocs cloudera_tutorial_tweets
  4. Run the MapReduce job with the --go-live parameter. Replace and with your NameNode and ZooKeeper hostnames, respectively.
    • Security Enabled:
      YARN_OPTS="" yarn jar /opt/cloudera/parcels/CDH/lib/solr/contrib/mr/search-mr-job.jar org.apache.solr.hadoop.MapReduceIndexerTool -D '' -D 'mapreduce.job.user.classpath.first=true' --log4j /opt/cloudera/parcels/CDH/share/doc/search*/examples/solr-nrt/ --morphline-file /opt/cloudera/parcels/CDH/share/doc/search*/examples/solr-nrt/test-morphlines/tutorialReadAvroContainer.conf --output-dir hdfs:// --verbose --go-live --zk-host --collection cloudera_tutorial_tweets hdfs://
    • Security Disabled:
      yarn jar /opt/cloudera/parcels/CDH/lib/solr/contrib/mr/search-mr-job.jar org.apache.solr.hadoop.MapReduceIndexerTool -D '' -D 'mapreduce.job.user.classpath.first=true' --log4j /opt/cloudera/parcels/CDH/share/doc/search*/examples/solr-nrt/ --morphline-file /opt/cloudera/parcels/CDH/share/doc/search*/examples/solr-nrt/test-morphlines/tutorialReadAvroContainer.conf --output-dir hdfs:// --verbose --go-live --zk-host --collection cloudera_tutorial_tweets hdfs://
    This command requires a morphline file, which must include a SOLR_LOCATOR directive. Any CLI parameters for --zkhost and --collection override the parameters of the solrLocator. The SOLR_LOCATOR directive might appear as follows:
      # Name of solr collection
      collection : collection_name
      # ZooKeeper ensemble
      zkHost : ",,"
    morphlines : [
        id : morphline1
        importCommands : ["org.kitesdk.**", "org.apache.solr.**"]
        commands : [
          { generateUUID { field : id } }
          { # Remove record fields that are unknown to Solr schema.xml.
            # Recall that Solr throws an exception on any attempt to load a document that
            # contains a field that isn't specified in schema.xml.
            sanitizeUnknownSolrFields {
              solrLocator : ${SOLR_LOCATOR} # Location from which to fetch Solr schema
          { logDebug { format : "output record: {}", args : ["@{}"] } }
            loadSolr {
              solrLocator : ${SOLR_LOCATOR}
    For help on how to run the MapReduce job, run the following command:
    yarn jar /opt/cloudera/parcels/CDH/lib/solr/contrib/mr/search-mr-*-job.jar org.apache.solr.hadoop.MapReduceIndexerTool --help

    For development purposes, you can use the --dry-run option to run in local mode and print documents to stdout instead of loading them into Solr. Using this option causes the morphline to run locally without submitting a job to MapReduce. Running locally provides faster turnaround during early trial and debug sessions.

    To print diagnostic information, such as the content of records as they pass through the morphline commands, enable TRACE log level diagnostics by adding the following entry to your file:
    The file location can be specified by using the MapReduceIndexerTool --log4j /path/to/ command-line option.
  5. Check the job status at:
    For secure clusters, replace http with https and port 8088 with 8090.
  6. When the job is complete, run a Solr query. For example, for a Solr server running on, go to one of the following URLs in a browser, depending on whether you have enabled security on your cluster:
    • Security Enabled:*:*
    • Security Disabled:*:*
    If indexing was successful, this page displays the first 10 query results.