はじめてみよう!クラウドコンピューティングの a to z ~ getting started with...
TRANSCRIPT
1© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
アマゾン ウェブ サービス ジャパン株式会社テクニカルトレーナー
二條 智文
2017/09/21
はじめてみよう!クラウドコンピューティングの A to Z~ Getting Started with AWS
Computing ~
2© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
概要Amazon
EC2
関連サービス負荷分散
AutoScaling
運用モニタリング自動化
今日お話しする事 ~AWS Computing~
3© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS に関するおさらい
4© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon の歴史
1994: Jeff Bezos により設立
1995:
Amazon.com
としてオンライ
ン書店を開始
2005: Amazon Publishingを開始
2006:
アマゾン ウェブ サー
ビス (AWS) を開始
2007: Kindleを開始
2011: Amazon
Freshを開始
2012: Amazon Game Studiosを開始
2013: Amazon Artを開始
2014: Amazon Prime Nowを開
始
2015:
Amazon Home
Services &
Amazon Echo を開
始
5© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
高速で進む AWS のイノベーション
2009
48
159
722
82
2011 2013 2015
機能改善と新しいサービス
1017
2016
7© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
クラウドコンピューティングサービスとは?
インターネット経由のオンデマンドITリソース
事前契約書は不要、すぐに使い始めることが可能
自前のデータセンターやサーバは不要
必要な分を使った分だけ支払う従量課金制
ITリソースは、拡大や縮小が自由
規模の経済性が働く
データセンター ストレージ機器サーバー契約書
不要
8© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS のコアインフラストラクチャとサービス
AWS Technical Essentials 3.8 ILT
セキュリティ
ネットワーク
セキュリティ
ネットワーク
セキュリティグループNACL Access Mgmt
VPCVPCEC2 "クラシック"
"パブリック"
ELBオンデマンド
プロビジョン
従来のインフラストラクチャ アマゾン ウェブ サービス
サーバー
AMI Amazon EC2 インスタンスオンプレミスサーバー
セキュリティセキュリティグループ NACL AWS IAMファイアウォール ACL 管理者
ネットワーキング
VPCELBルーター ネットワークパイプライン スイッチ
ストレージとデータベース
RDBMSDAS SAN NAS AmazonEBS
AmazonEFS
AmazonS3
AmazonRDS
11© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWSグローバルインフラストラクチャ
12© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS グローバルインフラストラクチャ - AZ
リージョン (Region)地理的ロケーション最低 2 つのアベイラビリティーゾーン (AZ) で構成される
アベイラビリティーゾーン
(AZ = Availability Zone)
データセンターのクラスター
他のアベイラビリティーゾーンの障害から分離
アベイラビリティーゾーン – A
アベイラビリティーゾーン – B
アベイラビリティーゾーン – C
リージョン
13© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS グローバルインフラストラクチャ
(August 11, 2017)
16 のリージョン1. 米国東部(バージニア北部)
2. 米国東部 (オハイオ)
3. 米国西部 (北カリフォルニア)
4. 米国西部 (オレゴン)
5. カナダ (中部)
6. 欧州 (アイルランド)
7. 欧州 (フランクフルト)
8. 欧州 (ロンドン)
9. アジアパシフィック (東京)
10. アジアパシフィック (ソウル)
11. アジアパシフィック (シンガポール)
12. アジアパシフィック (シドニー)
13. アジアパシフィック (ムンバイ)
14. 南米 (サンパウロ)
15. 中国(北京)
16. GovCloud
44 のアベイラビリティゾーン
82 のエッジロケーション
14© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
概要Amazon
EC2
関連サービス負荷分散
Auto Scaling
運用モニタリング自動化
今日お話しする事 ~AWS Computing~
15© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon Elastic Compute Cloud (EC2)
仮想コンピューティング環境(仮想サーバ / インスタンス)
数分で起動し、1時間ごとの従量課金で利用可能
追加・削除、スペック変更が数分で可能
管理者権限 (root / Administrator) で利用可能
Amazon EC2
16© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon EC2 インスタンスの起動
OS、アプリケーション、設定
AMI
スペック(CPU、メモリ)
インスタンスタイプ
AZ
VPC
リージョン
EBS EBS EBS EBS EBS EBS
AZ
インスタンス インスタンス
数分で起動
17© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
EC2 数分間クッキング!
ほんとうに数分で起動するのかやってみましょう
18© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon EC2 インスタンスの起動
OS、アプリケーション、設定
AMI
スペック(CPU、メモリ)
インスタンスタイプ
AZ
VPC
リージョン
EBS EBS EBS EBS EBS EBS
AZ
インスタンス インスタンス
19© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
AMIとは
AMI(Amazonマシンイメージ)はインスタンス起動に必要なOSイメージ
AMI に含まれるもの
インスタンスのルートボリュームのテンプレート(OS、アプリケーションなど)
起動時にインスタンスにアタッチするボリュームを指定するブロックデバイスマッピング
起動権限
20© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
AMIを探す
Amazon が提供コミュニティAMI コンソールでEC2起動時に
検索 CLI/APIで describe-images
を利用
AWS Marketplace AWS上で実行されるソフトウェアやサービスを見つけて
購入しすぐに使用開始できるオンラインソフトウェアストア
多くのソフトウェアベンダー製品やOSSのソフトウェアがインストール済みOSイメージを公開中
有償ソフトウェアを従量課金で利用可能
VM Import / Export
21© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
AMI の利用
① 既存AMI から新規インスタンスを起動
② カスタムAMIを作成
③ カスタムAMIを使って、インスタンスを複数台起動
• 作成したAMIは別アカウントと共有可能
• 別リージョンへのコピーも可能
インスタンス
Amazon S3
AMI
Availability Zone-1a Availability Zone-1b
カスタムAMI①
②
③
22© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon EC2 インスタンスの起動
OS、アプリケーション、設定
AMI
スペック(CPU、メモリ)
インスタンスタイプ
AZ
VPC
リージョン
EBS EBS EBS EBS EBS EBS
AZ
インスタンス インスタンス
23© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
現行世代のインスタンス
インスタンスファミリー ユースケース
汎用 (t2、m4、m3) • 低トラフィックのウェブサイトとウェブアプリケーション
• 小規模~中規模のデータベース
コンピューティング最適化 (c4、c3) • 高性能なフロントエンド群• 動画エンコーディング
メモリ最適化 (r3) • 高性能データベース• 分散型メモリキャッシュ
ストレージ最適化 (i2、d2) • データウェアハウス• ログまたはデータ処理アプリケーション
GPU 最適化 (g2) • 3D アプリケーションストリーミング• 機械学習
24© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
インスタンスタイプの選択
C 3 . 8xlarge
①インスタンスファミリー
②世代 ③サイズ
C3インスタンスの例
用途に応じてインスタンスファミリーと世代を決めた後に、必要なサイズを決める
25© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
ユーザーデータの追加
インスタンス起動時に、ユーザーデータを指定可能
ユーザーデータの種類:
Linux スクリプト – cloud-init により実行される
Windows バッチまたは PowerShell スクリプト –EC2Config サービスによって実行される
デフォルトでは、ユーザーデータスクリプトはinstance-id ごとに 1 回実行される
26© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
ユーザーデータの例: Linux
#!/bin/sh
yum -y install httpd
chkconfig httpd on
/etc/init.d/httpd start
ユーザーデータのシェルスクリプトは #! の記号とスクリプトを読み取るインタープリタのパスが最初に付いている必要がある
Apache ウェブサーバーをインストールするウェブサーバーを有効にするウェブサーバーを起動する
27© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon EC2のストレージ
インスタンスストア
• ホストコンピュータに内蔵されたディスク
• 性能・容量はインスタンスタイプごとに規定
• 追加費用なし(無料)
注意:インスタンスの停止または削除でデータが破棄される
28© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon EC2のストレージ
Amazon Elastic Block Store (EBS)
• ネットワークで接続されたディスク• EC2とは独立管理• ボリュームごとに性能・容量を定義可能• EBSの費用が別途発生• Snapshotを取得しS3に保存可能
29© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
インスタンスのライフサイクル
起動したインスタンスは3つの状態を持つ
Running(実行中) : 課金される。停止処理で Stoppedへ遷移
Stopped(停止中) : 課金されない。開始処理で再度Runningへ遷移
Terminated(削除) : 課金されない。削除処理で遷移。もう開始はできない
AMI Running
Terminated
Stopped
開始停止
削除作成
削除[ユーザデータ]作成時に1度だけ
実行
30© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
概要Amazon
EC2
関連サービス負荷分散
Auto Scaling
運用モニタリング自動化
今日お話しする事 ~AWS Computing~
ベストプラクティス①
各リージョン内の複数のアベイラビリティーゾーンを使用し、高可用性を実現する
その他のHA 複数のサーバー
各アベイラビリティーゾーン内で分離された冗長データセンター
世界中を網羅するリージョン
耐障害性の高いサービス
32© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
マルチ AZ 構成
リージョン
AZ AZ
Log
Elastic LoadBalancing
33© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Elastic Load Balancing
34© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Elastic Load Balancing
複数のEC2インスタンスにトラフィックを分散
正常に動作していない EC2 インスタンスを検出して除去するためのヘルスチェックをサポート
複数のアベイラビリティゾーンに跨って、高レベルの耐障害性を実現
Elastic Load
Balancing
35© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
機能の説明
アベイラビリティーゾーン A アベイラビリティーゾーン B
ロードバランサー
X
36© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Elastic Load Balancing の例
アベイラビリティーゾーン A
アベイラビリティーゾーン B
EC2 インスタンスEC2 インスタンス
インターネット接続
ロードバランサー
EC2 インスタンスEC2 インスタンス
HTTPS
SSL ハンドラ/ロードバランサー
HTTPS トラフィック
アベイラビリティーゾーン B
アベイラビリティーゾーン A
アベイラビリティーゾーン B
EC2 インスタンスEC2 インスタンス
内部
ロードバランサー
プライベートサブネットプライベートサブネット
パブリックサブネット パブリックサブネット
EC2 インスタンス
EC2 インスタンス
アベイラビリティーゾーン A
37© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
ロードバランサーの種類
マネジメントコンソールのロードバランサ作成画面
ベストプラクティス②
スケーラビリティを確保する
クラウドベースのインフラストラクチャの大きなメリットの 1 つは、リソースの需要の変化に迅速に対応できること
40© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon.com の典型的な週間トラフィック
日曜日 月曜日 火曜日 水曜日 木曜日 金曜日 土曜日
用意したキャパシティー
41© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon.com の 11 月のトラフィック
用意したキャパシティー
11 月
76%
24%
課題は必要なコンピューティング容量を効率的に "予測する" こと
42© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Auto Scaling
43© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Auto Scaling
指定された条件に基づき、インスタンスを起動または終了する
使用量が変動するアプリケーションに最適
追加料金なしで使用可能Auto
Scaling
44© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Auto Scaling の動作
レイテンシー
使用率
CloudWatchAuto Scaling
Elastic Load
Balancing
Auto Scaling グループ
ポリシー実行
45© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Auto Scaling の設定
① 起動設定 を作成起動設定は Auto Scaling グループが EC2 インスタンスを起動するために使うテンプレート
起動設定作成時に指定する内容(例)
AMI ID
インスタンスタイプ
46© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Auto Scaling の設定
② Auto Scaling グループを作成起動設定に基づくEC2 インスタンスの集合
設定例
最小サイズ
最大サイズ
ロードバランサー
Auto Scaling グループ
最小サイズ
最大サイズ
必要に応じてスケールアウト
47© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Auto Scaling の設定
③ ポリシーを作成 (オプション)どのような条件でサーバを起動 / 削除するか - CloudWatch アラーム
Auto Scaling グループがスケールアウトするタイミング
Auto Scaling グループがスケールインするタイミング
48© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
スケールしなくても Auto Scaling
Auto Healingとして利用 最小および最大インスタンスをX台として設定すればX台の正常なインスタンスを維持できる
複数のEC2インスタンスをまとめて監視
min
max
Desired capacity
49© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
概要Amazon
EC2
関連サービス負荷分散
Auto Scaling
運用モニタリング自動化
今日お話しする事 ~AWS Computing~
50© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
モニタリング
51© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon CloudWatch
AWS クラウドリソースと AWS でお
客様が実行するアプリケーションのモ
ニタリングサービスAmazon CloudWatch
52© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon CloudWatch のアーキテクチャ
CloudWatch対応 AWS リソース
Amazon CloudWatch
Amazon CloudWatch アラーム
SNS E メール通知
Auto Scaling
利用できる統計
統計情報AWS マネジメントコンソール
CloudWatch メトリックス
CPUUtilization
StatusCheckFailed
独自のアプリケーション専用メトリックス
PageViewCount
53© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon CloudWatch メトリックス
サービスごとに定義された監視項目
標準のメトリックスを使った監視の多くは無償
Amazon EC2の標準メトリックスの間隔は5分
詳細モニタリング(1分間隔)も可能だが、追加課金が必要
メトリックスの値は最大15ヵ月保存される
54© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon CloudWatch アラーム
設定した期間・しきい値・回数により特定のアクションを呼びだす
55© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
サポートされている AWS のサービス
Auto Scaling
Amazon CloudFront
Amazon CloudWatch
Amazon CloudSearch
Amazon DynamoDB
Amazon EC2
Amazon ElastiCache
Amazon EBS
Elastic LoadBalancing
Amazon EMR
Amazon Kinesis Amazon EC2 Container Service
AWS OpsWorks
Amazon Redshift
Amazon RDS
Amazon Route 53
Amazon SNS
Amazon SQS
Amazon SWF
Amazon S3AWS Storage Gateway
Amazon WorkSpaces
Amazon Machine Learning
AWS Lambda AWS WAF
ベストプラクティス③
リソースのプロビジョニング、削除、および設定は可能な限り自動化する
手動作業の排除によってシステムの安定性と整合性を改善し、組織の効率を高める
AWSはAPIで操作可能!
57© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
自動化
58© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS CloudFormation
特徴 (http://aws.amazon.com/jp/cloudformation/)
◦テンプレートを元に、EC2やELBといったAWSリソースの環境構築を自動化
◦ JSON,yamlフォーマットで、テンプレートを自由に記述可能
◦ Microsoft Windows Server や SAP HANA などのリファレンス実装を用意(http://aws.amazon.com/quickstart/)
価格体系 (http://aws.amazon.com/jp/cloudformation/pricing/)
◦ 追加料金はありませんAWS リソース(Amazon EC2 インスタンスや Elastic Load Balancing ロードバランサーなど)に対してお支払いいただきます。
設定管理 & クラウドのオーケストレーション サービス
スタック
EC2
AutoScaling
テンプレート(設定ファイル)
テンプレートに基づき各リソースが自動起動
EC2
CloudFormation
59© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
ベストプラクティスサービス詳細
ソリューション事例業界別事例
などをもっと知りたい方
60© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Black Belt オンラインセミナー
AWSに関する様々な技術を紹介する無償オンラインセミナー
・開催日程(ほぼ毎週開催)
「AWS オンラインセミナースケジュール」で検索
・過去のセミナー動画・資料
「AWSクラウドサービス活用資料集」で検索
61© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
概要Amazon
EC2
関連サービス負荷分散
AutoScaling
運用モニタリング自動化
今日お話しした事 ~AWS Computing~
62© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2017 Amazon Web Services, Inc. or its affiliates. All rights reserved.
このトレーニング内容の全体または一部を複製または再配布することは、Amazon Web Services, Inc. の書面による事前の許可がある場合を除き、禁じられています。商業目的のコピー、貸与、または販売を禁止します。
エラーまたは修正がある場合、[email protected]
まで E メールを送信してください。その他の質問については、以下の URL からお問い合わせください。
https://aws.amazon.com/contact-us/aws-training/
すべての商標は各所有者に帰属します。