Providing quick access to ready-to-use Big Data solutions
Because Big Data doesn't have to be complicated
Javier Cacheiro / Cloudera Certified Developer for Hadoop / @javicacheiro
Compute centric: bring the data to the computation
Data centric: bring the computation to the data
Jonathan Dursi: HPC is dying, and MPI is killing it
| Framework | Lines | Lines of Boilerplate |
|---|---|---|
| MPI+Python | 52 | 20+ |
| Spark+Python | 28 | 2 |
| Chapel | 20 | 1 |
To upload a file from local disk to HDFS:
hdfs dfs -put file.txt file.txt
It will copy the file to /user/username/file.txt in HDFS.
To list files in HDFS:
hdfs dfs -ls
Lists the files in our HOME directory of HDFS /user/username/
To list files in the root directory:
hdfs dfs -ls /
Create a directory:
hdfs dfs -mkdir /tmp/test
Delete a directory:
hdfs dfs -rm -r -f /tmp/test
Read a file:
hdfs dfs -cat file.txt
Download a file from HDFS to local disk:
hdfs dfs -get fichero.txt
You can easily access the HUE File Explorer from the WebUI:
You can easily access the NameNode UI from the WebUI:
yarn jar application.jar DriverClass input output
yarn application -list
yarn logs -applicationId applicationId
yarn application -kill applicationId
MapReduce is a programming model and an associated implementation for processing and generating large data sets with a parallel, distributed algorithm on a cluster.
To launch a job:
yarn jar job.jar DriverClass input output
To list running MR jobs:
mapred job -list
To cancel a job:
mapred job -kill [jobid]
You can easily monitor your jobs using the YARN UI from the WebUI:
You can see finished jobs using the MR2 UI from the WebUI:
PYSPARK_DRIVER_PYTHON=ipython pyspark
[jlopez@login7 ~]$ PYSPARK_DRIVER_PYTHON=ipython pyspark
>>> from pyspark.sql import Row
>>> Person = Row('name', 'surname')
>>> data = []
>>> data.append(Person('Joe', 'MacMillan'))
>>> data.append(Person('Gordon', 'Clark'))
>>> data.append(Person('Cameron', 'Howe'))
>>> df = sqlContext.createDataFrame(data)
>>> df.show()
+-------+---------+
| name| surname|
+-------+---------+
| Joe|MacMillan|
| Gordon| Clark|
|Cameron| Howe|
+-------+---------+
[jlopez@login6 ~]$ sparkR
[jlopez@login7 ~]$ sparkR
> df <- createDataFrame(sqlContext, faithful)
> head(df)
eruptions waiting
1 3.600 79
2 1.800 54
3 3.333 74
4 2.283 62
5 4.533 85
6 2.883 55
# client mode
spark-submit --master yarn \
--name testWC test.py input output
# cluster mode
spark-submit --master yarn --deploy-mode cluster \
--name testWC test.py input output
# client mode
spark-submit --master yarn --name testWC \
--class es.cesga.hadoop.Test test.jar \
input output
# cluster mode
spark-submit --master yarn --deploy-mode cluster \
--name testWC \
--class es.cesga.hadoop.Test test.jar \
input output
--num-executors NUM Number of executors to launch (Default: 2)
--executor-cores NUM Number of cores per executor. (Default: 1)
--driver-cores NUM Number of cores for driver (cluster mode)
--executor-memory MEM Memory per executor (Default: 1G)
--queue QUEUE_NAME The YARN queue to submit to (Default: "default")
--proxy-user NAME User to impersonate
Hive offers the possibility to use Hadoop through a SQL-like interface
Hive and Impala use the same SQL syntax HiveQL
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ':'
sqoop list-tables \
--username ${USER} -P \
--connect jdbc:postgresql://${SERVER}/${DB}
sqoop import \
--username ${USER} --password ${PASSWORD} \
--connect jdbc:postgresql://${SERVER}/${DB} \
--table mytable \
--target-dir /user/username/mytable \
--num-mappers 1
sqoop import \
--username ${USER} --password ${PASSWORD} \
--connect jdbc:postgresql://${SERVER}/${DB} \
--table mytable \
--target-dir /user/username/mytable \
--num-mappers 1 \
--hive-import
sqoop create-hive-table \
--username ${USER} --password ${PASSWORD} \
--connect jdbc:postgresql://${SERVER}/${DB} \
--table mytable
First create table into PostgreSQL
sqoop export \
--username ${USER} --password ${PASSWORD} \
--connect jdbc:postgresql://${SERVER}/${DB} \
--table mytable \
--export-dir /user/username/mytable \
--input-fields-terminated-by '\001' \
--num-mappers 1
For MySQL and PosgreSQL for faster performance you can use direct mode (--direct option)
Apache Mahout is a machine learning library that includes collaborative filtering, clustering and classification algorithms built using MapReduce.
Introduction to Item-Based Recommendations with HadoopLow-level routines for performing common linear algebra operations
Adds support to Python for fast operations with multi-dimensional arrays and matrices
Already configured to use Intel MKL
ssh -C2qTnNf -D 9876 @login.hdp.cesga.es
Using a powerful CLI through SSH:
ssh @login.hdp.cesga.es
Using a simple Web User Interface
The Jupyter Notebook is a web application that allows you to create and share documents that contain live code, equations, visualizations and explanatory text.
start_jupyter
The Jupyter Notebook is running at: http://1.2.3.4:8888/
git clone https://github.com/bigdatacesga/mr-wordcount
# Download sources and javadoc
mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc
# Update the existing Eclipse project
mvn eclipse:eclipse
# Or if you using Intellij IDEA
mvn idea:idea
Compile:
mvn compile
Run the tests
mvn test
Package your app
mvn package
If you prefer to compile and package manually:
javac -classpath $(hadoop classpath) *.java
jar cvf wordcount.jar *.class
Basic components of a program:
public class Driver {
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
Job job = Job.getInstance(conf);
job.setJarByClass(Driver.class);
job.setJobName("Word Count");
job.setMapperClass(WordMapper.class);
job.setCombinerClass(SumReducer.class);
job.setReducerClass(SumReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
FileInputFormat.setInputPaths(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
boolean success = job.waitForCompletion(true);
System.exit(success ? 0 : 1);
}
}
public class WordMapper
extends Mapper<LongWritable, Text, Text, IntWritable> {
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
@Override
public void map(LongWritable key, Text value, Context context)
throws IOException, InterruptedException {
String line = value.toString();
for (String field : line.split("\\W+")) {
if (field.length() > 0) {
word.set(field);
context.write(word, one);
}
}
}
}
public class SumReducer
extends Reducer<Text, IntWritable, Text, IntWritable> {
@Override
public void reduce(
Text key, Iterable<IntWritable> values, Context context)
throws IOException, InterruptedException {
int wordCount = 0;
for (IntWritable value : values) {
wordCount += value.get();
}
context.write(key, new IntWritable(wordCount));
}
}
We are here to help:
Stay up to date subscribing to our Mailing list