Monday, February 24, 2014

Cassandra modeling with CQL for a simple time series use case

Simple Cassandra modeling example
           



1       Introduction


The document explores different designs for a simple real-world time series use case on Apache Cassandra. Initially this data resided in a different database (SQL Server, Rdbms), but given the volume of the data, we need a more scalable solution. Cassandra was chosen for its scalability, no SPOF feature, and ease of use. We will review our options regarding the data model, using CQL to construct the table.

1.1     Scope and requirements


Devices need to communicate over the Web (devices are wifi-enabled) to their backend cloud infrastructure (IaaS and PaaS) to send status and retrieve updates. There will be about 100k devices connected, and it is important that the architecture be scalable when more devices are added. The rate fluctuates with spikes. Data format is XML.
Need to find the optimal schema for this data, accounting for fast writes and fast retrieval, minimizing the amount of space utilized. 
Cassandra is a good choice for storing this data, but how to proceed with the data schema?

1.2      Data schema & queries

The data that we want to store in Cassandra are of the format below.

1.    Sample data format

Column name
Sample value
Comment
Date
02/05/2013
Day's worth of data
Device_id
As-333-fd-45
unique id for device
timestamp
02:44:45
Time stamp for this date
Event_type
notification
Other data
Message_id
454


Message
M455






2.   Queries

As we know in NoSQL, the design of the tables is driven by the queries of the data rather than by its entities & relationships; i.e., optimizing for reads at write time. Here are the types of queries that we want out of the data:

- Q1 -> Get all records for a particular date
- Q2 -> Get a record for a date and a device_id
- Q3 -> Get a record for a device_id 
- Q4 -> Get all records for a date and a timestamp between x and y

 Lets review the options that we have to construct the table for this data. We will use CQL for this. The main issue has to do with finding the proper Primary Key for our objects.

1.2.1    Option 1: 


The date object, will be the partitioning key; device_id will be the clustering key. The date object will be the same throughout the day's worth of data.
The clustering key (device_id) on the other hand should not be unique. It is used for ordering when querying objects.
This seems like the wrong design altogether.

1.2.2    Option 2: 

Only utilize this as the partitioning key. It is preferable as this is a unique value. The partitioning key is used to distribute the data across nodes, so we want this as random as possible.
Secondary index on date ; required since date is not part of the key.
Secondary index on timestamp

1.2.3    Option 3:

This removes the need for the secondary indexes, and thus is a gain of space. However, it adds constraints as one must using filtering (i.e., scan in memory through a B-tree) for queries on the PK fields.

1.2.4    Option 4:

PRIMARY KEY ((device_id, date), timestamp);
device_id / date will be the partitioning key. timestamp is the clustering key.

 This lets us avoid the 'allow filtering' clause, which slows down the query. However it impedes us from querying on some of the PK fields..

1.3     Summary


Options
Q1
Q2
Q3
Q4
Comments / Pros & Cons
1
 Yes
Yes
Yes with filtering
No
1.     Wide-row if for a partition, there are lot of records
2.     The node will be very hot as everything is going in one row for one day. Lots of contention. Should be avoided
2
Yes
Yes
Yes
Yes with filtering
Q4 will be served with Allow filtering
1.     More space consumption due to secondary indices
3
Yes with allow filtering
Yes
Yes
Yes with filtering
No index. But not very effective to use allow filtering (~ B-tree in memory) , more than secondary index on partitionKey.
4
No, needs rowkey
yes
No, needs partition key
No, needs row key
No need for filtering, but then too restrictive.



The best choice seems to be option 2.

2       Appendix

Definitions

partitionkey = date
rowkey = device_id
range = timestamp.

2.1     Option 1


CREATE TABLE tablestorage6 (
  partitionkey text,
  rowkey text,
  policyid text,
  policyname text,
  range timestamp,
  PRIMARY KEY (partitionkey, rowkey);

CREATE INDEX i1 ON tablestorage6 (range);

cqlsh:demodb> select * from tablestorage6 ;

 partitionkey | rowkey | policyid | policyname | range
--------------+--------+----------+------------+--------------------------
           p1 |     r1 |      pl1 |     plicy1 | 2007-01-02 00:00:00+0000
           p1 |     r2 |      pl2 |     plicy2 | 2007-01-03 00:00:00+0000
           p2 |     r3 |      pl3 |     plicy3 | 2008-01-03 00:00:00+0000

(3 rows)

cqlsh:demodb> select * from tablestorage6 where rowkey = 'r2' allow filtering;

 partitionkey | rowkey | policyid | policyname | range
--------------+--------+----------+------------+--------------------------
           p1 |     r2 |      pl2 |     plicy2 | 2007-01-03 00:00:00+0000

(1 rows)

2.1.1  Option 2


CREATE TABLE tablestorage (
  rowkey text,
  clientipaddress text,
  deviceid text,
  eventtype text,
  grouppolicyid text,
  grouppolicyname text,
  loglevel text,
  macaddress text,
  messageid text,
  model text,
  msgparam text,
  packageid text,
  partitionkey text,
  policyid text,
  policyname text,
  serialnumber text,
  "timestamp" timestamp,
  username text,
  PRIMARY KEY (rowkey)

create index a on tablestorage(partitionkey);

select * from tablestorage where rowkey='726716f7-2e54-4715-9f00-91dcbea999448' and partitionkey = '2' ;

 rowkey                                | clientipaddress | deviceid | eventtype    | grouppolicyid | grouppolicyname | loglevel | macaddress | messageid | model  | msgparam | packageid | partitionkey | policyid | policyname | serialnumber | timestamp                    | username
---------------------------------------+-----------------+----------+--------------+---------------+-----------------+----------+------------+-----------+--------+----------+-----------+--------------+----------+------------+--------------+------------------------------+----------
 726716f7-2e54-4715-9f00-91dcbea999448 |           Host2 |      id2 | CreateSchema |         gpid2 |             gp2 |    debug |       1234 |         5 | model2 |     sgp2 |      pkg2 |            2 |     pol2 |     plnme2 |       seril2 | 20133114-07-02 03:19:39+0000 |    matt8

(1 rows)

cqlsh:demodb> select * from tablestorage where partitionkey = '2' and timestamp > '20131212' allow filtering;

 rowkey                                | clientipaddress | deviceid | eventtype    | grouppolicyid | grouppolicyname | loglevel | macaddress | messageid | model  | msgparam | packageid | partitionkey | policyid | policyname | serialnumber | timestamp                    | username
---------------------------------------+-----------------+----------+--------------+---------------+-----------------+----------+------------+-----------+--------+----------+-----------+--------------+----------+------------+--------------+------------------------------+----------
 726716f7-2e54-4715-9f00-91dcbea999442 |           Host2 |      id2 | CreateSchema |         gpid2 |             gp2 |    debug |       1234 |         5 | model2 |     sgp2 |      pkg2 |            2 |     pol2 |     plnme2 |       seril2 | 20133114-07-02 03:14:27+0000 |    matt2

(1 rows)

2.1.2  Option 3

CREATE TABLE tablestorage10 (
  rowkey text,
  partitionkey text,
  range timestamp,
  policyid text,
  policyname text,
  PRIMARY KEY (rowkey, partitionkey, range)

cqlsh:demodb> select * from tablestorage10;

 rowkey | partitionkey | range                    | policyid | policyname
--------+--------------+--------------------------+----------+------------
     r3 |           p2 | 2008-01-03 00:00:00+0000 |      pl3 |     plicy3
     r2 |           p1 | 2007-01-03 00:00:00+0000 |      pl2 |     plicy2

(2 rows)

Q4: cqlsh:demodb> select * from tablestorage10 where partitionkey= 'p1' and range > '2006-01-01' allow filtering;

 rowkey | partitionkey | range                    | policyid | policyname
--------+--------------+--------------------------+----------+------------
     r2 |           p1 | 2007-01-03 00:00:00+0000 |      pl2 |     plicy2

(1 rows)

cqlsh:demodb>

but
cqlsh:demodb> select * from tablestorage10 where range > '2006-01-01' allow filtering;
Bad Request: PRIMARY KEY part range cannot be restricted (preceding part partitionkey is either not restricted or by a non-EQ relation)
cqlsh:demodb>

cqlsh:demodb> select * from tablestorage10 where partitionkey='p1' and  range > '2006-01-01' allow filtering;

 rowkey | partitionkey | range                    | policyid | policyname
--------+--------------+--------------------------+----------+------------
     r2 |           p1 | 2007-01-03 00:00:00+0000 |      pl2 |     plicy2

(1 rows)

cqlsh:demodb>


cqlsh:demodb> select * from tablestorage10 where rowkey = 'r2' and  range > '2006-01-01' allow filtering;
Bad Request: PRIMARY KEY part range cannot be restricted (preceding part partitionkey is either not restricted or by a non-EQ relation)
cqlsh:demodb>

cqlsh:demodb> select * from tablestorage10 where rowkey = 'r2';

 rowkey | partitionkey | range                    | policyid | policyname
--------+--------------+--------------------------+----------+------------
     r2 |           p1 | 2007-01-03 00:00:00+0000 |      pl2 |     plicy2

(1 rows)

cqlsh:demodb> select * from tablestorage10 where rowkey = 'r2' and partitionkey = 'p1';

 rowkey | partitionkey | range                    | policyid | policyname
--------+--------------+--------------------------+----------+------------
     r2 |           p1 | 2007-01-03 00:00:00+0000 |      pl2 |     plicy2

(1 rows)

cqlsh:demodb> select * from tablestorage10 where partitionkey = 'p1';
Bad Request: Cannot execute this query as it might involve data filtering and thus may have unpredictable performance. If you want to execute this query despite the performance unpredictability, use ALLOW FILTERING
cqlsh:demodb> select * from tablestorage10 where partitionkey = 'p1' allow filtering;

 rowkey | partitionkey | range                    | policyid | policyname
--------+--------------+--------------------------+----------+------------
     r2 |           p1 | 2007-01-03 00:00:00+0000 |      pl2 |     plicy2

(1 rows)

cqlsh:demodb>

2.1.3  Option 4

CREATE TABLE tablestorage8 (
  partitionkey text,
  rowkey text,
  range timestamp,
  policyid text,
  policyname text,
  PRIMARY KEY ((partitionkey, rowkey), range)

demodb> select * from tablestorage8  where partitionkey='p2';
Bad Request: Partition key part rowkey must be restricted since preceding part is

select * from tablestorage8 where rowkey='r3' and range > '20131212';
Bad Request: partition key part rowkey cannot be restricted (preceding part partitionkey is either not restricted or by a non-EQ relation)
cqlsh:demodb>



Tuesday, February 4, 2014

IBM stampede program notes

The IBM Stampede training is a second part training about the IBM products; one of  its main attraction was that it was taught by an actual IBM solutions architect, giving real-case examples of his past projects. These are some of the notes taken during the training.

Components

It is important to have some kind of data stewardship when dealing with amounts of data; a lot of companies essentially deal with this on an ad-hoc way instead.
There are essentially 3 components at play
- Hadoop ; data at rest, landed
- Stream ; data in motion
- Data warehouse

IBM offers these 3 components as part of their Big Insights offering.
Also, IBM offers Accelerators that are essentially frameworks for working with specific use cases, for data that is not harmonized together.

In addition, IBM offers Watson, which is able to perform NLP (language processing) given a given context.


Hadoop



Hadoop in the context of the Data warehouse (DW)

Hadoop’s sweet spot from a data perspective is for the queryable archive of data, the cold/unused data offloaded from the expensive DW.
Hadoop is seen as performing DW Augmentation. The DW (typically Netezza) stays, only is complemented by Hadoop.
IBM talks about the Analytics landing zone as the logical data storage area.
In comparison, this is similar to the Enterprise hub from cloudera, or the Data lake from Hortonworks.
The landing zone is essentially for raw data (which ends up being stored along time) in addition to modeled data.

Obviously from a cost perspective, Hadoop is cheaper. It is also for “untrusted sources”, vs trusted sources in the DW. Hence the data is segmented.
Hadoop is mainly used today to offload cold data that is typically unused.
This data now becomes a queryable archive; instead of being stored to tape.

Delta files also end up being stored in the landing zone. They stay in the low cost platform, for recovery purposes.

Hadoop has a “Wild West” mentality today, the same as what the Data warehouse used to have 10 years ago! For example in DW, there used to be no systems management, nor recovery. This is now the case in Hadoop: i.e. the relative poor posix support of hdfs, the non-existent audit trail, etc.



Data Warehouse


The definition of a DW is central repository used for reporting & data analysis.
Its challenges are:
- It stores structured data.
-It mainly uses Batch data
-It has limited history, due to data volume constraints: thus, it mainly stores aggregated views.

The data-warehousing instance usually follows a set of processes, with the following:
-       A Data owner
-       A Data steward
-       Data governance
-       Measurements via KPI’s
-       Data Lineage to trace the data.

With Hadoop we now talk about DW Augmentation, to leverage all data and get timely insights, in a cost-optimized way. There starts to be some kind of data federation between DW and Hadoop also, via tools like Cirro; but typically you want to avoid data latency, and data movement (data is not collocated), depending on the cardinality of the data.


Use Cases


IBM sees Big Data exploration as 90% of the use cases. A lot of use cases have to do with finding new expected traits, via exhaust data.

Other use cases vary depending on the vertical; an example is Fraud detection with Hadoop at a major Credit card company. In that use case, detailed transactions in aggregated in a fraud model, utilizing a large volume of structured data, with a small set of users; this is NOT like the standard social data analytics use case that creates all the buzz today.




IBM-specific Big Data tools

BigSQL


BigSQL is IBM’s “secret sauce” around querying data in Hadoop, and is a SQL-like high-level language and wrapper to give access to the data in Big Insights.
Compared to Cloudera’s Impala, IBM says it is fully SQL 92 compliant, and is more accurate.  That said, BigSQL is still a revision 0 product.  It is very effective at what it does because some of the IBM research results went in its design; i.e. the DB2 cost-based optimizers are in there.
It also has a “local table” approach to querying the data, effectively bypassing HDFS by using local storage; it is one of its value-add. BigSQL has access to data stored in HBase, Hive, or DB2 for that matter.

Also, BigSQL has advantages over Hive: sub queries are not possible in Hive.


Data transformations in Big Insights


IBM’s Big Insights integrates Apache’s Pig and Hive which are the most common tools used by the community to perform transformations.
For text analytics, the Annotation Query Language (AQL) is widely used for text analytics, via context extractors.
And BigSheets, the Excel-like Big Data tool generates Pig under the hood; it will also integrate with BigSQL soon.

IBM also attempts to enhance data science tools like R: today R doesn’t work in parallel for the Reduce side of M/R and goes back to a single node. With IBM Big R, the execution of these functions is parallelized; in addition it removes R’s memory limitation.
For Data mining, SPSS and SAS are still the most widely used tools for predictive analytics. Of note, the FDA used to certify drug models prediction only with SAS, but recently opened it up R for statistical models.


Data explorer


IBM’s Data Explorer is a search tool, that provides core indexing, discovery, navigation and search capabilities. The user typically visualizes the results on a portal.
Howerver the data is on its own server, and usually the size of index is 2.5-3 times larger than the data.


Analytics


There are essentially 3 levels of analytics reporting:
-       Descriptive:  essentially what is known as Operational reports, summarizing the data, usually a certain type of metrics (i.e. number of followers). This is akin to looking through your rear-view mirror, without knowing where you are going.
-       Predictive: in-depth analysis of the data via data mining tools, to try and make predictions about the future from the data that you have based on a set of assumptions.
-       Prescriptive: in addition to give prediction about the data, a prescriptive analysis recommends courses of actions based on actionable data and a feedback system.

Use case


In the retail vertical, a typical use case has been around how to better induce a sale. Retailers are essentially looking for the shopper’s trigger point.
To deduce this, retailers obtain the Mac address of mobile phone devices in range of their router (no need to be on the Wifi, mobiles broadcast their Mac address!) to find patterns of aisles routes.

In the car vertical, IBM has done work with major car manufacturers to pull data in motion from car sensors. Aggregation of all of the data can give some very interesting insights on the typical usage of the cars.

They mentioned that a new car like a Ford fusion that has a lot of sensors, will yield about 2Tb of data!

Tuesday, January 7, 2014

IBM's Big Insights training notes


IBM’s Big Insights: A primer


Recently I had the opportunity to attend a training session about IBM’s Big Insights, in November 2013. Below are my notes about this product.


What is Big Insights in a nutshell?


Big Insights is IBM’s Big Data platform. It is comprised of an all-in-one Big Data infrastructure, with IBM’s flavor of Hadoop and its ecosystem, as well as proprietary tools to query the data like JAQL and AQL, and out-of-the-box connectors and interfaces called accelerators. We’ll review these components in details in the below section.

Big Insights Hadoop infrastructure

Big Insights is composed of a Hadoop infrastructure (independent from vendors like Cloudera). It is using a released version of Hadoop that is well-tested, usually a bit older from trunk. However it differs from the Apache version in some ways also. Big Insights comes integrated with:
-       GPFS (IBM’s version of HDFS) for its file system
-       Adaptive Map Reduce, an enhanced version of MR that attempts to optimize task executions, by way of using automatic job tuning of speculative execution and Task JVM reuses. Map Reduce tasks become aware of the global state of the job they are working in. This helps balance the workload across Map tasks. 
-       Zookeeper, HBase, Hive, Pig

Of note is the fact that Big Insights is not bundled with Cloudera’s CDH anymore; IBM has its own version of Hadoop.

New query language: JAQL

Big Insights offers a language called JAQL, a functional language that can interface will of all the Big Insights tools. It provides API's (or modules) for reaching out to external IBM and 3rd party tools, such as relational databases, indexing services, text analytics, machine learning etc. JAQL stands for Json Query Language, because it is represented via Json. Similar to Pig, Jaql is automatically taking care managing the complexities of the MapReduce world to optimally perform the work. However it also manages deep level nested semi-structured data.
Jaql can be executed either from its own shell, or from within Eclipse.

Big Insights Applications

Big Insights provides an environment for developing and executing applications. A business user can launch existing applications from the Web console, supply any input parameters and view results.  These applications may be developed using Big Insights’ development tooling which enables programmers to publish completed applications through the Web console.
The BigInsights Eclipse tools include wizards, code generators, context-sensitive help, and a test environment to simplify your development efforts.
Workflow applications are run by Oozie as a workflow job.

Big Sheets

Big Insights also comes with a spreadsheet-like interface to interact with Big data in a manner business users would use Excel. To do so, it presents a familiar interface (e.g. Pivot, Union, Intersection functions) that allows users to gather, filter, combine, explore, and visualize data from various sources. Big Sheets has been designed to be used by non-technical professionals to rapidly gather insight (BigSheets executes work on a simulated environment of sample data first) and analysis from huge amounts of data, and to be able to act on those insights in a timely manner. No need to understand database schemas, no need to understand a query language. And Big Sheets conveniently has a built-in visualization module to chart and publish the results.
Also, the nice thing about it is that Big Sheets is integrated natively with the other Big Insights components, so it’s easy to navigate between the different tools that Big Insights provides; e.g. create an ETL job in Jaql and export the results to Big Sheets..


Big Data Accelerators

Big Insights bundles in some pre-built components for specific solutions to accelerate development on certain specific use cases. The accelerators generally provide business logic, data processing and visualization. An example of this is the Social Data Analytics accelerator, providing  a set of predefined elements as workbooks and dashboards to analyse social data.

Other Big Data tools

The IBM Big Data platform is comprised of Big Sheets, but also other tools like Infosphere Streams for low latency data, and an MPP (Massively Parallel Processing) database. The IBM ecosystem also seems to support Big Data: R is supported in Big Insights, Cognos supports Hive, Netezza integrates with Streams. These systems offer complementary analytical approaches.

IBM offers a free downloadable virtual machine to play with Big Insights.

Overall a good experience, although one can get easily lost by the sea of products IBM offers. On the other hand  tools like Big Sheets and the Accelerators seem very valuable.

Monday, November 25, 2013

Stinger and Tez: a primer

Stinger and Tez: A primer


Recently I had the opportunity to attend a talk from Hortonworks’ own Alan Gates about Tez and Stinger. Here are the notes from this talk.

What is Stinger?


The Stinger initiative aims to redesign Hive to make it what people want today: Hive is currently used for large batch jobs and works great in that sense; but people also want interactive queries, and Hive is too slow today for this. So a big drive is performance, aiming to be 100x faster.
Additionally Hive doesn’t support all of the native SQL features for analytics (e.g. Date calculations, Windowing) so to be able to connect to a BI stack, and give Hive to SQL power users.
Stinger also covers work that is in HDFS and YARN. An example of this is the new data format, ORC. Thus Stinger is not only focused on Hive, it is a cross-project initiative.
This is work done as open source, by Hortonworks, but also SAP, Microsoft, and Facebook.

Why build upon Hive rather than build a new system?


Hive is out there and being used, and works at scale. It s hard to build a new tool that works at scale; it is easy to build a tool that is fast, but works on a small dataset (Gigabyte range).
Hive already manages at scale, and scale is hard. And now the effort is focused on making it faster. It is easier to do this rather than build in scale afterwards..

Also from a vision perspective, users only need one SQL tool, not a fragmented toolkit. Otherwise different tools are going to use different flavors of SQL, different data types, which is going to create an impedance mismatch and going to cause frustration for users. So the focus is to build just one tool, that does both batch and interactive, and have the optimizer make the right decision: is it a query that’s going to run for an hour so I should use batch type operators, or is it going to take 5 sec so I should run it in an interactive way?


Why is SQL compatibility so important?


            SQL is the English of the data world. You can get by pretty much anywhere with English when you are traveling. It is the same way with SQL, it is the language that everyone knows, and there is a workforce of analysts and set of BI tools that speak SQL. It just makes sense that Hadoop can speak SQL.
However Hadoop can not just speak SQL; Hadoop is so much more than that. YARN brings different data processing models: a real time streaming-type models like Storm, a graph processing model like Gyraph, an ETL model like Pig.
Stinger is not only focusing on SQL. Tez and Stinger open up to other tools like Pig, Cascading and make sure everyone can share the benefit.
SQL is how most of the world is going to communicate with Hadoop.

What is Tez and how does it relate to the Stinger initiative?

In Hadoop 1.0, there was only one option for how to execute their data processing: Map Reduce.

YARN

Map Reduce is a great paradigm for a whole set of problems, but in a context of a relational system that is going to stream together a set of relational operators, like Pig, Hive or Cascading, Map Reduce is not the design that you would choose if you starting out from a clean slate. That’s when Hadoop 2.0 comes in with YARN, which separates out resource management from execution. The execution moves from the system to user space, where the user can write an application manager that controls how the job is executed, so that is the opportunity for Pig and Hive to write an app manager tailored to them: Tez. Tez is application that runs on YARN, that builds the underlying execution for a parallel data processing engine for running relational operators like Group by, Join, sort. Tez is being evolved from Map Reduce, with strengths like recoverability that are baked in, and still scales and can handle faults. The underplaying execution layer can handle multiple inputs, which is needed for joins. Map Reduce 1.0 only accepts one input, and additional code is needed to shoehorn joins into it. In Tez, joins are supported natively in the execution layer.

Data movement

Also it frees you up in how you move data; in MR you write data to disk in intermediary stages for persistence in HDFS; this is great for large batch jobs, and you don’t want to give that up, but for quick interactive jobs, you want to be able to move data into memory or via sockets so you can stream in data very quickly. The goal behind Tez is to enable both of those, where the optimizer of the application (like Hive, Pig) can makes the choice: should I use socket-based streaming because I know this is going to be really fast, or should I use HDFS-based communication because this job is going to take an hour, and if it blows at the 59th minute I don’t want to loose everything?

Startup times

Also, Tez is about driving down the job startup times: MR was built where jobs would take an hour on average; so if it took 30 sec to start the job it was just noise. This is the way it was designed. But for interactive jobs, it is important to drive down the startup times from seconds into milliseconds.

Chip architecture optimizations

Also, Tez will be rewritten to add internal optimizers in Hive to take advantage of chip architectures; traditional databases have operated on 1 record at a time. But you can now process multiple records at a time.

Buffer caching

The next Stinger phase will be about buffer caching for Hadoop: Hadoop needs to know what it needs to keep in memory vs. what should be on disk. Hadoop was build around the notion that you scan everything on disk every time , and that is a great fit for batches , but some jobs and data sets you need to hold the data in memory in the cache , if for example you are doing some frequent joins with say dimension tables. Web buffer caching strategies will help in that respect.

Cost-base optimizers

Hive needs a true cost-based optimizer for Hive, instead of the current rules-based optimizer.
For example it almost always make sense to execute a filter before a join statement. But today Hive is complex enough that there are options in how it executes things, and you don’t know what the right answer is, so you will need to make estimates on what is the optimal plan to execute a particular statement.


What Tez means for Pig and other tools?


            Building Tez not just in Hive; Pig: their API’s are fairly different; different tools expose different API’s that are more appropriate for different use cases. Underneath, there are only so many things that you do to data: you can either sort it, join it, group it, filter it, or project it. Having separate implementations for this is wasted effort. Tez optimizes the execution of these operators to make sure it is shareable across the stack to different tools.



Wednesday, November 20, 2013

How to install something on multiple machines at once with pssh (parallel ssh)

It is a common practice to need to install and configure something on multiple machines at once. While there are a number of tools to do this, a quick and dirty way to do this is with parallel ssh. i had a bit of a hard time setting this up the first time, so are my notes on how to configure this correctly. This was tested on Ubuntu but may work on other platforms as well. First, install parallel-ssh .
sudo aptitude install pssh
Then you will need to grant passwordless authentication to the remote machines for pssh to work. First, we have to generate an SSH key:œœ
ssh-keygen -t rsa -P ""
The second line will create an RSA key pair with an empty password. Generally, using an empty password is not recommended, but in this case it is needed to unlock the key without your interaction (you don’t want to enter the passphrase every time Hadoop interacts with its nodes). Second, you have to enable SSH access to your local machine with this newly created key. cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys Third, distribute the public key to the other machines:
ssh-copy-id -i $HOME/.ssh/id_rsa.pub root@machine2 ssh-copy-id -i $HOME/.ssh/id_rsa.pub root@machine3
and you are done. pssh is now renamed parallel-ssh. Let's give it a try:
root@tabitha7:~# parallel-ssh -h ./cassandrahosts -i ls [1] 11:23:32 [SUCCESS] x.x.x.71 tomcat [2] 11:23:32 [SUCCESS] x.x.x.74 jdk-6u45-linux-x64.bin