Ingesxng HDFS Data Into Solr Using Spark

Ingesxng HDFS Data Into Solr Using Spark

Inges&ng HDFS data into Solr using Spark Wolfgang Hoschek ([email protected]) So@ware Engineer @ Cloudera Search QCon 2015 1 The Enterprise Data Hub The image cannot be displayed. Your computer may not have Metadata, Security, Audit, Lineage Management Online Analy>c Search Batch Stream Machine System • Mul&ple processing NoSQL MPP DBMS Engine Processing Processing Learning DBMS frameworks • One pool of data Resource Management • One set of system resources Unified Scale-out Storage Management • One management For Any Type of Data Data interface Elas&c, Fault-tolerant, Self-healing, In-memory capabili&es • One security framework SQL Streaming File System (NFS) 2 Apache Spark • Mission • Fast and general engine for large-scale data processing • Speed • Advanced DAG execu&on engine that supports cyclic data flow and in-memory compu&ng • Ease of Use • Write applicaons quickly in Java, Scala or Python • Generality • Combine batch, streaming, and complex analy&cs • Successor to MapReduce 3 What is Search on Hadoop? Interac>ve search for Hadoop • Full-text and faceted navigaon • Batch, near real-&me, and on-demand indexing Apache Solr integrated with CDH • Established, mature search with vibrant community • Incorporated as part of the Hadoop ecosystem • Apache Flume, Apache HBase • Apache MapReduce, Kite Morphlines • Apache Spark, Apache Crunch Open Source • 100% Apache, 100% Solr • Standard Solr APIs 4 Search on Hadoop - Architecture Overview Online Streaming Data OLTP Data End User Client App (e.g. Hue) Search queries Cloudera Manager NRT Replicaon HBase NRT Data Events indexed Cluster indexed w/ w/ Morphlines Flume Morphlines SolrCloud Cluster(s) Raw, filtered, or Indexed data GoLive updates annotated data HDFS Spark & MapReduce Batch 5 Indexing w/ Morphlines • Navigated, faceted drill down Customizable Hue UI • Full text search, standard Solr API and query language 6 hp://gethue.com Scalable Batch ETL & Indexing Solr and MapReduce Solr server • Flexible, scalable, reliable Solr Index batch indexing server shard • On-demand indexing, cost- Index efficient re-indexing shard Indexer w/ • Start serving new indices HDFS Morphlines without down&me Indexer w/ • “MapReduceIndexerTool” Morphlines • “HBaseMapReduceIndexerTool” • “CrunchIndexerTool on MR” Files Files or HBase Solr and Spark tables • “CrunchIndexerTool on Spark” hadoop ... MapReduceIndexerTool --morphline-file morphline.conf ... 7 Streaming ETL (Extract, Transform, Load) syslog Flume Agent Kite Morphlines Event • Consume any kind of data from any Solr sink kind of data source, process and load into Solr, HDFS, HBase or anything else Record • Simple and flexible data transformaon Command: readLine • Extensible set of transf. commands Record • Reusable across mul&ple workloads Command: grok • For Batch & Near Real Time Record • Configuraon over coding Morphline Command: loadSolr • reduces &me & skills • ASL licensed on Github Document heps://github.com/kite-sdk/kite Solr 8 Morphline Example – syslog with grok morphlines : [ { id : morphline1 importCommands : [”org.kitesdk.**", "org.apache.solr.**"] commands : [ { readLine {} } { grok { dic&onaryFiles : [/tmp/grok-dic&onaries] expressions : { message : """<%{POSINT:syslog_pri}>%{SYSLOGTIMESTAMP:syslog_mestamp} % {SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: % {GREEDYDATA:syslog_message}""" } Example Input } <164>Feb 4 10:46:14 syslog sshd[607]: listening on 0.0.0.0 port 22 } Output Record { loadSolr {} } syslog_pri:164 ] syslog_mestamp:Feb 4 10:46:14 } syslog_hostname:syslog ] syslog_program:sshd syslog_pid:607 syslog_message:listening on 0.0.0.0 port 22. 9 Current Morphline Command Library • Supported Data Formats • Text: Single-line record, mul&-line records, CSV, CLOB • Apache Avro, Parquet files • Apache Hadoop Sequence Files • Apache Hadoop RCFiles • JSON • XML, XPath, XQuery • Via Apache Tika: HTML, PDF, MS-Office, Images, Audio, Video, Email • HBase rows/cells • Via pluggable commands: Your custom data formats • Regex based paern matching and extrac&on • Flexible log file analysis • Integrate with and load data into Apache Solr • Scrip&ng support for dynamic Java code • Etc, etc, etc 10 Morphline Example - Escape to Java Code morphlines : [ { id : morphline1 importCommands : [”org.kitesdk.**”] commands : [ { java { code: """ List tags = record.get("tags"); if (!tags.contains("hello")) { return false; } tags.add("world"); return child.process(record); """ } } ] } ] 11 Example Java Driver Program - Can be wrapped into Spark func&ons /** Usage: java ... <morphline.conf> <dataFile1> ... <dataFileN> */ public static void main(String[] args) { // compile morphline.conf file on the fly File conf= new File(args[0]); MorphlineContext ctx= new MorphlineContext.Builder().build(); Command morphline = new Compiler().compile(conf, null, ctx, null); // process each input data file Notifications.notifyBeginTransaction(morphline); for (int i = 1; i < args.length; i++) { InputStream in = new FileInputStream(new File(args[i])); Record record = new Record(); record.put(Fields.ATTACHMENT_BODY, in); morphline.process(record); in.close(); } Notifications.notifyCommitTransaction(morphline); } 12 Scalable Batch Indexing Input Extractors Leaf Shards Root Shards • Morphline runs inside Mapper Files (Mappers) (Reducers) (Mappers) • Reducers build local Solr indexes S • Mappers merge microshards 0_0_0 • GoLive merges into live SolrCloud S 0_0_1 GoLive ... ... S0 S0_1_0 • Can exploit all reducer slots even if S0_1_1 #reducers >> #solrShards • Great throughput but poor latency S1_0_0 • Only inserts, no updates & deletes! • Want to migrate from MR to Spark S1_0_1 GoLive ... ... S1 S1_1_0 S1_1_1 hadoop ... MapReduceIndexerTool --morphline-file morphline.conf ... 13 Batching Indexing with CrunchIndexerTool Input Extractors SolrCloud Files (Executors/ Shards Mappers) ... ... S0 • Morphline runs inside Spark executors • Morphline sends docs to live SolrCloud • Good throughput and good latency • Supports inserts, updates & deletes • Flag to run on Spark or MapReduce S ... ... 1 spark-submit ... CrunchIndexerTool --morphline-file morphline.conf ... or hadoop ... CrunchIndexerTool --morphline-file morphline.conf ... 14 More CrunchIndexerTool features (1/2) • Implemented with Apache Crunch library • Eases migraon from MapReduce execu&on engine to Spark execu&on engine – can run on either engine • Supported Spark modes • Local (for tes&ng) • YARN client • YARN cluster (for produc&on) • Efficient batching of Solr updates and deleteById and deleteByQuery • Efficient locality-aware processing for splieable HDFS files • avro, parquet, text lines 15 More CrunchIndexerTool features (2/2) • Dry-run mode for rapid prototyping • Sends commit to Solr on job success • Inherits Fault tolerance & retry from Spark (and MR) • Security in progress: Kerberos token delegaon, SSL • ASL licensed on Github • heps://github.com/cloudera/search/tree/ cdh5-1.0.0_5.3.0/search-crunch 16 Conclusions • Easy migraon from MapReduce to Spark • Also supports updates & deletes & good latency • Recommendaon • Use MapReduceIndexerTool for large scale batch inges&on use cases where updates or deletes of exis&ng documents in Solr are not required • Use CrunchIndexerTool for all other use cases 17 ©2014 Cloudera, Inc. All rights reserved. .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    18 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us