Pro Apache Phoenix
Total Page:16
File Type:pdf, Size:1020Kb
Pro Apache Phoenix An SQL Driver for HBase First Edition Shakil Akhtar Ravi Magham Pro Apache Phoenix: An SQL Driver for HBase Shakil Akhtar Ravi Magham Bangalore, Karnataka Santa Clara, California India USA ISBN-13 (pbk): 978-1-4842-2369-7 ISBN-13 (electronic): 978-1-4842-2370-3 DOI 10.1007/978-1-4842-2370-3 Library of Congress Control Number: 2016961814 Copyright © 2017 by Shakil Akhtar and Ravi Magham This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director: Welmoed Spahr Lead Editor: Celestin Suresh John Technical Reviewers: Ankit Singhal and Rajeshbabu Chintaguntla Editorial Board: Steve Anglin, Pramila Balan, Laura Berendson, Aaron Black, Louise Corrigan, Jonathan Gennick, Robert Hutchinson, Celestin Suresh John, Nikhil Karkal, James Markham, Susan McDermott, Matthew Moodie, Natalie Pao, Gwenan Spearing Coordinating Editor: Sanchita Mandal Copy Editor: Alexander Krider Compositor: SPi Global Indexer: SPi Global Artist: SPi Global Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail [email protected], or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales. Any source code or other supplementary materials referenced by the author in this text are available to readers at www.apress.com. For detailed information about how to locate your book’s source code, go to www.apress.com/source-code/. Readers can also access source code at SpringerLink in the Supplementary Material section for each chapter. Printed on acid-free paper Contents at a Glance About the Authors ........................................................................... xiii About the Technical Reviewers ....................................................... xv ■ Chapter 1: Introduction .................................................................. 1 ■ Chapter 2: Using Phoenix ............................................................. 15 ■ Chapter 3: CRUD with Phoenix ...................................................... 37 ■ Chapter 4: Querying Data ............................................................. 51 ■ Chapter 5: Advanced Querying ..................................................... 63 ■ Chapter 6: Transactions ................................................................ 79 ■ Chapter 7: Advanced Phoenix Concepts ....................................... 91 ■ Chapter 8: Integrating Phoenix with Other Frameworks ............ 111 ■ Chapter 9: Tools & Tuning ........................................................... 123 Index .............................................................................................. 137 iii Contents About the Authors ........................................................................... xiii About the Technical Reviewers ....................................................... xv ■ Chapter 1: Introduction .................................................................. 1 1.1 Big Data Lake and Its Representation ............................................ 2 1.2 Modern Applications and Big Data ................................................. 3 1.2.1 Fraud Detection in Banking .........................................................................3 1.2.2 Log Data Analysis .........................................................................................3 1.2.3 Recommendation Engines ............................................................................4 1.3 Analyzing Big Data ......................................................................... 4 1.4 An Overview of Hadoop and MapReduce ...................................... 5 1.5 Hadoop Ecosystem ......................................................................... 5 1.5.1 HDFS .............................................................................................................6 1.5.2 MapReduce .................................................................................................7 1.5.3 HBase ...........................................................................................................9 1.5.4 Hive ............................................................................................................10 1.5.5 YARN ...........................................................................................................11 1.5.6 Spark ..........................................................................................................11 1.5.7 PIG ..............................................................................................................11 1.5.8 ZooKeeper ..................................................................................................11 1.6 Phoenix in the Hadoop Ecosystem ............................................... 12 1.7 Phoenix’s Place in Big Data Systems ........................................... 12 v ■ CONTENTS 1.8 Importance of Traditional SQL-Based Tools and the Role of Phoenix ...................................................................... 12 1.8.1 Traditional DBA Problems for Big Data Systems- .......................................13 1.8.2 Which Tool Should I Use for Big Data? ��������������������������������������������������������13 1.8.3 Massive Data Storage and Challenges �������������������������������������������������������13 1.8.4 A Traditional Data Warehouse and Querying ..............................................13 1.9 Apache Phoenix in Big Data Analytics .......................................... 14 1.10 Summary .................................................................................... 14 ■ Chapter 2: Using Phoenix ............................................................. 15 2.1 What is Apache Phoenix? ............................................................. 15 2.2 Architecture ................................................................................. 16 2.2.1 Installing Apache Phoenix ..........................................................................17 2.2.2 Installing Java ............................................................................................17 2.3 Installing HBase ........................................................................... 18 2.4 Installing Apache Phoenix ........................................................... 19 2.5 Installing Phoenix on Hortonworks HDP ....................................... 20 2.5.1 Downloading Hortonworks Sandbox ����������������������������������������������������������21 2.5.2 Start HBase ...............................................................................................27 2.5.3 Testing Your Phoenix Installation ����������������������������������������������������������������28 2.6 Installing Phoenix on Cloudera Hadoop ........................................ 30 2.7 Capabilities .................................................................................. 31 2.8 Hadoop Ecosystem and the Role of Phoenix ................................ 32 2.9 Brief Description of Phoenix’s Key Features ............................... 33 2.9.1 Transactions ...............................................................................................33 2.9.2 User-Defined Functions ..............................................................................33 2.9.3 Secondary Indexes .....................................................................................34 2.9.4 Skip Scan ..................................................................................................34 2.9.5 Views ..........................................................................................................34 vi ■ CONTENTS 2.9.6 Multi-Tenancy .............................................................................................34