67
華麗なる Elastic Beanstalk での環境構築 2013年2月22日 NetCOBOLによるAWS活用事例とAWSを活用した事例セミナー 欧文印刷株式会社・田名辺健人 http://blog.dateofrock.com/

華麗なるElastic Beanstalkでの環境構築

Embed Size (px)

DESCRIPTION

NetCOBOLによるAWS活用事例とAWSを活用した事例セミナーにてお話しした、Elastic Beanstalkを活用すべき3つのポイントについてのスライドです。

Citation preview

Page 1: 華麗なるElastic Beanstalkでの環境構築

華麗なるElastic Beanstalkでの環境構築

2013年2月22日NetCOBOLによるAWS活用事例とAWSを活用した事例セミナー欧文印刷株式会社・田名辺健人 http://blog.dateofrock.com/

Page 2: 華麗なるElastic Beanstalkでの環境構築

Who am I ?(この顔にピンときたら)

Page 3: 華麗なるElastic Beanstalkでの環境構築

田名辺 健人(たなべたけひと)

ソフトウェアエンジニア

欧文印刷株式会社(東京都)高校まで札幌在住2011年11月から札幌でテレワーク

@dateofrock

http://blog.dateofrock.com/

有効期限切れてますww

Page 4: 華麗なるElastic Beanstalkでの環境構築

1946年創業/社員数130名本社:東京都文京区工場:埼玉県坂戸市

Page 5: 華麗なるElastic Beanstalkでの環境構築

アナログ・デジタル独自商品開発

Page 6: 華麗なるElastic Beanstalkでの環境構築

紙で出来たホワイトボード消せる紙(し)

http://www.g-mark.org/award/describe/39114

ノート型ホワイトボードNUboard

Page 7: 華麗なるElastic Beanstalkでの環境構築
Page 8: 華麗なるElastic Beanstalkでの環境構築

✓Elastic Beanstalkとは?✓使う3つの理由

Page 9: 華麗なるElastic Beanstalkでの環境構築

✓Elastic Beanstalkとは?✓使う3つの理由

Page 10: 華麗なるElastic Beanstalkでの環境構築

ウェブインターフェース 識別&アクセスIAM

Identity FederationConsolidated Billing

デプロイ&自動化AWSElasticBeanstalk

AWSCloudFormation

AWSMangement Console Amazon CloudWatch

モニタリング

マネージメント&管理

コンテンツ配信Amazon

CloudFront

メッセージング

AmazonSNS

AmazonSQS

AmazonSES

検索Amazon CloudSearch

分散処理

ElasticMapReduce

AmazonSWF

ライブラリ&SDKJava, PHP, Python,

Ruby, .NET

アプリケーションプラットフォームサービス

基本サービスコンピューティング クラウドストレージ データベース ネットワーク

AmazonEC2

AutoScaling Amazon

S3Amazon

EBSAWS Storage

GatewayAmazon

RDSAmazon

DynamoDBAmazon

ElasticacheAmazon

VPCElastic Load

BalancerAmazonRoute53

AWS DirectConnect

アベイラビリティ―ゾーン

リージョンエッジロケーション

AWSグローバルインフラストラクチャ

アマゾン ウェブ サービスの製品・サービス構成

©Amazon Web Services LLC or its affiliates. All rights reserved.

http://aws.amazon.com/jp/what-is-aws/

Page 11: 華麗なるElastic Beanstalkでの環境構築

ウェブインターフェース 識別&アクセスIAM

Identity FederationConsolidated Billing

デプロイ&自動化AWSElasticBeanstalk

AWSCloudFormation

AWSMangement Console Amazon CloudWatch

モニタリング

マネージメント&管理

コンテンツ配信Amazon

CloudFront

メッセージング

AmazonSNS

AmazonSQS

AmazonSES

検索Amazon CloudSearch

分散処理

ElasticMapReduce

AmazonSWF

ライブラリ&SDKJava, PHP, Python,

Ruby, .NET

アプリケーションプラットフォームサービス

基本サービスコンピューティング クラウドストレージ データベース ネットワーク

AmazonEC2

AutoScaling Amazon

S3Amazon

EBSAWS Storage

GatewayAmazon

RDSAmazon

DynamoDBAmazon

ElasticacheAmazon

VPCElastic Load

BalancerAmazonRoute53

AWS DirectConnect

アベイラビリティ―ゾーン

リージョンエッジロケーション

AWSグローバルインフラストラクチャ

アマゾン ウェブ サービスの製品・サービス構成

©Amazon Web Services LLC or its affiliates. All rights reserved.

Page 12: 華麗なるElastic Beanstalkでの環境構築

ウェブインターフェース 識別&アクセスIAM

Identity FederationConsolidated Billing

デプロイ&自動化AWSElasticBeanstalk

AWSCloudFormation

AWSMangement Console Amazon CloudWatch

モニタリング

マネージメント&管理

コンテンツ配信Amazon

CloudFront

メッセージング

AmazonSNS

AmazonSQS

AmazonSES

検索Amazon CloudSearch

分散処理

ElasticMapReduce

AmazonSWF

ライブラリ&SDKJava, PHP, Python,

Ruby, .NET

アプリケーションプラットフォームサービス

基本サービスコンピューティング クラウドストレージ データベース ネットワーク

AmazonEC2

AutoScaling Amazon

S3Amazon

EBSAWS Storage

GatewayAmazon

RDSAmazon

DynamoDBAmazon

ElasticacheAmazon

VPCElastic Load

BalancerAmazonRoute53

AWS DirectConnect

アベイラビリティ―ゾーン

リージョンエッジロケーション

AWSグローバルインフラストラクチャ

アマゾン ウェブ サービスの製品・サービス構成

©Amazon Web Services LLC or its affiliates. All rights reserved.

2013/02/19追加!

AWSOpsWorks

Page 13: 華麗なるElastic Beanstalkでの環境構築

ウェブインターフェース 識別&アクセスIAM

Identity FederationConsolidated Billing

デプロイ&自動化AWSElasticBeanstalk

AWSCloudFormation

AWSMangement Console Amazon CloudWatch

モニタリング

マネージメント&管理

コンテンツ配信Amazon

CloudFront

メッセージング

AmazonSNS

AmazonSQS

AmazonSES

検索Amazon CloudSearch

分散処理

ElasticMapReduce

AmazonSWF

ライブラリ&SDKJava, PHP, Python,

Ruby, .NET

アプリケーションプラットフォームサービス

基本サービスコンピューティング クラウドストレージ データベース ネットワーク

AmazonEC2

AutoScaling Amazon

S3Amazon

EBSAWS Storage

GatewayAmazon

RDSAmazon

DynamoDBAmazon

ElasticacheAmazon

VPCElastic Load

BalancerAmazonRoute53

AWS DirectConnect

アベイラビリティ―ゾーン

リージョンエッジロケーション

AWSグローバルインフラストラクチャ

アマゾン ウェブ サービスの製品・サービス構成

©Amazon Web Services LLC or its affiliates. All rights reserved.

2013/02/19追加!

AWSOpsWorks

Page 14: 華麗なるElastic Beanstalkでの環境構築

時間もないので

Page 15: 華麗なるElastic Beanstalkでの環境構築

AWSの良い資料があります

【注】スライドの手抜きではありません(笑)

Page 17: 華麗なるElastic Beanstalkでの環境構築

AWS資料より抜粋 http://www.slideshare.net/AmazonWebServicesJapan/getting-startedwithbeanstalk-20130111

Page 18: 華麗なるElastic Beanstalkでの環境構築

AWS資料より抜粋 http://www.slideshare.net/AmazonWebServicesJapan/getting-startedwithbeanstalk-20130111

Page 19: 華麗なるElastic Beanstalkでの環境構築

AWS資料より抜粋 http://www.slideshare.net/AmazonWebServicesJapan/getting-startedwithbeanstalk-20130111

Page 20: 華麗なるElastic Beanstalkでの環境構築

AWS資料より抜粋 http://www.slideshare.net/AmazonWebServicesJapan/getting-startedwithbeanstalk-20130111

続きはWebで

Page 21: 華麗なるElastic Beanstalkでの環境構築

✓Elastic Beanstalkとは?✓使う3つの理由

Page 22: 華麗なるElastic Beanstalkでの環境構築

✓Elastic Beanstalkとは?✓使う3つの理由

Page 23: 華麗なるElastic Beanstalkでの環境構築

【1】簡単すぎる環境構築

Page 24: 華麗なるElastic Beanstalkでの環境構築
Page 25: 華麗なるElastic Beanstalkでの環境構築
Page 26: 華麗なるElastic Beanstalkでの環境構築

war

Page 27: 華麗なるElastic Beanstalkでの環境構築
Page 28: 華麗なるElastic Beanstalkでの環境構築
Page 29: 華麗なるElastic Beanstalkでの環境構築

構築+deploy完了

Page 30: 華麗なるElastic Beanstalkでの環境構築

EC2 InstanceElastic Load Balancing

S3

war

Cloud Watch SNS

EC2 Instance

Elastic Beanstalk Environment

Auto scaling group

Page 31: 華麗なるElastic Beanstalkでの環境構築
Page 32: 華麗なるElastic Beanstalkでの環境構築

$ git aws.push

Page 33: 華麗なるElastic Beanstalkでの環境構築

【2】便利なSwap URL

Page 34: 華麗なるElastic Beanstalkでの環境構築

本番環境+

ステージング環境

Page 35: 華麗なるElastic Beanstalkでの環境構築
Page 36: 華麗なるElastic Beanstalkでの環境構築

2つの environment

Page 37: 華麗なるElastic Beanstalkでの環境構築

environment1honban.elasticbeanstalk.com

Page 38: 華麗なるElastic Beanstalkでの環境構築

environment1Running Version: version2

Page 39: 華麗なるElastic Beanstalkでの環境構築

environment2staging.elasticbeanstalk.com

Page 40: 華麗なるElastic Beanstalkでの環境構築

environment2Running Version: version3

Page 41: 華麗なるElastic Beanstalkでの環境構築

ステージングを本番に昇格

Page 42: 華麗なるElastic Beanstalkでの環境構築
Page 43: 華麗なるElastic Beanstalkでの環境構築

SwapEnvironmentURL

Page 44: 華麗なるElastic Beanstalkでの環境構築
Page 45: 華麗なるElastic Beanstalkでの環境構築

staging.elasticbeanstalk.com

honban.elasticbeanstalk.com

Page 46: 華麗なるElastic Beanstalkでの環境構築

本番がversion3になりました!

Page 47: 華麗なるElastic Beanstalkでの環境構築

【3】必要十分なConfig

Page 48: 華麗なるElastic Beanstalkでの環境構築

AMI

Page 49: 華麗なるElastic Beanstalkでの環境構築

AMI

素のAMIをカスタマイズしたい!

Page 50: 華麗なるElastic Beanstalkでの環境構築

AMI

✓パッケージ インストール✓コンテナ カスタマイズ

etc...

Page 51: 華麗なるElastic Beanstalkでの環境構築
Page 52: 華麗なるElastic Beanstalkでの環境構築

YAML

Page 53: 華麗なるElastic Beanstalkでの環境構築

YAML

$APP_ROOT/.ebextensions/*.config

✓パッケージインストール✓アーカイブダウンロード + 展開✓ファイル生成 or コピー✓OSユーザー・グループ作成✓コマンド実行(OS用)✓コマンド実行(コンテナ用)✓サービス設定(/etc/init.d)✓Beanstalk固有の設定

Page 54: 華麗なるElastic Beanstalkでの環境構築

YAML

Page 55: 華麗なるElastic Beanstalkでの環境構築

packages: yum: libmemcached: [] ruby-devel: [] nfs-utils: [1.0.9]

rpm, yum, apt,rubygems (chef)

Page 56: 華麗なるElastic Beanstalkでの環境構築

sources: /usr/local/bin:↵

http://hoge.com/hoge.tar.gz

tar, tar+gzip, tar+bz2, zip

Page 57: 華麗なるElastic Beanstalkでの環境構築

files: "/home/ec2-user":

mode: "000777" owner: ec2-user group: ec2-user source: http://hoge.com/a.txt

Page 58: 華麗なるElastic Beanstalkでの環境構築

files: "/home/ec2-user":

mode: "000777" owner: ec2-user group: ec2-user content: |

# this is my file# with content

content直書きOK

Page 59: 華麗なるElastic Beanstalkでの環境構築

users: myuser: groups: group1 group2 uid: "50" homeDir: “/tmp”groups: - groupOne - groupTwo gid: "45"

Page 60: 華麗なるElastic Beanstalkでの環境構築

commands: test: command: myscript.py cwd: /home/ec2-user env: myvarname: myvarvalue

Page 61: 華麗なるElastic Beanstalkでの環境構築

container_commands: replace-server_xml: command: ↵ cp .ebextensions/server.xml ↵

/etc/tomcat7/server.xml

server.xmlの置換

Page 62: 華麗なるElastic Beanstalkでの環境構築

container_commands: 01syncdb: command: "django-admin.py syncdb --noinput" leader_only: true 02migrate: command: "django-admin.py migrate" leader_only: true

マイグレーションの実行

Page 63: 華麗なるElastic Beanstalkでの環境構築

services: sysvinit: myservice: enabled: true ensureRunning: true

Page 64: 華麗なるElastic Beanstalkでの環境構築

option_settings: - namespace: ↵ aws:elasticbeanstalk:container:tomcat:jvmoptions option_name: Xmx value: 512m - option_name: AWS_SECRET_KEY value: SECRET_KEY - option_name: AWS_ACCESS_KEY_ID value: ACCESS_KEY

Page 65: 華麗なるElastic Beanstalkでの環境構築
Page 66: 華麗なるElastic Beanstalkでの環境構築

✓Elastic Beanstalkとは?✓使う3つの理由1.簡単すぎる環境構築2.便利なSwap URL3.必要十分なConfig

Page 67: 華麗なるElastic Beanstalkでの環境構築

Elastic Beanstalkで華麗に環境構築しよう!

おしまい