Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アマゾン ウェブ サービス ジャパン株式会社ソリューションアーキテクト⼩川 貴⼠2020年5⽉21⽇
Amazon EC2 を始めるのに必要な 10 のこと
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アジェンダ• 本セッションの⽬的• Amazon EC2 を始めるのに必要な10のこと
1. Amazon EC2とは2. EC2を配置する場所3. インスタンスタイプ4. OSイメージ5. EC2のネットワークについて6. ストレージ7. EC2のセキュリティー8. EC2の管理9. EC2へのアクセス⽅法10.EC2の料⾦
• まとめ
2
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
本セッションの⽬的
対象者• これからAmazon EC2を利⽤しようとしている⽅• Amazon EC2を使ったシステムを提案するシステムインテグレータの⽅• AWS全般に興味がある⽅
⽬的• Amazon EC2を起動するのに最低限知っておくべき10のことをクイックに知る
本セッションではEC2の初⼼者向けに最低限知って頂きたい事柄について説明します。EC2のより詳細について知りたい⽅は、EC2のドキュメントならびに下記BlackBeltの資料を参照ください。
https://www.slideshare.net/AmazonWebServicesJapan/20190305-aws-black-belt-online-seminar-amazon-ec2
3
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
1. Amazon EC2 とは
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon EC2とは• 数分で起動して、1時間または秒単位の
従量課⾦で利⽤可能なAWSクラウド上の仮想サーバー (インスタンスによってはベアメタルサーバも選択可)
• サーバーの追加・削除、マシンスペック変更も数分で可能
• 払い出されたサーバー内のOSは管理者権限(root/Administrator) にて操作可能
Host ServerHypervisor
Guest 1 Guest 2 Guest nEC2インスタンス
4vCPU/16GBメモリ搭載したLinuxのサーバーが使いたいなー
⽤意できましたー︕
5
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
2. Amazon EC2を配置する場所(リージョンとAZ)
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EC2を利⽤できるAWSのデータセンター拠点
AZ
AZ
AZ AZ AZ
Transit
Transit
東京など 24 の地理的リーション 76 のアベイラビリティーゾーン(AZ)で運⽤• EC2は任意のリージョンならびに
アベイラビリティーゾーンを選択して起動することができる
• リージョンによって選択できるインスタンスの種類ならびに価格が異なる
https://aws.amazon.com/jp/about-aws/global-infrastructure/アベイラビリティーゾーン(AZ)概念図
7
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
3. インスタンスタイプ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon EC2 インスタンスタイプ
汎⽤ コンピューティング最適化
ストレージ最適化
⾼速コンピューティング
(GPU・FPGA)メモリ最適化
さまざまなユースケースにマッチするように、メモリ・I/O・CPUクロック重視、GPU・FPGA搭載などの特徴を持つ⼤きく5つのカテゴリに分類されるインスタンスファミリーを提供
F
P GMH
D
C X
ZA
IR
High Memory
T
Inf
9
EC2インスタンスタイプは下記のようなネーミングルールで構成されており、各インスタンスファミリーから⽤途に合ったスペックのインスタンスタイプを選択して利⽤する
インスタンス世代c5d.xlarge
インスタンスファミリー
インスタンスサイズ
(オプション)
最新のEC2インスタンスの⼀覧はWebを参照→ https://aws.amazon.com/jp/ec2/instance-types/
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
M
Z
A
I
T C
P
HighMemory
D HF G
R X
<参考>迷ったら汎⽤”M”を基準に重視するリソースから選択する
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
4. OSイメージ (AMI)
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AMI (Amazon Machine Image) とは
• 予めRedHat,SUSE,UbuntuなどのLinuxやWindows ServerのOSイメージが提供されており、選択してインスタンスを起動する
• AWS以外にサードパーティもAMIを提供(AWS Marketplace)
• ⼀般提供のAMIから起動したOSにアプリケーションを追加した上で再びAMI化するなど、⾃前のカスタムAMIを作成することも可能
12
AWS Cloud
インスタンス
Amazon S3
AMI カスタムAMI
AMIからインスタンスを起動
カスタムAMIを使って、インスタンスを
複数台起動
カスタムAMIを作成必要に応じて共有設定
Availability zone – 1a Availability zone – 1b
AMIとはEC2インスタンスの起動に使⽤するOSイメージ
AMIは内部的にS3(AWSのオブジェクトストレー
ジサービス)に格納
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AMIの分類アーキテクチャ
• x86 とArmビット数
• 32bit と64bit仮想化⽅式
• 準仮想化 ( Paravirtual : PV)• 完全仮想化 (Hardware-assisted VM : HVM)
ブートストレージ• EBS Backed • Instance Store-Backed (S3 Backed)
同じOSでも、上記種類で複数のパターンが存在⼀般的な推奨は 64bit HVM EBS-Backed
32bit
64bit
PV HVM
S3 BackedEBS Backed
PVは古い形式の為、利⽤は推奨されません
13
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
5. EC2のネットワークについて
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EC2におけるIPアドレスの種類Private IP
• 必ず割り当てられるIPアドレス• EC2作成時にIPを指定可能(VPCのみ)• Stop/StartしてもIPは変わらず固定(VPCのみ)
Public IP• ランダムに割り当てられるPublic IP• Stop/Startすると別のIPが割当てられる• 割当ての有無を変更することも可能(VPCのみ)
Elastic IP (EIP)• 別インスタンスへ再マップも可能な静的Public IP• Stop/StartしてもIPアドレスが維持される(VPCのみ)• 利⽤していない場合は課⾦発⽣
− Public IP またはElastic IP
− Private IP
EC2
より詳細はEC2のドキュメントを参照http://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/using-instance-addressing.html15
AWS Cloud
VPC
Subnet
デフォルト状態(デフォルトVPC上でデフォルトEC2設定)でEC2を起動するとPrivate IPとPublic IPがそれぞれ1つ付与される
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
6. ストレージ(EBSとインスタンスストア)
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EC2のストレージ 1、Amazon EC2 インスタンスストア• ホストコンピュータに内蔵されたディスク• EC2インスタンスと不可分• EC2インスタンスをStop/Terminateすると
クリアされる• 性能・容量はインスタンスタイプごとに規定• 追加費⽤なし(無料)
2、Amazon Elastic Block Store (EBS)• ネットワークで接続• EC2インスタンスとは独⽴管理• EC2インスタンスをStop/Terminateしても
EBSは保持可能• Volumeごとに性能・容量を定義可能• EBSの費⽤が別途発⽣• Snapshotを取得しS3に保存可能
http://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/Storage.html
Amazon EBS
EBS Snapshot
gp2 io1
st1 sc1
SSD volumes
HDD volumes
Amazon S3
Instance Store
SSD HDD
17
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
7. EC2のセキュリティー(セキュリティーグループとキーペア)
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Security Group
EC2 インスタンス
ポート22(SSH)
ポート80(HTTP)
EC2ファイアウォール
Security Group
ポート25(SMTP)
19
EC2へリモートログインする為には、Linuxの場合SSHポート(TCP/22番) 、Windowsの場合はRDP(TCP/3389番)の受信を許可します
EC2インスタンスへのトラフィックを制限するファイアウォール機能
• EC2インスタンスあたり必ず1つは定義する必要がある
• デフォルトでは全トラフィックが閉じた状態
• 必要な受信アクセスに対してアクセスルールを定義する
• プロトコル( TCP/UDP)• 宛先ポート• アクセス元IP / Security Group
• ルールをひとまとめにしたテンプレートをSecurity Groupと呼ぶ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Key Pair
EC2インスタンス上のOSに対する安全な認証を提供する機能
• 鍵認証は、ユーザ名・パスワードの認証よりも安全な認証⽅式
• AWSでは公開鍵のみ保持し、起動時に公開鍵をコピーする
• 秘密鍵は、ユーザにて適切に管理・保管する
秘密鍵=⼿元のPCに保管
①キーペア作成
②インスタンス起動時に公開鍵をコピー
③公開鍵・秘密鍵のペアが合致するとログイン可能
20
公開鍵=AWS側で保管
EC2インスタンスがLinuxの場合はキーペアを使⽤してsshキーファイル認証(パスフレーズ無し)、Windowsの場合はキーファイルを元にパスワード⽣成を⾏い、OSに対するログイン認証を⾏う
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
8. EC2の管理
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
インスタンスのライフサイクル
起動したインスタンスは下記の状態を持つRunning
• 実⾏中。課⾦される• Stop操作でStoppedへ、Terminate操作
でTerminatedに遷移Stopped
• 停⽌中。課⾦されない• Start操作で再度Running状態に遷移
Terminated• 削除済み。課⾦されない• Stop/Startはできない
Running
Terminated
Stopped
StartStop
Terminatelaunch
Terminate
AmazonMachineImage (AMI)
Amazon EC2インスタンス
より詳細は下記ドキュメント参照http://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/ec2-instance-lifecycle.html
22
補⾜︓Instance Store-Backed AMIを使⽤した場合はStopped状態に遷移できません
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon CloudWatchによるモニタリング
各AWSサービスのメトリックス監視• メトリックス = 監視項⽬(例︓CPU使⽤率)• メトリックスはあらかじめ定義され、構成済み
• サービス開始時から監視開始• EC2ではハイパーバイザーから監視できる項⽬
• メトリックスを追加定義も可能• カスタムメトリックス
• メトリックス値を時系列にグラフ表⽰
各メトリックスに対してアラームを作成可能• しきい値を設定(例︓CPU使⽤率60%以上)• メトリックス値がしきい値を越えたら起こすアクションを定義(例︓メールで通知)
EC2上のログ監視 ・・・Amazon CloudWatch Logs• メトリックスとアラームも作成可能
詳細はAmazon CloudWatchのBlackBelt資料を参照くださいhttps://www.slideshare.net/AmazonWebServicesJapan/black-belt-online-seminar-amazon-cloudwatch23
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
9. EC2へのアクセス⽅法
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EC2インスタンスへのリモートログインEC2インスタンスのOSにログインするには⼿元の端末からリモートログインする
※EC2のアドレス情報はEC2のコンソールから確認できます
EC2Linux
AWS Cloud
VPC
Subnet
EC2Windows
Internet gateway
SSH接続
RDP接続
EC2インスタンスのOSがLinuxの場合• sshを使⽤してEC2のアドレスにアクセス• 管理ユーザ名+キーペア(秘密鍵)で認証
(ec2-user,ubuntu,centosなどディストリビューションによって異なる)
EC2インスタンスのOSがWindowsの場合• コンソールからキーペア(秘密鍵)を使⽤
してパスワード⽣成• リモートデスクトップ(RDP)を使⽤して
EC2のアドレスにアクセス• 管理ユーザ名(Administrator)+⽣成された
パスワードで認証
25
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
<参考>セッションマネージャーを使⽤したEC2へのログイン
SSM Agent
SSM Agent経由でサーバ上のシェルにアクセス
SSM セッションマネージャー
IAM認証/認可
ブラウザAWS CLI
操作履歴
CloudWatch LogsS3 Bucket
接続履歴
CloudTrailセッションマネージャー
接続履歴
AWS Systems Managerのセッションマネージャを使⽤することで、AWSの管理コンソール(ブラウザ)やAWS CLIから、EC2のターミナルにログインすることも可能
(キーペアは不要)
(sshならびにRDPポートの開放不要)
26詳細はAWS Systems ManagerのBlackBelt資料を参照ください
https://www.slideshare.net/AmazonWebServicesJapan/20200212-aws-black-belt-online-seminar-aws-systems-manager
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
10. EC2の料⾦
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EC2の課⾦の内訳
データ転送量(out)
インスタンスタイプ別利⽤料
EBSの利⽤料
AMI/スナップショットの保管料
EC2はインスタンス利⽤料の他、ストレージ利⽤料、データ転送料が主に掛る
例) 汎⽤SSD使⽤料: $0.12/GB/⽉
例) S3に対するsnapshot: $0.05/GB/⽉
例) EC2からインターネットへの通信料: $0.114/GB
例) m5.large(Linux)使⽤料: $0.124/時間
※いづれも東京リージョンでの価格例
28
インターネット
EC2
EBS
S3
料⾦表での単価は時間や⽉あたりの料⾦表⽰であるが、課⾦は秒単位で⾏われる (ただし有償AMI利⽤時は時間単位の課⾦)EC2料⾦情報 → https://aws.amazon.com/jp/ec2/pricing/
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
<参考>EC2 購⼊オプション
オンデマンドインスタンス使⽤した分の⽀払い (秒単位/時間単位)。
Amazon EC2のデフォルトの購⼊形式(定価)
スパイクするようなワークロード
Savings Plans リザーブドインスタンス スポットインスタンス
Amazon EC2の空きキャパシティを活⽤し、最⼤90%割引。
ただし中断が発⽣することがある
中断に強く、かつ様々なインスタンスタイプを活⽤できる
ワークロード
利⽤計画に合わせたプランを選択することで、EC2に掛かるコストを最適化することができる
1年/3年の⻑期コミットをする代わりに⼤幅なディスカウント価格
⼀定の負荷の⾒通しがあるワークロード
29
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
まとめ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
まとめAmazon EC2 を始めるのに必要な10のこと
1.Amazon EC2とは2.EC2を配置する場所3.インスタンスタイプ4.OSイメージ5.EC2のネットワークについて6.ストレージ7.EC2のセキュリティー8.EC2の管理9.EC2へのアクセス⽅法10.EC2の料⾦
31
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank You !