Data Analysis with EMR.

Video demo: Run Spark Application(Scala) on Amazon EMR (Elastic MapReduce) cluster【EMR 5.3.1】

一个实战为王的年代,嘿嘿嘿~

数据分析的一般过程

步骤 1:设置示例集群的先决条件

创建 Amazon S3 存储桶

创建 Amazon EC2 密钥对

步骤 2:启动示例 Amazon EMR 集群

Goto: Create Cluster - Quick Options

关于服务器型号的选择,参见:[AWS] EC2 & GPU

名词解释

Spark 2.4.3 on Hadoop 2.8.5

YARN with Ganglia 3.7.2 and Zeppelin 0.8.1

    • Ganglia 是UC Berkeley发起的一个开源集群监视项目,设计用于测量数以千计的节点。
    • Zeppelin 是一个Web笔记形式的交互式数据查询分析工具,可以在线用scala和SQL对数据进行查询分析并生成报表。

Cluster 控制台

/* 需要找个教程全面学习下 */

在 Network and hardware (网络和硬件) 下,查找 Master (主) 和 Core (核心) 实例状态。

集群创建过程中,状态将经历 Provisioning (正在预置) 到 Bootstrapping (正在引导启动) 到 Waiting (正在等待) 三个阶段。

一旦您看到 Security groups for Master (主节点的安全组) 和 Security Groups for Core & Task (核心与任务节点的安全组) 对应的链接,即可转至下一步,但您可能需要一直等到集群成功启动且处于 Waiting (正在等待) 状态。

步骤 3:允许从客户端到集群的 SSH 连接

进入master的ec2主机,然后通过ssh登录。

记得在 Security Group 中修改配置,支持ssh。

步骤 4:通过以步骤形式运行 Hive 脚本来处理数据

关于准备数据集,参见:[AWS] S3 Bucket

步骤 5:清理资源

需终止集群并删除 Amazon S3 存储桶以免产生额外费用。

经验谈

一、Medicaid Dataset

数据比较大,如何预处理大数据。

Ref: Preprocessing data with Scalding and Amazon EMR

传统方案的弊端 - Local Pandas

the possiblity of building a model to predict the probability of chronic disease given the claim codes for a patient. Pandas over IPython was okay for doing analysis with a subset (single file) of data, but got a bit irritating with the full dataset because of frequent hangs and subsequent IPython server restarts.

预测一个病人是否患有这个疾病,是个预测模型。

Pandas适合将一个单独的表作为输入,数据过多容易导致系统崩溃。

代码展示:Medicaid Dataset - Basic Data Analysis of Benefit Summary Data

对数据集内容做了大概的了解。

大数据方案 - AWS EMR

This post describes a mixture of Python and Scala/Scalding code that I hooked up to convert the raw Benefits and Inpatient Claims data from the Medicare/Medicaid dataset into data for an X matrix and multiple y vectors, each y corresponding to a single chronic condition. Scalding purists would probably find this somewhat inelegant and prefer a complete Scalding end-to-end solution, but my Scalding-fu extends only so far - hopefully it will improve with practice.

二、大数据处理综述

From: Data Processing and Text Mining Technologies on Electronic Medical Records: A Review

Abstract

应用之潜力:Currently, medical institutes generally use EMR to record patient’s condition, including diagnostic information, procedures performed, and treatment results. EMR has been recognized as a valuable resource for large-scale analysis.

存在的问题:However, EMR has the characteristics of diversity, incompleteness, redundancy, and privacy, which make it difficult to carry out data mining and analysis directly.

预处理魔力:Therefore, it is necessary to preprocess the source data in order to improve data quality and improve the data mining results.

Different types of data require different processing technologies.

结构化数据:Most structured data commonly needs classic preprocessing technologies, including data cleansing, data integration, data transformation, and data reduction.

非结构化化:For semistructured or unstructured data, such as medical text, containing more health information, it requires more complex and challenging processing methods.

The task of information extraction for medical texts mainly includes NER (named-entity recognition) and RE (relation extraction).

This paper focuses on the process of EMR processing and emphatically analyzes the key techniques. In addition, we make an in-depth study on the applications developed based on text mining together with the open challenges and research issues for future work.

非常好的一篇文章,拿出一个案例为样品对大数据处理的各个流程做了阐述。

有时间不妨细看下。

方案对比

一、AWS Big Data Blog

一些新技术阐述:AWS Big Data Blog

很好的代码样例:https://github.com/aws-samples/aws-big-data-blog

一个经典的案例:Nasdaq’s Architecture using Amazon EMR and Amazon S3 for Ad Hoc Access to a Massive Data Set

RedShift

The Nasdaq Group has been a user of Amazon Redshift since it was released and we are extremely happy with it. We’ve discussed our usage of that system at re:Inventseveral times, the most recent of which was FIN401 Seismic Shift: Nasdaq’s Migration to Amazon Redshift. Currently, our system is moving an average of 5.5 billion rows into Amazon Redshift every day (14 billion on a peak day in October of 2014).

可见数据量非常庞大且高频。

Why Amazon S3 and Amazon EMR?

We can avoid these problems by using Amazon S3 and Amazon EMR, allowing us to separate compute and storage for our data warehouse and scale each independently.

Data Ingest Workflow

/* 略,没啥意思 */

二、Glue + Athena

From: 使用 AWS Glue 和 Amazon Athena 实现无服务器的自主型机器学习

目的

使用 AWS Glue 提取位于 Amazon S3 上有关出租车行驶情况的数据集,

并使用 K-means 根据行车坐标将数据分成 100 个不同的集群。

然后,我会使用 Amazon Athena 查询行驶次数和每个集群的大概区域。

最后,我会使用 Amazon Athena 来计算行驶次数最多的四个区域的坐标。

使用 AWS Glue 和 Amazon Athena 都可以执行这些任务,无需预置或管理服务器。

基本思路

该脚本使用 Spark 机器学习 K-means 集群库,基于坐标划分数据集。

该脚本通过加载绿色出租车数据并添加指示每一行被分配到哪个集群的列来执行作业。

该脚本采用 parquet 格式将表保存到 Amazon s3 存储桶 (目标文件)。

可以使用 Amazon Athena 查询存储桶。

执行 AWS Glue 作业

Glue抓取数据,然后kmean后将结果保存在S3中。

然后通过Athena做一些简单的查询。

问题来了:pySpark.kmean是否 base on EMR。

结论:

  先把glue用熟,积累一些简单的pipeline的处理经验后,再进阶使用emr处理复炸的Pipeline,或者也就是自定义搭建复杂pipeline。

End.

[AWS] 02 - Pipeline on EMR的更多相关文章

  1. 【redis 学习系列08】Redis小功能大用处02 Pipeline、事务与Lua

    3.Pipeline 3.1 Pipeline概念 Redis客户端执行一条命令分为如下四个过程: (1)发送命令 (2)命令排队 (3)命令执行 (4)返回结果 其中(1)和(4)称为Round T ...

  2. [AI] 深度数据 - Data

    Data Engineering Data  Pipeline Outline [DE] How to learn Big Data[了解大数据] [DE] Pipeline for Data Eng ...

  3. [Unity3D] 05 - Access to DB or AWS

    可以选择连接本地服务器,或者云服务器. 参考源代码 : https://www.cnblogs.com/wuzhang/p/wuzhang20141202.html (1) 功能:点击一下按键,然后访 ...

  4. AWS产品目录

    计算 Amazon EC2:弹性虚拟机 AWS Batch:批处理计算 Amazon ECR:Docker容器管理 Amazon ECS:高度可扩展的快速容器管理服务 Amazon EKS:在AWS上 ...

  5. aws产品整理

    计算 Amazon EC2:弹性虚拟机 AWS Batch:批处理计算 Amazon ECR:Docker容器管理 Amazon ECS:高度可扩展的快速容器管理服务 Amazon EKS:在AWS上 ...

  6. AWS 数据分析服务(十)

    Amazon Kinesis 概念 处理AWS上大量流数据的数据平台 Kinesis Streams 用于搜集数据,Client Library 用于分析后的展示 构建用于处理或分析流数据的自定义应用 ...

  7. AWS 数据库(七)

    数据库概念 关系型数据库 关系数据库提供了一个通用接口,使用户可以使用使用 编写的命令或查询从数据库读取和写入数据. 关系数据库由一个或多个表格组成,表格由与电子表格相似的列和行组成. 以行列形式存储 ...

  8. drone的pipeline原理与代码分析

    最近的一个项目,需要实现一个工作任务流(task pipeline),基于之前CICD的经验,jenkins pipeline和drone的pipeline进入候选. drone是基于go的cicd解 ...

  9. Aws Dynamodb数据导出到S3

    本节将描写叙述怎样从一个或多个DynamoDB的表导出数据到S3的bucket中.在运行导出之前你须要提前创建好S3的bucket. 注意 假设你还没有使用过AWS Data Pipeline,在运行 ...

随机推荐

  1. Django上线部署之Apache

    环境: 1.Windows Server 2016 Datacenter 64位 2.SQL Server 2016 Enterprise 64位 3.Python 3.6.0 64位 4.admin ...

  2. HBase 系列(七)——HBase 过滤器详解

    一.HBase过滤器简介 Hbase 提供了种类丰富的过滤器(filter)来提高数据处理的效率,用户可以通过内置或自定义的过滤器来对数据进行过滤,所有的过滤器都在服务端生效,即谓词下推(predic ...

  3. 单元测试之NUnit三

    NUnit 分三篇文章介绍,入门者可阅读文章,有基础者直接参考官方文档.初次写博客,望大家指点. 导航: 单元测试之NUnit一 单元测试之NUnit二 单元测试之NUnit三 除了Assert断言外 ...

  4. getline()与get()(c++学习笔记)

    istream中的类(如cin)提供了一些面向行的类成员函数:getline()和get() 1.getline()函数 读取整行,使用回车键输入的换行符来确定输入结尾. 调用方法:cin.getli ...

  5. slice splice(数组) 和 slice substr substring split (字符串)的区别

    array.slice(start,end)slice()如果不传入参数二,那么将从参数一的索引位置开始截取,一直到数组尾如果两个参数中的任何一个是负数,array.length会和它们相加 stri ...

  6. .NET平台下,钉钉微应用开发之:获取userid

    工作需求,开发钉钉微应用和小程序,之前有接触过支付宝小程序和生活号的开发,流程没有很大的差别,这里记录下我用ASP.NET MVC实现钉钉微应用的开发,并实现获取用户的userid.小弟我技术有限,本 ...

  7. 本地图片上传到GitHub,MarkDown使用Github图片地址

    最近在学习用markdown编辑器,我是直接用有道云笔记编辑的,感觉真的好好用,编辑了一半的博客,可以按样式保存在云笔记中,我再也不会忘记写博客了~~ 但是在编辑博客的时候发现了一个问题,那就是本地图 ...

  8. POJ 1661 暴力dp

    题意略. 思路: 很有意思的一个题,我采用的是主动更新未知点的方式,也即刷表法来dp. 我们可以把整个路径划分成横向移动和纵向移动,题目一开始就给出了Jimmy的高度,这就是纵向移动的距离. 我们dp ...

  9. hdfs运行机制

    hdfs:分布式文件系统 hdfs有着文件系统共同的特征: 1.有目录结构,顶层目录是:  / 2.系统中存放的就是文件 3.系统可以提供对文件的:创建.删除.修改.查看.移动等功能 hdfs跟普通的 ...

  10. LeetCode115不同的子序列

    题目说明在这里就不贴出来了,相信打开这篇文章的小伙伴们肯定都是在刷LeetCode的. 一开始我的想法是dfs+回溯,结果运行超时,一开始我就觉得可能会超时,结果不出所料[手动笑哭]. 后来我想了下d ...