대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: gaming...

40
대용량 데이타 쉽고 빠르게 분석하기

Upload: amazon-web-services-korea

Post on 16-Apr-2017

830 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

대용량데이타쉽고빠르게분석하기

Page 2: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Demo Day.

Page 3: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Amazon RedshiftAmazon Elastic MapReduce

Amazon Glacier

Amazon DynamoDB

Amazon Machine Learning

Amazon Kinesis

Combinational Services for Data analytics

Data WarehouseSemi-structured NoSQL Predictive Models Other AppsStreaming

Amazon Simple Storage Service

Data Lake Archive

Log Generator

Page 4: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Create EC2 instance to generate logs

• AMI -> Public Images -> AMI Name : da-hands-on

• Select the AMI and Click Launch

• Instance Type: t2.medium

• Tag: Name - myname-dev

• Security group with SSH ingress opened

$ aws ec2 create-security-group --group-name andy-ssh-sg --description "open SSH only" --vpc-id vpc-33d27056 {

"GroupId": "sg-7f3dd918"}

Page 5: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

$ aws ec2 authorize-security-group-ingress --group-id sg-7f3dd918 --protocol tcp --port 22 --cidr 0.0.0.0/0

$ aws ec2 run-instances --image-id ami-5c2beb3d --count 1 --instance-type t2.medium --key-name ilho_tokyo --security-group-ids sg-7f3dd918 --subnet-id subnet-1a7bad43 --associate-public-ip-address{

"OwnerId": "806506827877", "ReservationId": "r-a58c5e2a", "Groups": [], "Instances": [

{"Monitoring": {

…..................

Page 6: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Create S3 bucket

• Bucket Name: myname-game-log

• Region: Tokyo

$ aws s3 mb s3://andy-game-log --region ap-northeast-1make_bucket: andy-game-log

Page 7: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Amazon RedshiftAmazon Elastic MapReduce

Amazon Glacier

Amazon DynamoDB

Amazon Machine Learning

Amazon Kinesis

Generating Logs to stream them to Kinesis

Data WarehouseSemi-structured NoSQL Predictive Models Other AppsStreaming

Amazon Simple Storage Service

Data Lake Archive

Log Generator

Page 8: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Create Kinesis Steam

• Stream Name: myname-game-stream

• Number of Shards: 1

$ aws kinesis create-stream --stream-name andy-game-stream --shard-count 1

$ aws kinesis list-streams

Page 9: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Amazon RedshiftAmazon Elastic MapReduce

Amazon Glacier

Amazon DynamoDB

Amazon Machine Learning

Amazon Kinesis

Combinational Services for Data analytics

Data WarehouseSemi-structured NoSQL Predictive Models Other AppsStreaming

Amazon Simple Storage Service

Data Lake Archive

Log Generator

Page 10: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Launch Redshift

• Cluster Identifier: myname-game-dw

• Database Name: mynamegame

• Database Port: 5439 (default)

• Node Type: dc1.large

• Cluster Type: Single Node

• Number of Compute Nodes: 1 (required for multi-node)

Page 11: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

$ aws redshift create-cluster --cluster-identifier andy-game-dw --db-name mydb --node-type dc1.large --cluster-type single-node --publicly-accessible --master-username admin --master-user-password GamingonAWS2016 {

"Cluster": {"IamRoles": [], "ClusterVersion": "1.0", "NodeType": "dc1.large", "PubliclyAccessible": true, "Tags": [], "MasterUsername": "admin", "ClusterParameterGroups": [

{"ParameterGroupName": "default.redshift-1.0", "ParameterApplyStatus": "in-sync"

}], "Encrypted": false,

…....................

Page 12: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Let’s connect to EC2 instances

$ ssh -i [$mykey].pem [email protected]

Page 13: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Prepared python demo scripts

[ec2-user@ip-10-10-0-13 data_analytics_demo]$ ls -1amazon_kclpyamazon_kclpy_helper.pyconfig.jsonconfig.pyconfig.pycconsumer.propertiesconsumer.pydemo_util.pydemo_util.pycinserter.pykclkinesis_helper.pykinesis_helper.pycLICENSElogsreader.pyrun_consumer.shsimulator.pysummarizer.py

Page 14: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Generating Logs to Kinesis stream

$ Python Simulator.py

https://github.com/awslabs/kinesis-poster-worker

Page 15: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Consuming Logs from Kinesis stream

$ python amazon_kclpy_helper.py --print_command --java $(which java) --properties ./consumer.properties

https://github.com/awslabs/amazon-kinesis-client-python

Page 16: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Checking Logs files in S3 bucket

$ aws s3 ls myname-game-log

Page 17: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Amazon RedshiftAmazon Elastic MapReduce

Amazon Glacier

Amazon DynamoDB

Amazon Machine Learning

Amazon Kinesis

What we’ve done so far.

Data WarehouseSemi-structured NoSQL Predictive Models Other AppsStreaming

Amazon Simple Storage Service

Data Lake Archive

Log Generator

Page 18: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Copy Log data from S3 to Redshift

$ python inserter.py

Page 19: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Checking log tables in Redshift

$ psql -h hostname -p 5439 -U username -d dbname

Dbname=# select * from log limit 10;

….............

Page 20: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Amazon RedshiftAmazon Elastic MapReduce

Amazon Glacier

Amazon DynamoDB

Amazon Machine Learning

Amazon Kinesis

Creating a new table in Redshift

Data WarehouseSemi-structured NoSQL Predictive Models Other AppsStreaming

Amazon Simple Storage Service

Data Lake Archive

Log Generator

Creating summary tables from log table

Page 21: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Creating a summary table from log table

$ python summarizer.py

Page 22: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Run Business Intelligence Tools

Amazon RedshiftAmazon Elastic MapReduce

Amazon

Glacier

Amazon DynamoDB

Amazon Machine Learning

Amazon Kinesis

Data WarehouseSemi-structured NoSQL Predictive Models Other AppsStreaming

Amazon Simple Storage Service

Data Lake Archive

Log Generator

Page 23: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Adding ElasticSearch

Page 24: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Loading Streaming Data into Amazon Elasticsearch Service

Amazon RedshiftAmazon Elastic MapReduce

Amazon

Glacier

Amazon DynamoDB

Amazon Machine Learning

Amazon Kinesis

Data WarehouseSemi-structured NoSQL Predictive Models Other AppsStreaming

Amazon Simple Storage Service

Data Lake Archive

Log Generator

Creating summary tables from log table

Amazon ElasticsearchService

Page 25: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Launch Elasticsearch

• Go to AWS management console

• Launch Elasticsearch domain

• Set access policy to public open for Demo only

Page 26: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Loading Streaming Data into Amazon Elasticsearch Service

Amazon RedshiftAmazon Elastic MapReduce

Amazon

Glacier

Amazon DynamoDB

Amazon Machine Learning

Amazon Kinesis

Data WarehouseSemi-structured NoSQL Predictive Models Other AppsStreaming

Amazon Simple Storage Service

Data Lake Archive

Log Generator

Creating summary tables from log table

Amazon ElasticsearchService

AWSLambda

Page 27: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Creating and configuring Lambda function

• https://github.com/awslabs/amazon-elasticsearch-lambda-samples

• Download a sample JS file

• Install required Nodejs packages

• Modify ElasticSearch endpoint

• Zip all files including node_modules

• Upload zip file to Lambda function

• Set lambda role to access Elasticsearch

Page 28: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Checking result at Kibana

• Query

• Result

Page 29: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Querying Amazon Kinesis Streams Directly with SQL and Spark Streaming?

Page 30: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

EMR and Spark Streaming

Amazon RedshiftAmazon Elastic MapReduce

Amazon

Glacier

Amazon DynamoDB

Amazon Machine Learning

Amazon Kinesis

Data WarehouseSemi-structured NoSQL Predictive Models Other AppsStreaming

Amazon Simple Storage Service

Data Lake Archive

Log Generator

Creating summary tables from log table

Amazon ElasticsearchService

AWSLambda

Page 31: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Creating EMR Cluster with Spark is a simple job

$ aws emr create-cluster --release-label emr-4.2.0 --applications Name=Spark Name=Hive --ec2-attributes KeyName=myKey --use-default-roles --instance-groups InstanceGroupType=MASTER,InstanceCount=1,InstanceType=m3.xlarge InstanceGroupType=CORE,InstanceCount=2,InstanceType=m3.xlarge --bootstrap-actions Path=s3://aws-bigdata-blog/artifacts/Querying_Amazon_Kinesis/DownloadKCLtoEMR400.sh,Name=InstallKCLLibs

Page 32: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Managing resources is easy. But building logics is complicating.

Page 33: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

• A fully managed service for continuously querying streaming data using standard SQL

• Use cases: Preprocessing streams / Most frequently occurring values Counting distinct values / Simple alerts / Detecting anomalies on a stream / Post processing in application stream

Real-time Log Analytics

Amazon Kinesis Analytics

Page 34: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Amazon Kinesis Analytics

Amazon RedshiftAmazon Elastic MapReduce

Amazon

Glacier

Amazon DynamoDB

Amazon Machine Learning

Amazon Kinesis

Data WarehouseSemi-structured NoSQL Predictive Models Other AppsStreaming

Amazon Simple Storage Service

Data Lake Archive

Log Generator

Creating summary tables from log table

Amazon ElasticsearchService

AWSLambda

Amazon Kinesis

Analytics

Page 35: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Demo.

Page 36: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
Page 37: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Adding Amazon Machine Learning

Page 38: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Adding Amazon Machine Learning is your homework.

Amazon Machine Learning 게임에서활용해보기:: 김일호 :: AWS Summit Seoul 2016https://www.youtube.com/watch?v=Bs1QZMlwmLM&feature=youtu.be

Page 39: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

A hint

Amazon RedshiftAmazon Elastic MapReduce

Amazon

Glacier

Amazon DynamoDB

Amazon Machine Learning

Amazon Kinesis

Data WarehouseSemi-structured NoSQL Predictive Models Other AppsStreaming

Amazon Simple Storage Service

Data Lake Archive

Log Generator

Creating summary tables from log table

Amazon ElasticsearchService

AWSLambda

Amazon Kinesis

Analytics

Page 40: 대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016

Thank you!