Академический Документы
Профессиональный Документы
Культура Документы
DATA ANALYTICS
WITH ORACLE
Csar Prez
INTRODUCTION
Big data analytics is the process of examining big data to uncover hidden patterns,
unknown correlations and other useful information that can be used to make better
decisions. With big data analytics, data scientists and others can analyze huge volumes of
data that conventional analytics and business intelligence solutions cant touch. Consider
this; its possible that your organization could accumulate (if it hasnt already) billions of
rows of data with hundreds of millions of data combinations in multiple data stores and
abundant formats. High-performance analytics is necessary to process that much data in
order to figure out whats important and what isnt. Enter big data analytics.
Big data is now a reality: The volume, variety and velocity of data coming into your
organization continue to reach unprecedented levels. This phenomenal growth means that
not only must you understand big data in order to decipher the information that truly
counts, but you also must understand the possibilities of what you can do with big data
analytics.
Using big data analytics you can extract only the relevant information from terabytes,
petabytes and exabytes, and analyze it to transform your business decisions for the future.
Becoming proactive with big data analytics isnt a one-time endeavor; it is more of a
culture change a new way of gaining ground by freeing your analysts and decision
makers to meet the future with sound knowledge and insight.
On the other hand, business intelligence (BI) provides standard business reports, ad hoc
reports, OLAP and even alerts and notifications based on analytics. This ad hoc analysis
looks at the static past, which has its purpose in a limited number of situations.
Oracle support for big data implementations, including Hadoop. throught Oracle and
Hadoop is possible work in all steps of Analytical Process: Identify/formulate Problem,
Data Preparation, Data Exploration, Transform and select, Buil Model, Validate model,
Deploy Model and Evaluate/Monitor Results.
This book presents the work possibilities that Oracle offers in the modern sectors of Big
Data, Business Intelligence and Analytics. The most important tools of Oracle are
presented for processing and analyzing large volumes of data in an orderly manner. In
turn, these tools allow also extract the knowledge contained in the data.
INDEX
INTRODUCTION
BIG DATA CONCEPTS
1.1 DEFINING BIG DATA
1.2 THE IMPORTANCE OF BIG DATA
1.3 THE NEED FOR BIG DATA
1.4 KEY TECHNOLOGIES FOR EXTRACTING BUSINESS VALUE FROM BIG DATA
1.4.1 Information Management for Big Data
HADOOP
2.1 BUILDING A BIG DATA PLATFORM
2.1.1 Acquire Big Data
2.1.2 Organize Big Data
2.1.3 Analyze Big Data
2.1.4 Solution Spectrum
2.2 HADOOP
2.3 HADOOP COMPONENTS
2.3.1 Benefits of Hadoop
2.3.2 Limitations of Hadoop
2.4 GET DATA INTO HADOOP
2.5 HADOOP USES
2.5.1 Prime Business Applications for Hadoop
2.6 HADOOP CHALLENGES
ORACLE BIG DATA APPLIANCE
3.1 INTRODUCTION
3.2 ORACLE BIG DATA APPLIANCE BASIC CONFIGURATION
3.3 AUTO SERVICE REQUEST (ASR)
3.4 ORACLE ENGINEERED SYSTEMS FOR BIG DATA
3.5 SOFTWARE FOR BIG DATA
3.5.1 Software Component Overview
3.6 ACQUIRING DATA FOR ANALYSIS
3.6.1 Hadoop Distributed File System
3.6.2 Apache Hive
3.6.3 Oracle NoSQL Database
3.7 ORGANIZING BIG DATA
3.8 MAPREDUCE
3.9 ORACLE BIG DATA CONNECTORS
3.9.1 Oracle SQL Connector for Hadoop Distributed File System
3.9.2 Oracle Loader for Hadoop
3.9.3 Oracle Data Integrator Application Adapter for Hadoop
3.9.4 Oracle XQuery for Hadoop
3.10 ORACLE R ADVANCED ANALYTICS FOR HADOOP
3.11 ORACLE R SUPPORT FOR BIG DATA
3.12 ANALYZING AND VISUALIZING BIG DATA
3.13 ORACLE BUSINESS INTELLIGENCE FOUNDATION SUITE
5.1 INTRODUCTION
5.2 SQL ON HADOOP
5.3 SQL ON MORE THAN HADOOP
5.4 UNIFYING METADATA
5.5 OPTIMIZING PERFORMANCE
5.6 SMART SCAN FOR HADOOP
5.7 ORACLE SQL DEVELOPER & DATA MODELER SUPPORT FOR ORACLE BIG DATA SQL
5.7.1 Setting up Connections to Hive
5.7.2 Using the Hive Connection
5.7.3 Create Big Data SQL-enabled Tables Using Oracle Data Modeler
5.7.4 Edit the Table Definitions
5.7.5 Query All Your Data
5.8 USING ORACLE BIG DATA SQL FOR DATA ACCESS
5.8.1 About Oracle External Tables
5.8.2 About the Access Drivers for Oracle Big Data SQL
5.8.3 About Smart Scan Technology
5.8.4 About Data Security with Oracle Big Data SQL
5.9 INSTALLING ORACLE BIG DATA SQL
5.9.1 Prerequisites for Using Oracle Big Data SQL
5.9.2 Performing the Installation
5.9.3 Running the Post-Installation Script for Oracle Big Data SQL
5.9.4 Running the bds-exa-install Script
5.9.5 bds-ex-install Syntax
5.10 CREATING EXTERNAL TABLES FOR ACCESSING BIG DATA
5.10.1 About the Basic CREATE TABLE Syntax
5.10.2 Creating an External Table for a Hive Table
5.10.3 Obtaining Information About a Hive Table
5.10.4 Using the CREATE_EXTDDL_FOR_HIVE Function
5.10.5 Developing a CREATE TABLE Statement for ORACLE_HIVE
5.10.6 Creating an External Table for HDFS Files
5.10.7 Using the Default Access Parameters with ORACLE_HDFS
5.10.8 Overriding the Default ORACLE_HDFS Settings
5.10.9 Accessing Avro Container Files
5.11 ABOUT THE EXTERNAL TABLE CLAUSE
5.11.1 TYPE Clause
5.11.2 DEFAULT DIRECTORY Clause
5.11.3 LOCATION Clause
5.11.4 REJECT LIMIT Clause
5.11.5 ACCESS PARAMETERS Clause
5.12 ABOUT DATA TYPE CONVERSIONS
5.13 QUERYING EXTERNAL TABLES
5.14 ABOUT ORACLE BIG DATA SQL ON ORACLE EXADATA DATABASE MACHINE
5.14.1 Starting and Stopping the Big Data SQL Agent
5.14.2 About the Common Directory
5.14.3 Common Configuration Properties
5.14.4 bigdata.properties
5.14.5 bigdata-log4j.properties
5.14.6 About the Cluster Directory
1Chapter 1.
The McKinsey Global Institute estimates that data volume is growing 40% per year, and
will grow 44x between 2009 and 2020. But while its often the most visible parameter,
volume of data is not the only characteristic that matters. In fact, there are four key
characteristics that define big data (Figure 1-1):
Volume. Machine-generated data is produced in much larger quantities than
non-traditional data. For instance, a single jet engine can generate 10TB of data
in 30 minutes. With more than 25,000 airline flights per day, the daily volume of
just this single data source runs into the Petabytes. Smart meters and heavy
industrial equipment like oil refineries and drilling rigs generate similar data
volumes, compounding the problem.
Velocity. Social media data streams while not as massive as machinegenerated data produce a large influx of opinions and relationships valuable to
customer relationship management. Even at 140 characters per tweet, the high
velocity (or frequency) of Twitter data ensures large volumes (over 8 TB per
day).
To make the most of big data, enterprises must evolve their IT infrastructures to handle
these new high-volume, high-velocity, high-variety sources of data and integrate them
with the pre-existing enterprise data to be analyzed.
Big data is a relative term describing a situation where the volume, velocity and variety of
data exceed an organizations storage or compute capacity for accurate and timely decision
making. Some of this data is held in transactional data stores the byproduct of fastgrowing online activity. Machine-to-machine interactions, such as metering, call detail
records, environmental sensing and RFID systems, generate their own tidal waves of data.
All these forms of data are expanding, and that is coupled with fast-growing streams of
unstructured and semistructured data from social media.
Thats a lot of data, but it is the reality for many organizations. By some estimates,
organizations in all sectors have at least 100 terabytes of data, many with more than a
petabyte. Even scarier, many predict this number to double every six months going
forward, said futurist Thornton May, speaking at a webinar in 2011.
Figure 1-1
The term Big Data can be interpreted in many different ways. We defined Big Data as
conforming to the volume, velocity, and variety attributes that characterize it. Note that
Big Data solutions arent a replacement for your existing warehouse solutions, and in our
humble opinion, any vendor suggesting otherwise likely doesnt have the full gambit of
experience or understanding of your investments in the traditional side of information
management.
We think its best to start out this section with a couple of key Big Data principles we want
you to keep in mind, before outlining some consider- ations as to when you use Big Data
technologies, namely:
Big Data solutions are ideal for analyzing not only raw structured data, but
semistructured and unstructured data from a wide variety of sources.
Big Data solutions are ideal when all, or most, of the data needs to be
analyzed versus a sample of the data; or a sampling of data isnt nearly as
effective as a larger set of data from which to derive analysis.
Big Data solutions are ideal for iterative and exploratory analysis when
business measures on data are not predetermined.
When it comes to solving information management challenges using Big
Data technologies, we suggest you consider the following:
For example, typically, data bound for the analytic warehouse has to be
cleansed, documented, and trusted before its neatly placed into a strict
warehouse schema (and, of course, if it cant fit into a traditional row and
column format, it cant even get to the warehouse in most cases). In contrast, a
Big Data solution is not only going to leverage data not typically suitable for a
traditional warehouse environment, and in massive amounts of volume, but its
going to give up some of the formalities and strictness of the data. The benefit
is that you can preserve the fidelity of data and gain access to mountains of
information for exploration and discovery of business insights before running it
through the due diligence that youre accustomed to; the data that can be
included as a participant of a cyclic system, enriching the models in the
warehouse.
Big Data is well suited for solving information challenges that dont natively
fit within a traditional relational database approach for handling the problem at
hand.
Its important that you understand that conventional database technolo- gies are an
important, and relevant, part of an overall analytic solution. In fact, they become even
more vital when used in conjunction with your Big Data platform.
A good analogy here is your left and right hands; each offers individual strengths and
optimizations for a task at hand. For example, if youve ever played baseball, you know
that one hand is better at throwing and the other at catching. Its likely the case that each
hand could try to do the other task that it isnt a natural fit for, but its very awkward (try
it; better yet, film your- self trying it and you will see what we mean). Whats more, you
dont see baseball players catching with one hand, stopping, taking off their gloves, and
throwing with the same hand either. The left and right hands of a base- ball player work in
unison to deliver the best results. This is a loose analogy to traditional database and Big
Data technologies: Your information plat- form shouldnt go into the future without these
two important entities work- ing together, because the outcomes of a cohesive analytic
ecosystem deliver premium results in the same way your coordinated hands do for
baseball. There exists some class of problems that dont natively belong in traditional
databases, at least not at first. And theres data that were not sure we want in the
warehouse, because perhaps we dont know if its rich in value, its unstructured, or its
too voluminous. In many cases, we cant find out the value per byte of the data until after
we spend the effort and money to put it into the warehouse; but we want to be sure that
data is worth saving and has a high value per byte before investing in it.
Some organizations will need to rethink their data management strategies when they face
hundreds of gigabytes of data for the first time. Others may be fine until they reach tens or
hundreds of terabytes. But whenever an organization reaches the critical mass defined as
big data for itself, change is inevitable.
Organizations are moving away from viewing data integration as a standalone discipline to
a mindset where data integration, data quality, metadata management and data governance
are designed and used together. The traditional extract-transform-load (ETL) data
approach has been augmented with one that minimizes data movement and improves
processing power.
Organizations are also embracing a holistic, enterprise view that treats data as a
core enterprise asset. Finally, many organizations are retreating from reactive data
management in favor of a managed and ultimately more proactive and predictive approach
to managing information.
The true value of big data lies not just in having it, but in harvesting it for fast, factbased
decisions that lead to real business value. For example, disasters such as the recent
financial meltdown and mortgage crisis might have been prevented with risk computation
on historical data at a massive scale. Financial institutions were essentially taking bundles
of thousands of loans and looking at them as one. We now have the computing power to
assess the probability of risk at the individual level. Every sector can benefit from this
type of analysis.
Big data provides gigantic statistical samples, which enhance analytic tool results. The
general rule is that the larger the data sample, the more accurate are the statistics and other
products of the analysis. However, organizations have been limited to using subsets of
their data, or they were constrained to simplistic analysis because the sheer volume of data
overwhelmed their IT platforms. What good is it to collect and store terabytes of data if
you cant analyze it in full context, or if you have to wait hours or days to get results to
urgent questions? On the other hand, not all business questions are better served by bigger
data. Now, you have choices to suit both scenarios:
Incorporate massive data volumes in analysis. If the business question is one
that will get better answers by analyzing all the data, go for it. The game-changing
technologies that extract real business value from big data all of it are here today. One
approach is to apply high-performance analytics to analyze massive amounts of data using
technologies such as grid computing, in-database processing and in-memory analytics.
Determine upfront which data is relevant. The traditional modus operandi has
been to store everything; only when you query it do you discover what is relevant.
Oracle provides the ability to apply analytics on the front end to determine data relevance
based on enterprise context. This analysis can be used to determine which data should be
included in analytical processes and which can be placed in
low-cost storage for later availability if needed.
aggregate and structure big data. By combining data integration, data quality and
master data management in a unified development and delivery environment,
organizations can maximize each stage of the data management process.
Oracle is unique for incorporating high-performance analytics and analytical intelligence
into the data management process for highly efficient modeling and faster results.
For instance, you can analyze all the information within an organization such as
email, product catalogs, wiki articles and blogs extract important concepts from that
information, and look at the links among them to identify and assign weights to millions
of terms and concepts. This organizational context is then used to assess data as it streams
into the organization, churns out of internal systems, or sits in offline data stores. This upfront analysis identifies the relevant data that should be pushed to the enterprise data
warehouse or to high-performance analytics.
2Chapter 2.
HADOOP
The requirements in a big data infrastructure span data acquisition, data organization and
data analysis.
The acquisition phase is one of the major changes in infrastructure from the days before
big data. Because big data refers to data streams of higher velocity and higher variety, the
infrastructure required to support the acquisition of big data must deliver low, predictable
latency in both capturing data and in executing short, simple queries; be able to handle
very high transaction volumes, often in a distributed environment; and support flexible,
dynamic data structures.
NoSQL databases are frequently used to acquire and store big data. They are well suited
for dynamic data structures and are highly scalable. The data stored in a NoSQL database
is typically of a high variety because the systems are intended to simply capture all data
without categorizing and parsing the data into a fixed schema.
For example, NoSQL databases are often used to collect and store social media data.
While customer facing applications frequently change, underlying storage structures are
kept simple. Instead of designing a schema with relationships between entities, these
simple structures often just contain a major key to identify the data point, and then a
content container holding the relevant data (such as a customer id and a customer profile).
This simple and dynamic structure allows changes to take place without costly
reorganizations at the storage layer (such as adding new fields to the customer profile).
todays enterprises.
Figure 2-1
2.2 HADOOP
Hadoop is an open-source software framework for storing and processing big data in a
distributed fashion on large clusters of commodity hardware. Essentially, it accomplishes
two tasks: massive data storage and faster processing.
For starters, lets take a quick look at some of those terms and what they mean.
Open-source software. Open source software differs from commercial software due to
the broad and open network of developers that create and manage the programs.
Traditionally, its free to download, use and contribute to, though more and more
commercial versions of Hadoop are becoming available.
Framework. In this case, it means everything you need to develop and run your
volumes of data. The more computing nodes you use, the more processing power you
have.
Scalability. You can easily grow your system simply by adding more nodes. Little
administration is required.
Storage flexibility. Unlike traditional relational databases, you dont have to preprocess
data before storing it. And that includes unstructured data like text, images and videos.
You can store as much data as you want and decide how to use it later.
processing are protected against hardware failure. If a node goes down, jobs are
automatically redirected to other nodes to make sure the distributed computing does not
fail. And it automatically stores multiple copies of all data.
Figure 2-2
Other components that have achieved top-level Apache project status and are available
include:
Hive a data warehousing and SQL-like query language that presents data in
the form of tables. Hive programming is similar to database programming. (It
was initially developed by Facebook.)
In addition, commercial software distributions of Hadoop are growing. Two of the most
prominent (Cloudera and Hortonworks) are startups formed by the frameworks inventors.
And there are plenty of others entering the Hadoop sphere. With distributions from
software vendors, you pay for their version of the framework and receive additional
software components, tools, training, documentation and other services.
Its inexpensive. Hadoop uses lower-cost commodity hardware to reliably store large
quantities of data.
You can upload unstructured data without having to schematize it first. Dump any
type of data into Hadoop and apply structure as needed for consuming applications.
If capacity is available, Hadoop will start multiple copies of the same task for the same
block of data. If a node goes down, jobs are automatically redirected to other working
servers.
Data security is fragmented, but new tools and technologies are surfacing.
MapReduce is very batch-oriented and not suitable for iterative, multi-step analytics
processing.
The Hadoop ecosystem does not have easy-to-use, full-feature tools for data
integration, data cleansing, governance and metadata. Especially lacking are tools for
data quality and standardization.
Skilled professionals with specialized Hadoop skills are in short supply and at a
premium.
MapReduce is file intensive. And because the nodes dont intercommunicate except
through sorts and shuffles, iterative algorithms require multiple map-shuffle/sort-reduce
phases to complete. This creates multiple files between MapReduce phases and is very
inefficient for advanced analytic computing.
Hadoop definitely provides economical data storage. But the next step is to manage the
data and use analytics to quickly identify previously unknown insights. Enter SAS. More
on that later.
If you have a large number of files, a shell script that will run multiple put commands
in parallel will speed up the process. You dont have to write MapReduce code.
Create a cron job to scan a directory for new files and put them in HDFS as they
show up. This is useful for things like downloading email at regular intervals.
Mount HDFS as a file system and simply copy files or write files there.
Use Sqoop to import structured data from a relational database to HDFS, Hive and
HBase. It can also extract data from Hadoop and export it to relational databases and
data warehouses.
2.5 HADOOP USES
Going beyond its original goal of searching millions (or billions) of web pages and
returning relevant results, many organizations are looking to Hadoop as their next big data
platform. Here are some of the more popular uses for the framework today.
Low-cost storage and active data archive. The modest cost of commodity hardware
makes Hadoop useful for storing and combining big data such as transactional, social
media, sensor, machine, scientific, click streams, etc. The low-cost storage lets you
keep information that is not currently critical but could become useful later for business
analytics.
Staging area for a data warehouse and analytics store. One of the most prevalent
uses is to stage large amounts of raw data for loading into an enterprise data warehouse
(EDW) or an analytical store for activities such as advanced analytics, query and
reporting, etc. Organizations are looking at Hadoop to handle new types of data (e.g.,
unstructured), as well as to offload some historical data from their EDWs.
Data lake. Hadoop is often used to store large amounts of data without the constraints
introduced by schemas commonly found in the SQL-based world. It is used as a lowcost compute-cycle platform that supports processing ETL and data quality jobs in
parallel using hand-coded or commercial data management technologies. Refined
results can then be passed to other systems (e.g., EDWs, analytic marts) as needed.
Sandbox for discovery and analysis. Because Hadoop was designed to deal with
volumes of data in a variety of shapes and forms, it can enable analytics. Big data
analytics on Hadoop will help run current business more efficiently, uncover new
opportunities and derive next-level competitive advantage. The sandbox setup provides
a quick and perfect opportunity to innovate with minimal investment.
Certainly Hadoop provides an economical platform for storing and processing large and
diverse data. The next logical step is to transform and manage the diverse data and use
analytics to quickly identify undiscovered insights.
Hadoop is providing a data storage and analytical processing environment for a variety of
business uses, including:
Health and life sciences: Genomics data in medical trials and prescription adherence.
Oil and gas and other utilities: Predict asset failures, improve asset utilization and
monitor equipment safety.
3Chapter 3.
3.1 INTRODUCTION
Oracle provides a big data platform that captures, organizes, and supports deep analytics
on extremely large, complex data streams flowing into your enterprise from many data
sources. You can choose the best storage and processing location for your data depending
on its structure, workload characteristics, and end-user requirements.
Oracle Database enables all data to be accessed and analyzed by a large user community
using identical methods. By adding Oracle Big Data Appliance in front of Oracle
Database, you can bring new sources of information to an existing data warehouse. Oracle
Big Data Appliance is the platform for acquiring and organizing big data so that the
relevant portions with true business value can be analyzed in Oracle Database.
For maximum speed and efficiency, Oracle Big Data Appliance can be connected to
Oracle Exadata Database Machine running Oracle Database. Oracle Exadata Database
Machine provides outstanding performance in hosting data warehouses and transaction
processing databases. Moreover, Oracle Exadata Database Machine can be connected to
Oracle Exalytics In-Memory Machine for the best performance of business intelligence
and planning applications. The InfiniBand connections between these engineered systems
provide high parallelism, which enables high-speed data transfer for batch or query
workloads.
The next figure shows the relationships among these engineered systems.
system that stores large files across multiple servers. It achieves reliability by
replicating data across multiple servers without RAID technology. It runs on top of the
Linux file system on Oracle Big Data Appliance.
MapReduce engine: The MapReduce engine provides a platform for the massively
parallel execution of algorithms written in Java. Oracle Big Data Appliance 3.0 runs
YARN by default.
Administrative framework: Cloudera Manager is a comprehensive administrative
tool for CDH. In addition, you can use Oracle Enterprise Manager to monitor both the
hardware and software on Oracle Big Data Appliance.
Apache projects: CDH includes Apache projects for MapReduce and HDFS, such as
Cloudera Enterprise Data Hub Edition, including Impala, Search, and Navigator.
CDH is written in Java, and Java is the language for applications development. However,
several CDH utilities and other software available on Oracle Big Data Appliance provide
graphical, web-based, and other language interfaces for ease of use.
The best tool for each task depends on the density of the information and the degree of
structure. The next figure shows the relationships among the tools and identifies the tasks
that they perform.
The next figure shows the Oracle Big Data Appliance Software structutre
Oracle NoSQL Database is designed to provide highly reliable, scalable, predictable, and
available data storage. The key-value pairs are stored in shards or partitions (that is,
subsets of data) based on a primary key. Data on each shard is replicated across multiple
storage nodes to ensure high availability. Oracle NoSQL Database supports fast querying
of the data, typically by key lookup.
An intelligent driver links the NoSQL database with client applications and provides
access to the requested key-value on the storage node with the lowest latency.
Oracle NoSQL Database includes hashing and balancing algorithms to ensure proper data
distribution and optimal load balancing, replication management components to handle
storage node failure and recovery, and an easy-to-use administrative interface to monitor
the state of the database.
Oracle NoSQL Database is typically used to store customer profiles and similar data for
identifying and analyzing big data. For example, you might log in to a website and see
advertisements based on your stored customer profile (a record in Oracle NoSQL
Database) and your recent activity on the site (web logs currently streaming into HDFS).
Oracle NoSQL Database is an optional component of Oracle Big Data Appliance and runs
on a separate cluster from CDH.
3.8 MAPREDUCE
The MapReduce engine provides a platform for the massively parallel execution of
algorithms written in Java. MapReduce uses a parallel programming model for processing
data on a distributed system. It can process vast amounts of data quickly and can scale
linearly. It is particularly effective as a mechanism for batch processing of unstructured
and semistructured data. MapReduce abstracts lower-level operations into computations
over a set of keys and values.
Although big data is often described as unstructured, incoming data always has some
structure. However, it does not have a fixed, predefined structure when written to HDFS.
Instead, MapReduce creates the desired structure as it reads the data for a particular job.
The same data can have many different structures imposed by different MapReduce jobs.
A simplified description of a MapReduce job is the successive alternation of two phases:
the Map phase and the Reduce phase. Each Map phase applies a transform function over
each record in the input data to produce a set of records expressed as key-value pairs. The
output from the Map phase is input to the Reduce phase. In the Reduce phase, the Map
output records are sorted into key-value sets, so that all records in a set have the same key
value. A reducer function is applied to all the records in a set, and a set of output records is
produced as key-value pairs. The Map phase is logically run in parallel over each record,
whereas the Reduce phase is run in parallel over all key values.
Oracle Big Data Appliance uses the Yet Another Resource Negotiator (YARN)
implementation of MapReduce by default. You have the option of using classic
MapReduce (MRv1) instead. You cannot use both implementations in the same cluster;
you can activate either the MapReduce or the YARN service.
Oracle R Enterprise enables you to store the results of your analysis of big data in an
Oracle database, or accessed for display in dashboards and applications.
Both Oracle R Advanced Analytics for Hadoop and Oracle R Enterprise make Oracle
Database and the Hadoop computational infrastructure available to statistical users
without requiring them to learn the native programming languages of either one.
3.13.4 Mobile BI
Business doesnt stop just because youre on the go. Make sure critical information is
reaching you wherever you are.
4Chapter 4.
InfiniBand network: Network topology and status for InfiniBand switches and ports.
See the net figure.
Oracle Big Data Appliance rack: Hardware status including server hosts, Oracle
Integrated Lights Out Manager (Oracle ILOM) servers, power distribution units
(PDUs), and the Ethernet switch.
The next figure shows a small section of the cluster home page. YARN Page in Oracle
Enterprise Manager
3. From the Targets menu, choose Big Data Appliance to view the Big Data page. You
can see the overall status of the targets already discovered by Oracle Enterprise
Manager.
5. Expand the target navigation tree to display the components. Information is available at
all levels.
7. To change the display, choose an item from the drop-down menu at the top left of the
main display area.
Cloudera Manager runs on the ResourceManager node (node03) and is available on port
7180.
To use Cloudera Manager:
Open a browser and enter a URL like the following:
http://bda1node03.example.com:7180
In this example, bda1 is the name of the appliance, node03 is the name of the server,
example.com is the domain, and 7180 is the default port number for Cloudera Manager.
Log in with a user name and password for Cloudera Manager. Only a user with
administrative privileges can change the settings. Other Cloudera Manager users can view
the status of Oracle Big Data Appliance.
Hosts: Monitors the health, disk usage, load, physical memory, swap space, and other
statistics for all servers in the cluster.
Diagnostics: Accesses events and logs. Cloudera Manager collects historical
information about the systems and services. You can search for a particular phrase for a
selected server, service, and time period. You can also select the minimum severity
level of the logged messages included in the search: TRACE, DEBUG, INFO, WARN,
ERROR, or FATAL.
Audits: Displays the audit history log for a selected time range. You can filter the
results by user name, service, or other criteria, and download the log as a CSV file.
Charts: Enables you to view metrics from the Cloudera Manager time-series data store
in a variety of chart types, such as line and bar.
Hive
Hue
Oozie
YARN
ZooKeeper
You can use Cloudera Manager to change the configuration of these services, stop, and
restart them. Additional services are also available, which require configuration before
you can use them
http://bda1node01.example.com:50070
In this example, bda1 is the name of the rack, node01 is the name of the server where the
dfshealth utility runs, and 50070 is the default port number for the user interface.
The next figure shows the DFS health utility interface.
Hue is automatically installed and configured on Oracle Big Data Appliance. It runs on
port 8888 of the ResourceManager node (node03).
To use Hue:
Log in to Cloudera Manager and click the hue service on the Home page.
Bookmark the Hue URL, so that you can open Hue directly in your browser. The
following URL is an example:
http://bda1node03.example.com:8888
Log in with your Hue credentials.
Oracle Big Data Appliance is not configured initially with any Hue user accounts. The
first user who connects to Hue can log in with any user name and password, and
automatically becomes an administrator. This user can create other user and administrator
accounts.
The next figure shows the Hive Query Editor.
Unconfigured Software
Oracle Linux 6.4 (upgrades stay at 5.8) with Oracle Unbreakable Enterprise Kernel
version 2 (UEK2)
Mammoth installation:
The next figure shows the relationships among the major Major Software Components of
Oracle Big Data Appliance.
Apache HBase
Apache Spark
Apache Sqoop
Cloudera Impala
Cloudera Navigator
Cloudera Search
To add a service:
1. Log in to Cloudera Manager as the admin user.
2.
On the Home page, expand the cluster menu in the left panel and choose Add a
Service to open the Add Service wizard. The first page lists the services you can add.
You can find the RPM files on the first server of each cluster in
/opt/oracle/BDAMammoth/bdarepo/RPMS/noarch.
Open the Clusters menu at the top of the page, then select Static Service Pools under
Resource Management.
Select Configuration.
Follow the steps of the wizard, or click Change Settings Directly to edit the current
settings.
4.6.1 Prerequisites
You must have root access. Passwordless SSH must be set up on the cluster, so that you
can use the dcli utility.
To ensure that passwordless-ssh is set up:
Log in to the first node of the cluster as root.
Use a dcli command to verify it is working. This command should return the IP address
and host name of every node in the cluster:
# dcli -C hostname
192.0.2.1: bda1node01.example.com
192.0.2.2: bda1node02.example.com
.
.
.
If you do not get these results, then set up dcli on the cluster:
# setup-root-ssh -C
4.6.2 Stopping Oracle Big Data Appliance
Follow these procedures to shut down all Oracle Big Data Appliance software and
hardware components.
Note:
The following services stop automatically when the system shuts down. You do not need
to take any action:
Oracle Enterprise Manager agent
After stopping Cloudera Manager, you cannot access it using the web
console.
# dcli -C service odi-agent stop
# dcli -C service odi-agent status
# dcli -g filename shutdown -h now
For filename, enter the name of the file that you created in step 1.
3. Stop the server you are logged in to:
# shutdown -h now
$ mount-hadoop-dirs
Enter password to mount Hadoop directories: password
If the servers do not start automatically, then you can start them locally by
pressing the power button on the front of the servers, or remotely by using
Oracle ILOM. Oracle ILOM has several interfaces, including a commandline interface (CLI) and a web console. Use whichever interface you prefer.
For example, you can log in to the web interface as root and start the server
from the Remote Power Control page. The URL for Oracle ILOM is the
same as for the host, except that it typically has a -c or -ilom extension.
This URL connects to Oracle ILOM for bda1node4:
http://bda1node04-ilom.example.com
# service cloudera-scm-server status
cloudera-scm-server (pid 11399) is running
# service cloudera-scm-server start
5. In the Status pane of the opening page, expand the menu for the cluster and
click Start, and then click Start again when prompted to confirm. See the next
figure.
To navigate to this page, click the Home tab, and then the Status subtab.
6. On the Command Details page, click Close when all processes are started.
7. In the same pane under Cloudera Management Services, expand the menu
for the mgmt service and click Start.
#
/opt/oracle/odiagent/agent_standalone/oracledi/agent/bin/startcmd.sh
OdiPingAgent [-AGENT_NAME=agent_name]
#
/opt/oracle/odiagent/agent_standalone/oracledi/agent/bin/agent.sh
NAME=agent_name] [-PORT=port_number]
[-
4.7 MANAGING ORACLE BIG DATA SQL
Oracle Big Data SQL is registered with Cloudera Manager as an add-on service. You can
use Cloudera Manager to start, stop, and restart the Oracle Big Data SQL service or
individual role instances, the same way as a CDH service.
Cloudera Manager also monitors the health of the Oracle Big Data SQL service, reports
service outages, and sends alerts if the service is not healthy.
4.7.1 Adding and Removing the Oracle Big Data SQL Service
Oracle Big Data SQL is an optional service on Oracle Big Data Appliance. It may be
installed with the other client software during the initial software installation or an
upgrade. Use Cloudera Manager to determine whether it is installed. A separate license is
required; Oracle Big Data SQL is not included with the Oracle Big Data Appliance
license.
You cannot use Cloudera Manager to add or remove the Oracle Big Data SQL service
from a CDH cluster on Oracle Big Data Appliance. Instead, log in to the server where
Mammoth is installed (usually the first node of the cluster) and use the following
commands in the bdacli utility:
To enable Oracle Big Data SQL
bdacli enable big_data_sql
4.
Under Category, expand BDS Server Default Group and click Resource
Management.
a. Locate YARN in the list of services on the Status tab of the Home page.
b. Expand the YARN menu and click Stop.
3. On the cluster menu, click Add a Service to start the Add Service wizard:
JobTracker: Click the field to display a list of nodes in the cluster. Select the third node.
TaskTracker: For a six-node cluster, keep the TaskTrackers on all nodes (default). For
larger clusters, remove the TaskTrackers from the first two nodes.
d. On the Review Changes page, change the parameter values:
TaskTracker Local Data Directory List: Change the default group and group 1
to /u12/hadoop/mapred../u01/hadoop/mapred.
JobTracker Local Data Directory List: Change the default group to
/u12/hadoop/mapred../u01/hadoop/mapred.
e. Complete the steps of the wizard with no further changes. Click Finish to save
the configuration and exit.
a. On the Status tab of the Home page, click hive to display the hive page.
b. Expand the Configuration submenu and click View and Edit.
c. Select mapreduce as the value of the MapReduce Service property.
d. Click Save Changes.
6.
On the Status tab of the Home page, expand the hive and oozie menus and choose
Restart.
If you retain the yarn service, then after every cluster restart, you will see Memory
overcommit validation warnings, and you must manually stop the yarn service.
8. Update the MapReduce service configuration:
a. On the Status tab of the Home page, click mapreduce to display the
mapreduce page.
c.
Under Category, expand TaskTracker Default Group, and then click
Resource Management.
Java Heap Size of TaskTracker in Bytes: Reset to the default value of 1 GiB.
Maximum Number of Simultaneous Map Tasks: Set to either 15 for Sun Fire
X4270 M2 racks or 20 for all other racks.
Maximum Number of Simultaneous Reduce Tasks: Set to either 10 for Sun
Fire X4270 M2 racks or 13 for all other racks.
e. Click Save Changes.
9. Add overrides for nodes 3 and 4 (or nodes 1 and 2 in a six-node cluster).
11. Expand the Actions menu and select Enable High Availability to start the Enable
JobTracker High Availability wizard:
a. On the Assign Roles page, select the fourth node (node04) for the Standby
JobTracker.
b. Complete the steps of the wizard with no further changes. Click Finish to
save the configuration and exit.
12. Verify that all services in the cluster are healthy with no configuration issues.
4.9 SECURITY ON ORACLE BIG DATA APPLIANCE
You can take precautions to prevent unauthorized use of the software and data on Oracle
Big Data Appliance.
This section contains these topics:
1. About Predefined Users and Groups
User
Group
Name
Used By
Login
Rights
flume
flume
No
hbase
hbase
No
hdfs
hadoop
NameNode, DataNode
No
hive
hive
No
hue
hue
Hue processes
No
mapred
hadoop
mysql
mysql
MySQL server
Yes
oozie
oozie
Oozie server
No
oracle
dba,
oinstall
Yes
puppet
puppet
No
sqoop
sqoop
No
No
svctag
No
2. In the Name column, click a server link to see its detail page.
Oracle Big Data Appliance Port Numbers
Service
Port
30920
60010
MySQL Database
3306
20910
5001
5010 to 5020
5000
Port map
111
8140
Puppet node service
8139
rpc.statd
668
ssh
22
6481
2. Captures activity on Oracle Database, Oracle Big Data Appliance, operating systems,
directories, file systems, and so forth.
3. Makes the auditing information available in a single reporting framework so that you
can understand the activities across the enterprise. You do not need to monitor each
system individually; you can view your computer infrastructure as a whole.
Audit Vault Server provides a web-based, graphic user interface for both administrators
and auditors.
You can configure CDH/Hadoop clusters on Oracle Big Data Appliance as secured targets.
The Audit Vault plug-in on Oracle Big Data Appliance collects audit and logging data
from these services:
1. HDFS: Who makes changes to the file system.
The Audit Vault plug-in is an installation option. The Mammoth utility automatically
configures monitoring on Oracle Big Data Appliance as part of the software installation
process.
2. Complete the Audit Vault Plug-in section of Oracle Big Data Appliance Configuration
Generation Utility.
3. Install the Oracle Big Data Appliance software using the Mammoth utility. An Oracle
representative typically performs this step.
You can also add the plug-in at a later time using either bdacli or mammoth-reconfig.
When the software installation is complete, the Audit Vault plug-in is installed on Oracle
Big Data Appliance, and Oracle Audit Vault and Database Firewall is collecting its audit
information. You do not need to perform any other installation steps.
4. To browse all activities, in the Activity Reports list, click the Browse report data icon
for All Activity.
5. Add or remove the filters to list the events. Event names include ACCESS, CREATE,
DELETE, and OPEN.
6. Click the Single row view icon in the first column to see a detailed report.
The next figure shows the beginning of an activity report, which records access to a
Hadoop sequence file.
2.
Run bdadiag with at least the cm option. You can include additional options on the
command line as appropriate.
# bdadiag cm
The command output identifies the name and the location of the diagnostic file.
3. Go to My Oracle Support at http://support.oracle.com.
4. Open a Service Request (SR) if you have not already done so.
5.
Upload the bz2 file into the SR. If the file is too large, then upload it to
sftp.oracle.com, as described in the next procedure.
Open an SFTP client and connect to sftp.oracle.com. Specify port 2021 and remote
directory /support/incoming/target, where target is the folder name given to you by
Oracle Support.
9. Update the SR with the full path and the file name.
4.12.1 Configuration
In this scenario, weve set up auditing for both the BDA and Oracle Database 12c.
The Audit Vault Server is deployed to its own secure server and serves as mission control
for auditing. It is used to administer audit policies, configure activities that are tracked on
the secured targets and provide robust audit reporting and alerting. In many ways, Audit
Vault is a specialized auditing data warehouse. It automates ETL from a variety of sources
into an audit schema and then delivers both pre-built and ad hoc reporting capabilities.
For our demonstration, Audit Vault agents are deployed to the BDA and Oracle Database
12c monitored targets; these agents are responsible for managing collectors that gather
activity data. This is a secure agent deployment; the Audit Vault Server has a trusted
relationship with each agent. To set up the trusted relationship, the agent makes an
activation request to the Audit Vault Server; this request is then activated (or approved)
by the AV Administrator. The monitored target then applies an AV Server generated Agent
Activation Key to complete the activation.
On the BDA, these installation and configuration steps have all been automated for you.
Using the BDAs Configuration Generation Utility, you simply specify that you would like
to audit activity in Hadoop. Then, you identify the Audit Vault Server that will receive the
audit data. Mammoth - the BDAs installation tool - uses this information to configure the
audit processing. Specifically, it sets up audit trails across the following services:
HDFS: collects all file access activity
MapReduce: identifies who ran what jobs on the cluster
Oozie: audits who ran what as part of a workflow
Hive: captures changes that were made to the Hive metadata
There is much more flexibility when monitoring the Oracle Database. You can create audit
policies for SQL statements, schema objects, privileges and more. Check out the auditors
guide for more details. In our demonstration, we kept it simple: we are capturing all select
statements on the sensitive HR.EMPLOYEES table, all statements made by the HR user
and any unsuccessful attempts at selecting from any table in any schema.
Now that we are capturing activity across the BDA and Oracle Database 12c, well set up
an alert to fire whenever there is suspicious activity attempted over sensitive HR data in
Hadoop:
In the alert definition found above, a critical alert is defined as three unsuccessful attempts
from a given IP address to access data in the HR directory. Alert definitions are extremely
flexible - using any audited field as input into a conditional expression. And, they are
automatically delivered to the Audit Vault Servers monitoring dashboard - as well as via
email to appropriate security administrators.
Now that auditing is configured, well generate activity by two different users: oracle and
DrEvil. Well then see how the audit data is consolidated in the Audit Vault Server and
how auditors can interrogate that data.
Drilling down on the alert reveals DrEvils three failed attempts to access the sensitive
data in HDFS:
Now that we see the alert triggered in the dashboard, lets see what other activity is taking
place on the BDA and in the Oracle Database.
As you can see, the report tells you all of the key elements required to understand: 1)
when the activity took place, 2) the source service for the event, 3) what object was
referenced, 4) whether or not the event was successful, 5) who executed the event, 6) the
ip address (or host) that initiated the event, and 7) how the object was modified or
accessed. Stoplight reporting is used to highlight critical activity - including DrEvils failed
attempts to open the sensitive salaries.txt file.
Notice, events may be related to one another. The Hive command ALTER TABLE
my_salarys RENAME TO my_salaries will generate two events. The first event is
sourced from the Metastore; the alter table command is captured and the metadata
definition is updated. The Hive command also impacts HDFS; the table name is
represented by an HDFS folder. Therefore, an HDFS event is logged that renames the
my_salarys folder to my_salaries.
Next, consider an Oozie workflow that performs a simple task: delete a file salaries2.txt
in HDFS. This Oozie worflow generates the following events:
1. First, an Oozie workflow event is generated indicating the start of the workflow.
2. The workflow definition is read from the workflow.xml file found in HDFS.
3. An Oozie working directory is created
4. The salaries2.txt file is deleted from HDFS
5. Oozie runs its clean-up process
The Audit Vault reports are able to reveal all of the underlying activity that is executed by
the Oozie workflow. Its flexible reporting allows you to sequence these independent
events into a logical series of related activities.
The reporting focus so far has been on Hadoop - but one of the core strengths of Oracle
Audit Vault is its ability to consolidate all audit data. We know that DrEvil had a few
unsuccessful attempts to access sensitive salary data in HDFS. But, what other
unsuccessful events have occured recently across our data platform? Well use Audit
Vaults ad hoc reporting capabilities to answer that question. Report filters enable users to
search audit data based on a range of conditions. Here, well keep it pretty simple; lets
find all failed access attempts across both the BDA and the Oracle Database within the last
two hours:
Again, DrEvils activity stands out. As you can see, DrEvil is attempting to access
sensitive salary data not only in HDFS - but also in the Oracle Database.
4.12.4 Summary
Security and integration with the rest of the Oracle ecosystem are two tablestakes that are
critical to Oracle Big Data Appliance releases. Oracle Audit Vault and Database Firewalls
auditing of data across the BDA, databases and operating systems epitomizes this goal providing a single repository and reporting environment for all your audit data.
5Chapter 5.
5.1 INTRODUCTION
Big Data SQL is Oracles unique approach to providing unified query over data in Oracle
Database, Hadoop, and select NoSQL datastores. Oracle Big Data SQL supports queries
against vast amounts of big data stored in multiple data sources, including Hadoop. You
can view and analyze data from various data stores together, as if it were all stored in an
Oracle database.
Using Oracle Big Data SQL, you can query data stored in a Hadoop cluster using the
complete SQL syntax. You can execute the most complex SQL SELECT statements
against data in Hadoop, either manually or using your existing applications, to tease out
the most significant insights.
Two zip files are contained within the archive. Unzip the JDBC4 archive to a target
directory that is accessible to SQL Developer (e.g. /home/oracle/jdbc below):
unzip Cloudera_HiveJDBC4_2.5.4.1006.zip -d /home/oracle/jdbc/
Now that the JDBC drivers have been extracted, update SQL Developer to use the new
drivers.
UPDATE SQL DEVELOPER TO USE THE CLOUDERA HIVE JDBC DRIVERS
Update the preferences in SQL Developer to leverage the new drivers:
Start SQL Developer
Go to Tools -> Preferences
Navigate to Database -> Third Party JDBC Drivers
Add all of the jar files contained in the zip to the Third-party JDBC Driver Path. It
should look like the picture below:
Restart SQL Developer
CREATE A CONNECTION
Now that SQL Developer is configured to access Hive, lets create a connection to
Hiveserver2. Click the New Connection button in the SQL Developer toolbar. Youll need
to have an ID, password and the port where Hiveserver2 is running:
The example above is creating a connection called hive which connects to Hiveserver2 on
localhost running on port 10000. The Database field is optional; here we are specifying the
default database.
And, you can use the SQL Worksheet to run custom queries, perform DDL operations whatever is supported in Hive:
Here, weve altered the definition of a hive table and then queried that table in the
worksheet.
5.7.3 Create Big Data SQL-enabled Tables Using Oracle Data Modeler
Oracle Data Modeler automates the definition of Big Data SQL-enabled external tables.
Lets create a few tables using the metadata from the Hive Metastore. Invoke the import
wizard by selecting the File->Import->Data Modeler->Data Dictionary menu item. You
will see the same connections found in the SQL Developer connection navigator:
After selecting the hive connection and a database, select the tables to import:
There could be any number of tables here - in our case we will select three tables to
import. After completing the import, the logical table definitions appear in our palette:
You can update the logical table definitions - and in our case we will want to do so. For
example, the recommended column in Hive is defined as a string (i.e. there is no
precision) - which the Data Modeler casts as a varchar2(4000). We have domain
knowledge and understand that this field is really much smaller - so well update it to the
appropriate size:
Now that were comfortable with the table definitions, lets generate the DDL and create
the tables in Oracle Database 12c. Use the Data Modeler DDL Preview to generate the
DDL for those tables - and then apply the definitions in the Oracle Database SQL
Worksheet:
You can update the source cluster for the data, how invalid records should be processed,
how to map hive table columns to the corresponding Oracle table columns (if they dont
match), and much more.
5.8.2 About the Access Drivers for Oracle Big Data SQL
By querying external tables, you can access data stored in HDFS and Hive tables as if that
data was stored in tables in an Oracle database. Oracle Database accesses the data by
using the metadata provided when the external table was created.
Oracle Database 12.1.0.2 supports two new access drivers for Oracle Big Data SQL:
1. ORACLE_HIVE: Enables you to create Oracle external tables over Apache Hive data
sources. Use this access driver when you already have Hive tables defined for your
HDFS data sources. ORACLE_HIVE can also access data stored in other locations,
such as HBase, that have Hive tables defined for them.
2.
ORACLE_HDFS: Enables you to create Oracle external tables directly over files
stored in HDFS. This access driver uses Hive syntax to describe a data source,
assigning default column names of COL_1, COL_2, and so forth. You do not need to
create a Hive table manually as a separate step.
Instead of acquiring the metadata from a Hive metadata store the way that
ORACLE_HIVE does, the ORACLE_HDFS access driver acquires all of the necessary
information from the access parameters. The ORACLE_HDFS access parameters are
required to specify the metadata, and are stored as part of the external table definition in
Oracle Database.
Oracle Big Data SQL uses these access drivers to optimize query performance.
2.
3. On-disk encryption: Protects the data on disk and at rest. For normal user access, the
data is automatically decrypted.
4.
Oracle Audit Vault and Database Firewall monitoring: The Audit Vault plug-in on
Oracle Big Data Appliance collects audit and logging data from MapReduce, HDFS,
and Oozie services. You can then use Audit Vault Server to monitor these services on
Oracle Big Data Appliance
Oracle Big Data SQL adds the full range of Oracle Database security features to this list.
You can apply the same security policies and rules to your Hadoop data that you apply to
your relational data.
Compute servers run Oracle Database and Oracle Enterprise Manager Grid Control
12.1.0.2 or later.
3.
4. Oracle Exadata Database Machine is connected to Oracle Big Data Appliance by the
InfiniBand network.
3. On Oracle Big Data Appliance, install or upgrade the software to the latest version.
4. You can select Oracle Big Data SQL as an installation option when using the Oracle
Big Data Appliance Configuration Generation Utility.
5. Download and install Mammoth patch 18064328 from Oracle Automated Release
Updates.
6. If Oracle Big Data SQL is not enabled during the installation, then use the bdacli
utility:
# bdacli enable big_data_sql
8. You can use Cloudera Manager to verify that Oracle Big Data SQL is up and running.
5.9.3 Running the Post-Installation Script for Oracle Big Data SQL
To run the Oracle Big Data SQL post-installation script:
1. On Oracle Exadata Database Machine, ensure that the Oracle Database listener is
running and listening on an interprocess communication (IPC) interface.
2. Verify the name of the Oracle installation owner. Typically, the oracle user owns the
installation.
3. Verify that the same user name (such as oracle) exists on Oracle Big Data Appliance.
4. Download the bds-exa-install.sh installation script from the node where Mammoth is
installed, typically the first node in the cluster. You can use a command such as wget or
curl. This example copies the script from bda1node07:
wget http://bda1node07/bda/bds-exa-install.sh
5. As root, run the script and pass it the system identifier (SID). In this example, the SID
is orcl:
./bds-exa-install.sh oracle_sid=orcl
When the script completes, Oracle Big Data SQL is running on the database instance.
However, if events cause the Oracle Big Data SQL agent to stop, then you must restart it.
You specify the column names and data types the same as for any other table.
ORGANIZATION EXTERNAL identifies the table as an external table.
The external_table_clause identifies the access driver and provides the information that it
needs to load the data. See About the External Table Clause.
You can obtain this information by querying the ALL_HIVE_TABLES data dictionary
view. It displays information about all Hive tables that you can access from Oracle
Database.
This example shows that the current user has access to an unpartitioned Hive table named
RATINGS_HIVE_TABLE in the default database. A user named JDOE is the owner.
SQL> SELECT cluster_id, database_name, owner, table_name, partitioned FROM all_hive_tables;
CLUSTER_ID DATABASE_NAME OWNER TABLE_NAME PARTITIONED
hadoop1 default jdoe ratings_hive_table UN-PARTITIONED
You can query these data dictionary views to discover information about
When this procedure runs, the PUT_LINE function displays the CREATE TABLE
command:
CREATE TABLE ratings_db_table (
c0 VARCHAR2(4000),
c1 VARCHAR2(4000),
c2 VARCHAR2(4000),
c3 VARCHAR2(4000),
c4 VARCHAR2(4000),
c5 VARCHAR2(4000),
c6 VARCHAR2(4000),
c7 VARCHAR2(4000))
ORGANIZATION EXTERNAL
(TYPE ORACLE_HIVE DEFAULT DIRECTORY DEFAULT_DIR
ACCESS PARAMETERS
(
com.oracle.bigdata.cluster=hadoop1
com.oracle.bigdata.tablename=default.ratings_hive_table
)
) PARALLEL 2 REJECT LIMIT UNLIMITED
You can capture this information in a SQL script, and use the access parameters to change
the Oracle table name, the column names, and the data types as desired before executing
it. You might also use access parameters to specify a date format mask.
The ALL_HIVE_COLUMNS view shows how the default column names and data types
are derived. This example shows that the Hive column names are C0 to C7, and that the
Hive STRING data type maps to VARCHAR2(4000):
Because no access parameters are set in the statement, the ORACLE_HIVE access driver
uses the default settings to do the following:
Connects to the default Hadoop cluster.
Uses a Hive table named order. An error results if the Hive table does not have fields
named CUST_NUM, ORDER_NUM, DESCRIPTION, and ORDER_TOTAL.
Sets the value of a field to NULL if there is a conversion error, such as a CUST_NUM
value longer than 10 bytes.
You can set properties in the ACCESS PARAMETERS clause of the external table clause,
which override the default behavior of the access driver. The following clause includes the
com.oracle.bigdata.overflow access parameter. When this clause is used in the previous
example, it truncates the data for the DESCRIPTION column that is longer than 100
characters, instead of throwing an error:
(TYPE oracle_hive
ACCESS PARAMETERS (
com.oracle.bigdata.overflow={action:truncate, col:DESCRIPTION} ))
1.
The next example sets most of the available parameters for ORACLE_HIVE:
com.oracle.bigdata.erroropt: [{action:replace, \
value:INVALID_NUM , \
col:[CUST_NUM,ORDER_NUM]} ,\
{action:reject, \
col:ORDER_TOTAL}
]
The parameters make the following changes in the way that the ORACLE_HIVE access
driver locates the data and handles error conditions:
Because no access parameters are set in the statement, the ORACLE_HDFS access driver
uses the default settings to do the following:
Connects to the default Hadoop cluster.
Reads the files as delimited text, and the fields as type STRING.
Assumes that the number of fields in the HDFS files match the number of columns
(three in this example).
Assumes the fields are in the same order as the columns, so that CUST_NUM data is in
the first field, ORDER_NUM data is in the second field, and ORDER_TOTAL data is
in the third field.
Rejects any records in which the value causes a data conversion error: If the value for
CUST_NUM exceeds 10 characters, the value for ORDER_NUM exceeds 20
characters, or the value of ORDER_TOTAL cannot be converted to NUMBER.
The following example is equivalent to the one shown in Overriding the Default
ORACLE_HIVE Settings. The external table access a delimited text file stored in HDFS.
The parameters make the following changes in the way that the ORACLE_HDFS access
driver locates the data and handles error conditions:
The access parameters provide the following information to the ORACLE_HDFS access
driver:
com.oracle.bigdata.rowformat: Identifies the SerDe that the access driver needs to use
to parse the records and fields. The files are not in delimited text format.
com.oracle.bigdata.fileformat: Identifies the Java classes that can extract records and
output them in the desired format.
com.oracle.bigdata.colmap: Handles differences in column names. ORACLE_HDFS
matches ORDER_LINE_ITEM_COUNT in the HDFS files with the ITEM_CNT
column in the external table.
com.oracle.bigdata.overflow: Truncates string data. Values longer than 100 characters
for the DESCRIPTION column are truncated.
LOCATION Clause
name,
such
as
The file names can contain any pattern-matching character described in the next table.
Pattern-Matching Characters
Character
Description
[abc]
[a-b]
Matches one character in the range {ab}. The character must be less
than or equal to b.
[^a]
Matches one character that is not in the character set or range {a}. The
carat (^) must immediately follow the left bracket, with no spaces.
\c
{ab\,cd}
Matches a string from the set {ab, cd}. The escape character (\) removes
the meaning of the comma as a path separator.
{ab\,c{de\,fh}
Matches a string from the set {ab, cde, cfh}. The escape character (\)
removes the meaning of the comma as a path separator.
stored in Hive, and the access parameters and the metadata store provide the necessary
information.
Hive
Type
VARCHAR2,
NUMBER, FLOAT,
Data CHAR,
BINARY_NUMBER, BLOB
NCHAR2,
BINARY_FLOAT
NCHAR, CLOB
DATE,
TIMESTAMP,
RAW TIMESTAMP WITH
TZ, TIMESTAMP
WITH LOCAL TZ
INTERVAL
YEAR
TO
MONTH,
INTERVAL DAY
TO SECOND
INT
SMALLINT
yes
yes
yes
yes
no
no
yes
yes
yes
yes
no
no
DECIMAL
yes
yes
no
no
no
no
BOOLEAN
yesFoot 1
yesFoot 2
yesFootref yes
2
no
no
BINARY
yes
no
yes
no
no
TINYINT
BIGINT
DOUBLE
FLOAT
yes
STRING
yes
TIMESTAMP yes
yes
yes
yes
yes
yes
no
no
no
yes
no
no
no
no
no
no
STRUCT
ARRAY
yes
UNIONTYPE
MAP
Footnote 1 FALSE maps to the string FALSE, and TRUE maps to the string TRUE.
Footnote 2 FALSE maps to 0, and TRUE maps to 1.
5.14.4 bigdata.properties
Thebigdata.properties file in the common directory contains property-value pairs that
define the Java class paths and native library paths required for accessing data in HDFS.
These properties must be set:
bigdata.cluster.default
java.classpath.hadoop
java.classpath.hive
java.classpath.oracle
LD_LIBRARY_PATH
A colon separated (:) list of directory paths to search for the Hadoop native libraries.
Recommended.
If you set this option, then do not set java.library path in java.options.
The next example shows a sample bigdata.properties file.
# bigdata.properties
#
# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
#
# NAME
# bigdata.properties - Big Data Properties File
#
# DESCRIPTION
# Properties file containing parameters for allowing access to Big Data
# Fixed value properties can be added here
#
java.libjvm.file=$ORACLE_HOME/jdk/jre/lib/amd64/server/libjvm.so
java.classpath.oracle=$ORACLE_HOME/hadoopcore/jlib/*:$ORACLE_HOME/hadoop/jlib/hver2/*:$ORACLE_HOME/dbjava/lib/*
java.classpath.hadoop=$HADOOP_HOME/*:$HADOOP_HOME/lib/*
java.classpath.hive=$HIVE_HOME/lib/*
LD_LIBRARY_PATH=$ORACLE_HOME/jdk/jre/lib
bigdata.cluster.default=hadoop_cl_1
5.14.5 bigdata-log4j.properties
The bigdata-log4j.properties file in the common directory defines the logging behavior of
queries against external tables in the Java code. Any log4j properties are allowed in this
file.
The next example shows a sample bigdata-log4j.properties file with the relevant log4j
properties.
# bigdata-log4j.properties
#
# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
#
# NAME
# bigdata-log4j.properties - Big Data Logging Properties File
#
# DESCRIPTION
# Properties file containing logging parameters for Big Data
# Fixed value properties can be added here
bigsql.rootlogger=INFO,console
log4j.rootlogger=DEBUG, file
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.target=System.err
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{2}: %m%n
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{2}: %m%n
log4j.logger.oracle.hadoop.sql=ALL, file
bigsql.log.dir=.
bigsql.log.file=bigsql.log
log4j.appender.file.File=$ORACLE_HOME/bigdatalogs/bigdata-log4j.log
A database directory object points to the cluster directory. Users who want to access the
data in a cluster must have read access to the directory object.
6Chapter 6.
6.1 INTRODUCTION
User-defined Functions (UDFs) have a long history of usefulness in SQL-derived
languages. While query languages can be rich in their expressiveness, theres just no way
they can anticipate all the things a developer wants to do. Thus, the custom UDF has
become commonplace in our data manipulation toolbox.
Apache Hive is no different in this respect from other SQL-like languages. Hive allows
extensibility via both Hadoop Streaming and compiled Java. However, largely because of
the underlying MapReduce paradigm, all Hive UDFs are not created equally. Some UDFs
are intended for map-side execution, while others are portable and can be run on the
reduce-side. Moreover, UDF behavior via streaming requires that queries be formatted
so as to direct script execution where we desire it.
The intricacies of where and how a UDF executes may seem like minutiae, but we would
be disappointed time spent coding a cumulative sum UDF only executed on single rows.
To that end, Im going to spend the rest of the week diving into the three primary types of
Java-based UDFs in Hive.
Were extending the UDF class with some decoration. The decoration is important for
usability and functionality. The description decorator allows us to give the Hive some
information to show users about how to use our UDF and what its method signature will
be. The UDFType decoration tells Hive what sort of behavior to expect from our function.
A deterministic UDF will always return the same output given a particular input. A squareroot computing UDF will always return the same square root for 4, so we can say it is
deterministic; a call to get the system time would not be. The stateful annotation of the
UDFType decoration is relatively new to Hive (e.g., CDH4 and above). The stateful
directive allows Hive to keep some static variables available across rows. The simplest
example of this is a row-sequence, which maintains a static counter which increments
with each row processed.
Since square-root and row-counting arent terribly interesting, well use the stateful
annotation to build a simple moving average function. Well return to the notion of a
moving average later when we build a UDAF, so as to compare the two approaches.
private DoubleWritable result = new DoubleWritable();
private static ArrayDeque<Double> window;
int windowSize;
public UDFSimpleMovingAverage() {
result.set(0);
The above code is basic initialization. We make a double in which to hold the result, but it
needs to be of class DoubleWritable so that MapReduce can properly serialize the data.
We use a deque to hold our sliding window, and we need to keep track of the windows
size. Finally, we implement a constructor for the UDF class.
public DoubleWritable evaluate(DoubleWritable v, IntWritable n) {
double sum = 0.0;
double moving_average;
double residual;
if (window == null)
{
window = new ArrayDeque<Double>();
Heres the meat of the class: the evaluate method. This method will be called on each row
by the map tasks. For any given row, we cant say whether or not our sliding window
exists, so we initialize it if its null.
//slide the window
if (window.size() == n.get())
window.pop();
window.addLast(new Double(v.get()));
// compute the average
for (Iterator<Double> i = window.iterator(); i.hasNext();)
sum += i.next().doubleValue();
Here we deal with the deque and compute the sum of the windows elements. Deques are
essentially double-ended queues, so they make excellent sliding windows. If the window
is full, we pop the oldest element and add the current value.
moving_average = sum/window.size();
result.set(moving_average);
return result;
Computing the moving average without weighting is simply dividing the sum of our
window by its size. We then set that value in our Writable variable and return it. The value
is then emitted as part of the map task executing the UDF function.
We also create an object of PrimitiveObjectInspector, which well use to ensure that the
input is a string. Once this is done, we need to override methods for initialization, row
processing, and cleanup.
@Override
if (args.length != 1) {
throw new UDFArgumentException(pairwise() takes exactly one argument);
}
if (args[0].getCategory() != ObjectInspector.Category.PRIMITIVE
This UDTF is going to return an array of structs, so the initialize method needs to return
aStructObjectInspector object. Note that the arguments to the constructor come in as an
array of ObjectInspector objects. This allows us to handle arguments in a normal fashion
but with the benefit of methods to broadly inspect type. We only allow a single argument
the string column to be processed so we check the length of the array and validate
that the sole element is both a primitive and a string.
The second half of the initialize method is more interesting:
List<String> fieldNames = new ArrayList<String>(2);
List<ObjectInspector> fieldOIs = new ArrayList<ObjectInspector>(2);
fieldNames.add(memberA);
fieldNames.add(memberB);
fieldOIs.add(PrimitiveObjectInspectorFactory.javaStringObjectInspector);
fieldOIs.add(PrimitiveObjectInspectorFactory.javaStringObjectInspector);
return ObjectInspectorFactory.getStandardStructObjectInspector(fieldNames, fieldOIs);
Here we set up information about what the UDTF returns. We need this in place before we
start processing rows, otherwise Hive cant correctly build execution plans before
submitting jobs to MapReduce. The structures were returning will be two strings per
struct, which means well needObjectInspector objects for both the values and the names
of the fields. We create two lists, one of strings for the name, the other of ObjectInspector
objects. We pack them manually and then use a factor to get the StructObjectInspector
which defines the actual return value.
Now were ready to actually do some processing, so we override the process method.
@Override
public void process(Object[] record) throws HiveException {
final String document = (String) stringOI.getPrimitiveJavaObject(record[0]);
if (document == null) {
return;
}
String[] members = document.split(,);
java.util.Arrays.sort(members);
for (int i = 0; i < members.length - 1; i++)
for (int j = 1; j < members.length; j++)
if (!members[i].equals(members[j]))
forward(new Object[] {members[i],members[j]});
This is simple pairwise expansion, so the logic isnt anything more than a nested for-loop.
There are, though, some interesting things to note. First, to actually get a string object to
operate on, we have to use an ObjectInspector and some typecasting. This allows us to bail
out early if the column value is null. Once we have the string, splitting, sorting, and
looping is textbook stuff.
The last notable piece is that the process method does not return anything. Instead, we
callforward to emit our newly created structs. From the context of those used to database
internals, this follows the producer-consumer models of most RDBMs. From the context
of those used to MapReduce semantics, this is equivalent to calling write on the Context
object.
@Override
public void close() throws HiveException {
// do nothing
If there were any cleanup to do, wed take care of it here. But this is simple emission, so
our override doesnt need to do anything.
Here we have the definition of our moving average class and the static inner class which
serves as an entry in our table. Whats important here are some of the variables we define
for each entry in the table: the time-index or period of the value (its order), the value itself,
the prefix sum, the subsequence total, and the moving average itself. Every entry in our
table requires not just the current value to compute the moving average, but also sum of
entries in our moving average window. Its the pair of these two values which allows
prefix sum methods to work their magic.
//class variables
private int windowSize;
private ArrayList<PrefixSumEntry> entries;
public PrefixSumMovingAverage()
{
windowSize = 0;
}
public void reset()
{
windowSize = 0;
entries = null;
}
public boolean isReady()
{
return (windowSize > 0);
}
The above are simple initialization routines: a constructor, a method to reset the table, and
a boolean method on whether or not the object has a prefix sum table on which to operate.
From here, there are 3 important methods to examine: add, merge, and serialize. The first
is intuitive, as we scan rows in Hive we want to add them to our prefix sum table. The
second are important because of partial aggregation.
We cannot say ahead of time where this UDAF will run, and partial aggregation may be
required. That is, its entirely possible that some values may run through the UDAF during
a map task, but then be passed to a reduce task to be combined with other values. The
serialize method will allow Hive to pass the partial results from the map side to the reduce
side. The merge method allows reducers to combine the results of partial aggregations
from the map tasks.
@SuppressWarnings(unchecked)
public void add(int period, double v)
{
//Add a new entry to the list and update table
PrefixSumEntry e = new PrefixSumEntry();
e.period = period;
e.value = v;
entries.add(e);
// do we need to ensure this is sorted?
//if (needsSorting(entries))
Collections.sort(entries);
// update the table
// prefixSums first
double prefixSum = 0;
for(int i = 0; i < entries.size(); i++)
{
PrefixSumEntry thisEntry = entries.get(i);
prefixSum += thisEntry.value;
thisEntry.prefixSum = prefixSum;
entries.set(i, thisEntry);
}
The first part of the add task is simple: we add the element to the list and update our
tables prefix sums.
// now do the subsequence totals and moving averages
for(int i = 0; i < entries.size(); i++)
{
double subsequenceTotal;
double movingAverage;
In the second half of the add function, we compute our moving averages based on the
prefix sums. Its here you can see the hinge on which the algorithm swings:
thisEntry.prefixSum - backEntry.prefixSum that offset between the current table entry
and its nth predecessor makes the whole thing work.
public ArrayList<DoubleWritable> serialize()
{
ArrayList<DoubleWritable> result = new ArrayList<DoubleWritable>();
result.add(new DoubleWritable(windowSize));
if (entries != null)
{
for (PrefixSumEntry i : entries)
{
result.add(new DoubleWritable(i.period));
result.add(new DoubleWritable(i.value));
}
}
return result;
The serialize method needs to package the results of our algorithm to pass to another
instance of the same algorithm, and it needs to do so in a type that Hadoop can serialize.
In the case of a method like sum, this would be relatively simple: we would only need to
pass the sum up to this point. However, because we cannot be certain whether this
instance of our algorithm has seen all the values, or seen them in the correct order, we
actually need to serialize the whole table. To do this, we create a list ofDoubleWritables,
pack the window size at its head, and then each period and value. This gives us a structure
thats easy to unpack and merge with other lists with the same construction.
@SuppressWarnings(unchecked)
public void merge(List<DoubleWritable> other)
{
if (other == null)
return;
// if this is an empty buffer, just copy in other
// but deserialize the list
if (windowSize == 0)
{
windowSize = (int)other.get(0).get();
entries = new ArrayList<PrefixSumEntry>();
// were serialized as period, value, period, value
for (int i = 1; i < other.size(); i+=2)
{
PrefixSumEntry e = new PrefixSumEntry();
e.period = (int)other.get(i).get();
e.value = other.get(i+1).get();
entries.add(e);
}
Merging results is perhaps the most complicated thing we need to handle. First, we check
the case in which there was no partial result passed just return and continue. Second,
we check to see if this instance of PrefixSumMovingAverage already has a table. If it
doesnt, we can simply unpack the serialized result and treat it as our window.
// if we already have a buffer, we need to add these entries
else
{
// were serialized as period, value, period, value
for (int i = 1; i < other.size(); i+=2)
{
PrefixSumEntry e = new PrefixSumEntry();
e.period = (int)other.get(i).get();
e.value = other.get(i+1).get();
entries.add(e);
}
The third case is the non-trivial one: if this instance has a table and receives a serialized
table, we must merge them together. Consider a Reduce task: as it receives outputs from
multiple Map tasks, it needs to merge all of them together to form a larger table. Thus,
merge will be called many times to add these results and reassemble a larger time series.
// sort and recompute
Collections.sort(entries);
// update the table
// prefixSums first
double prefixSum = 0;
This part should look familiar, its just like the add method. Now that we have new entries
in our table, we need to sort by period and recompute the moving averages. In fact, the
rest of the merge method is exactly like the add method, so we might consider putting
sorting and recomputing in a separate method.
Heres the beginning of our overrided initialization function. We check the parameters for
two modes, PARTIAL1 and COMPLETE. Here we assume that the arguments to our
UDAF are the same as the user passes in a query: the period, the input, and the size of the
window. If the UDAF instance is consuming the results of our partial aggregation, we
need a different ObjectInspector. Specifically, this one:
else
{
loi = (StandardListObjectInspector) parameters[0];
Similar to the UDTF, we also need type checking on the output types but for both
partial and full aggregation. In the case of partial aggregation, were returning lists of
DoubleWritables:
But in the case of FINAL or COMPLETE, were dealing with the types that will be
returned to the Hive user, so we need to return a different output. Were going to return a
list of structs that contain the period, moving average, and residuals (since theyre cheap
to compute).
else {
// The output of FINAL and COMPLETE is a full aggregation, which is a
Next come methods to control what happens when a Map or Reduce task is finished with
its data. In the case of partial aggregation, we need to serialize the data. In the case of full
aggregation, we need to package the result for Hive users.
@Override
public Object terminatePartial(AggregationBuffer agg) throws HiveException {
// return an ArrayList where the first parameter is the window size
MaAgg myagg = (MaAgg) agg;
return myagg.prefixSum.serialize();
}
@Override
public Object terminate(AggregationBuffer agg) throws HiveException {
// final return value goes here
MaAgg myagg = (MaAgg) agg;
if (myagg.prefixSum.tableSize() < 1)
{
return null;
}
else
{
ArrayList<DoubleWritable[]> result = new ArrayList<DoubleWritable[]>();
for (int i = 0; i < myagg.prefixSum.tableSize(); i++)
{
double
myagg.prefixSum.getEntry(i).movingAverage;
residual
myagg.prefixSum.getEntry(i).value
DoubleWritable[] entry = new DoubleWritable[3];
entry[0] = new DoubleWritable(myagg.prefixSum.getEntry(i).period);
entry[1] = new DoubleWritable(myagg.prefixSum.getEntry(i).movingAverage);
entry[2] = new DoubleWritable(residual);
result.add(entry);
}
return result;
}
We also need to provide instruction on how Hive should merge the results of partial
aggregation. Fortunately, we already handled this in our PrefixSumMovingAverage class,
so we can just call that.
@SuppressWarnings(unchecked)
@Override
public void merge(AggregationBuffer agg, Object partial) throws HiveException {
// if were merging two separate sets were creating one table thats doubly long
if (partial != null)
{
MaAgg myagg = (MaAgg) agg;
List<DoubleWritable> partialMovingAverage = (List<DoubleWritable>) loi.getList(partial);
myagg.prefixSum.merge(partialMovingAverage);
}
Of course, merging and serializing isnt very useful unless the UDAF has logic for
iterating over values. The iterate method handles this and as one would expect relies
entirely on thePrefixSumMovingAverage class we created.
@Override
public void iterate(AggregationBuffer agg, Object[] parameters) throws HiveException {
assert (parameters.length == 3);
if (parameters[0] == null || parameters[1] == null || parameters[2] == null)
{
return;
}
MaAgg myagg = (MaAgg) agg;
// Parse out the window size just once if we havent done so before. We need a window of at
least 1,
// otherwise theres no window.
if (!myagg.prefixSum.isReady())
{
int windowSize = PrimitiveObjectInspectorUtils.getInt(parameters[2], windowSizeOI);
if (windowSize < 1)
{
throw new HiveException(getClass().getSimpleName() + needs a window size >= 1);
}
myagg.prefixSum.allocate(windowSize);
}
//Add the current data point and compute the average
int p = PrimitiveObjectInspectorUtils.getInt(parameters[0], inputOI);
double v = PrimitiveObjectInspectorUtils.getDouble(parameters[1], inputOI);
myagg.prefixSum.add(p,v);
moving_avg
AS
Here were applying the UDAF to get the moving average of arrival delay from a
particular flight. Its a really simple query for all that work we did underneath. We can do
a bit more and leverage Hives abilities to handle complex types as columns, heres a
query which creates a table of timeseries as arrays.
#create a set of moving averages for every plane starting with N
#Note: this UDAF blows up unpleasantly in heap; there will be data volumes for which you need to
throw
#excessive amounts of memory at the problem
CREATE TABLE moving_averages AS
SELECT TailNum, moving_avg(timestring, delay, 4) as timeseries FROM ts_example
6.4.6 Summary
Weve covered all manner of UDFs: from simple class extensions which can be written
very easily, to very complicated UDAFs which require us to think about distributed
execution and plan orchestration done by query engines. With any luck, the discussion has
provided you with the confidence to go out and implement your own UDFs or at least
pay some attention to the complexities of the ones in use every day.
7Chapter 7.
ORACLE No SQL
7.1 INTRODUCTION
system, Oracle brings enterprise robustness and stability to the NoSQL landscape.
Furthermore, until recently, integrating NoSQL solutions with an enterprise application
architecture required manual integration and custom development;
Oracles NoSQL Database provides all the desirable features of NoSQL solutions
necessary for seamless integration into an enterprise application architecture. The next
figure shows a canonical acquireorganize-analyze data cycle, demonstrating how Oracles
NoSQL Database fits into such an ecosystem. Oracle-provided adapters allow the Oracle
NoSQL Database to integrate with a Hadoop MapReduce framework or with the Oracle
Database in-database MapReduce, Data Mining, R-based analytics, or whatever business
needs demand.
The Oracle NoSQL Database, with its No Single Point of Failure architecture is the
right solution when data access is simple in nature and application demands exceed the
volume or latency capability of traditional data management solutions. For example, clickstream data from high volume web sites, high-throughput event processing, and social
networking communications all represent application domains that produce extraordinary
volumes of simple keyed data. Monitoring online retail behavior, accessing customer
profiles, pulling up appropriate customer ads and storing and forwarding real-time
communication are examples of domains requiring the ultimate in low-latency access.
Highly distributed applications such as real-time sensor aggregation and scalable
authentication also represent domains well-suited to Oracle NoSQL Database.
Oracle NoSQL Database also provides a range of durability policies that specify what
guarantees the system makes after a crash. At one extreme, applications can request that
write requests block until the record has been written to stable storage on all copies. This
has obvious performance and availability implications, but ensures that if the application
successfully writes data, that data will persist and can be recovered even if all the copies
become temporarily unavailable due to multiple simultaneous failures.
At the other extreme, applications can request that write operations return as soon as the
system has recorded the existence of the write, even if the data is not persistent anywhere.
Such a policy provides the best write performance, but provides no durability guarantees.
By specifying when the database writes records to disk and what fraction of the copies of
the record must be persistent (none, all, or a simple majority), applications can enforce a
wide range of durability policies.
7.3 API
Incorporating Oracle NoSQL Database into applications is straightforward. APIs for basic
Create, Read, Update and Delete (CRUD) operations and a collection of iterators are
packaged in a single jar file. Applications can use the APIs from one or more client
processes that access a stand-alone Oracle NoSQL Database server process, alleviating the
need to set up multi-system configurations for initial development and testing.
7.5 ITERATION
In addition to basic CRUD operations, Oracle NoSQL Database supports two types of
iteration: unordered iteration over records and ordered iteration within a Major Key set.
In the case of unordered iteration over the entire store, the result is not transactional; the
iteration runs at an isolation level of read-committed, which means that the result set will
contain only key/value pairs that have been persistently written to the database, but there
are no guarantees of semantic consistency across key/value pairs.
The API supports both individual key/value returns using several storeIterator methods
and bulk key/value returns within a Major Key Path via the various multiGetIterator
methods. The example below demonstrates iterating over an entire store, returning each
key/value pair individually. Note that although the iterator returns only a single key/value
pair at a time, the storeIterator method takes a second parameter of batchSize, indicating
how many key/value pairs to fetch per network round trip.
This allows applications to simultaneously use network bandwidth efficiently, while
maintaining the simplicity of key-at-a-time access in the API.
Using Oracle Big Data SQL, you can query data stored in a Hadoop cluster using the
complete SQL syntax. You can execute the most complex SQL SELECT statements
against data in Hadoop, either manually or using your existing applications, to tease out
the most significant insights.
7.7 ADMINISTRATION
Oracle NoSQL Database comes with an Administration Service, accessible from both a
command line interface and a web console. Using the service, administrators can
configure a database instance, start it, stop it, and monitor system performance, without
manually editing configuration files, writing shell scripts, or performing explicit database
operations.
The Administration Service is itself a highly-available service, but consistent with the
Oracle NoSQL Database No Single Point of Failure philosophy, the ongoing operation
of an installation is not dependent upon the availability of the Administration Service.
Thus, both the database and the Administration Service remain available during
configuration changes.
In addition to facilitating configuration changes, the Administration Service also collects
and maintains performance statistics and logs important system events, providing online
monitoring and input to performance tuning.
7.8 ARCHITECTURE
We present the Oracle NoSQL Database architecture by following the execution of an
operation through the logical components of the system and then discussing how those
components map to actual hardware and software operation. We will create the key/value
pair Katana and sword. The next figure depicts the method invocation
putIfAbsent(Katana, sword)1.
The application issues the putIfAbsent method to the Client Driver (step 1). The client
driver hashes the key Katana to select one of a fixed number of partitions (step 2).
Thenumber of partitions is fixed and set by an administrator at system configuration time
and is chosen to be significantly larger than the maximum number of storage nodes
expected in the store. In this example, our store contains 25 storage nodes, so we might
have configured the system to have 25,000 partitions. Each partition is assigned to a
particular replication group. The driver consults the partition table (step 3) to map the
partition number to a replication group.
A replication group consists of some (configurable) number of replication nodes. Every
replication group consists of the same number of replication nodes. The number of
replication nodes in a replication group dictates the number of failures from which the
system is resilient; a system with three nodes per group can withstand two failures while
continuing to service read requests. Its ability to withstand failures on writes is based upon
the configured durability policy. If the application does not require a majority of
participants to acknowledge a write, then the system can also withstand up to two failures
for writes. A five-node group can withstand up to four failures for reads and up to two
failures for writes, even if the application demands a durability policy requiring a majority
of sites to acknowledge a write operation.
Given a replication group, the Client Driver next consults the Replication Group State
Table (RGST) (step 4). For each replication group, the RGST contains information about
each replication node comprising the group (step 5). Based upon information in the RGST,
such as the identity of the master and the load on the various nodes in a replication group,
the Client Driver selects the node to which to send the request and forwards the request to
the appropriate node (step 6). In this case, since we are issuing a write operation, the
request must go to the master node.
The replication node then applies the operation. In the case of a putIfAbsent, if the key
exists, the operation has no effect and returns an error, indicating that the specified entry is
already present in the store. If the key does not exist, the replication node adds the
key/value pair to the store and then propagates the new key/value pair to the other nodes
in the replication group (step 7).
7.9 IMPLEMENTATION
An Oracle NoSQL Database installation consists of two major pieces: a Client Driver and
a collection of Storage Nodes. As shown in Figure 3, the client driver implements the
partition map and the RGST, while storage nodes implement the replication nodes
comprising replication groups. In this section, well take a closer look at each of these
components.
Replication nodes support the Oracle NoSQL Database API via RMI calls from the client
and obtain data directly from or write data directly to the log-structured storage system,
which provides outstanding write performance, while maintaining index structures that
provide low-latency read performance as well. The Oracle NoSQL Database storage
engine pioneered the use of log-structured storage in key/value databases since its initial
deployment in 2003 and has been proven in several open-source NoSQL solutions, such as
Dynamo, Voldemort, and GenieDB, as well as in Enterprise deployments.
Oracle NoSQL Database uses replication to ensure data availability in the case of failure.
Its singlemaster architecture requires that writes are applied at the master node and then
propagated to the replicas. In the case of failure of the master node, the nodes in a
replication group automatically hold a reliable election (using the Paxos protocol),
electing one of the remaining nodes to be the master. The new master then assumes write
responsibility.
7.10 PERFORMANCE
We have experimented with various Oracle NoSQL Database configurations and present a
few performance results of the Yahoo! Cloud Serving Benchmark (YCSB), emonstrating
how the system scales with the number of nodes in the system. As with all performance
measurements, your mileage may vary. We applied a constant YCSB load per storage
node to configurations of varying sizes. Each storage node was comprised of a 2.93ghz
Westmere 5670 dual socket machine with 6 cores/socket and 24GB of memory. Each
machine had a 300GB local disk and ran RedHat 2.6.18-164.11.1.el5.crt1. At 300 GB, the
disk size is the scale-limiting resource on each node, dictating the overall configuration, so
we configured each node to hold 100M records, with an average key size of 13 bytes and
data size of 1108 bytes.
The next graph shows the raw insert performance of Oracle NoSQL Database for
configurations ranging from a single replication group system with three nodes storing
100 million records to a system with 32 replication groups on 96 nodes storing 2.1 billion
records (the YCSB benchmark is limited to a maximum of 2.1 billion records). The graph
shows both the throughput in operations per second (blue line and left axis) and the
response time in milliseconds (red line and right axis). Throughput of the system scales
almost linearly as the database size and number of replication groups grows, with only a
modest increase in response time.
The next graph shows the throughput and response time for a workload of 50% reads and
50% updates. As the system grows in size (both data size and number of replication
groups), we see both the update and read latency decline, while throughput scales almost
linearly, delivering the scalability needed for todays demanding applications.
7.11 CONCLUSION
Oracles NoSQL Database brings enterprise quality storage and performance to the highlyavailable, widely distributed NoSQL environment. Its commercially proven, writeoptimized storage system delivers outstanding performance as well as robustness and
reliability, and its No Single Point of Failure design ensures that the system continues to
run and data remain available after any failure.