Contenu connexe
Similaire à [AWSマイスターシリーズ] AWS OpsWorks (20)
Plus de Amazon Web Services Japan (20)
[AWSマイスターシリーズ] AWS OpsWorks
- 1. re:G
ene
AWS マイスターシリーズ
rate
AWS OpsWorks
アマゾン データサービス ジャパン株式会社
プリンシパル ソリューションアーキテクト
荒⽊木 靖宏
ソリューションアーキテクト
⾈舟崎 健治
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 4. Introduction
“Most IT organizations still install and maintain computers the same
way the automotive industry built cars in the early 1900's: An
individual craftsman manually manipulates a machine into being, and
manually maintains it afterward.”
(訳)ほとんどのITの組織は未だ1900年年代初期に⾃自動⾞車車業界が⾞車車を
作っていた⽅方法と同じ⽅方式:個々の職⼈人が⼿手動でマシンを操作して
維持する⽅方式でコンピュータをインストール・維持している。
引用
Steve Traugott, Sterling Software, NASA Ames Research Center
http://www.infrastructures.org/bootstrap/ALL.shtml
4
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 5. Infrastructure as Codeの時代
! 今まで
手順書
手動でインストール・
更新
・人的作業の増大
・更新頻度少ない、1回のみ
ビジネス変化への対応が遅い
! Infrastructure as Code
コードリポジトリ
インフラ構築手順
をコーディング
自動インストール・
更新
・人的作業の縮小
・更新頻度を多くすることができる
ビジネス変化への対応が速い!
5
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 6. Chefの利利⽤用広がってます!
Right Scale State of 2013 industry surveyより引用
http://www.rightscale.com/blog/cloud-industry-insights/rightscale-statecloud-2013-look-ahead
6
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 7. OpsWorksとは?
! アプリケーションをAWS上で管理理するための
DevOpsソリューション
• Chef-‐‑‒Solo(Chefのスタンドアローン版)を採⽤用
• 幅広いアプリケーションアーキテクチャをサポート
• 追加コストなし
7
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 8. OpsWorks利利⽤用に最適なシステムとは?
! 良良い例例
! 悪い例例(現時点の)
• ソーシャル・ブラウザ向けゲー
ム
• SaaSプロバイダー
• Eコマース
• ロケーションベースサービス
• 基本的なWebやモバイルアプリ
• 商⽤用エンタープライズアプリ
ケーション
• スクリプトでパッケージイ
ンストールできない場合
• ソースコードリポジトリと本
番環境が通信できない場合
8
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 11. Chefのメリット
! サーバの構成管理理をプログラミング可能
! 何度度Recipeを実⾏行行しても同じ結果になる
! OSなどの環境の差異異を吸収してくれる
11
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 12. Chefレシピの例例
! Rubyベース
# haproxy パッケージインストール
case node[:platform]
when 'ubuntu'
package 'haproxy' do
action :install
end
end
12
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 13. レシピ + ⾃自動化
Eric Joyner
ericjoyner.com
13
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 20. OpsWorksの動作要件
! AMIをカスタマイズ可能
• Amazon LinuxまたはUbuntu 12.04LTSベース
! Chefバージョン9,11に対応
! VPC対応
• デフォルトVPC, ⾃自作VPC共に利利⽤用可能
! ELB対応
! 起動したインスタンスからOpsWorksサービスエンドポ
イントへ通信可能であること
20
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 21. OpsWorksの利利⽤用⽅方法
! AWSマネージメントコンソール
! AWS CLI
• OpsWorksのEndPointはus-‐‑‒east-‐‑‒1のみ(サービス⾃自体は他リージョ
ンでも利利⽤用可能)
https://opsworks.us-‐‑‒east-‐‑‒1.amazonaws.com
$ aws opsworks describe-stacks
! AWS SDK for Java / .NET / PHP / Python / Ruby
21
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 24. ⽤用語説明:スタックとは?
! OpsWorksのトップエンティティ
! 属する全インスタンスの構成を管理理
• 例例:DBサーバをアプリケーションサーバの
バックエンドデータストアとして認識識させる
! カスタムレシピを保存する任意のリポジト
リを指定可能
! スタックをコピー可能
• リージョン間でも可能
24
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 26. ⽤用語説明:インスタンスとは?
! アプリケーションを提供するためのEC2
インスタンスのこと
! 起動時にインスタンスサイズや
AZ(VPC内の場合はサブネット)を指
定
26
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 27. ⽤用語説明:Appとは?
! アプリケーションサーバにデプロイ
される
! 利利⽤用可能なアプリケーションサーバ
• Ruby on Rails / PHP /
Node.js(JavaScript) / Static(HTML) /
Other(Javaなど)
! サポートするリポジトリ
• Git / Subversion / HTTP archive / S3
Archive / Other
27
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 29. リソースプロビジョニング
! スケーリングタイプごとに異異なる⽅方式でインスタンス起
動可能
• 24/7 インスタンス
• ⼿手動で起動・終了了
• 負荷ベースのインスタンス
• 時間ベースのインスタンス
29
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 30. リソースプロビジョニング
! Auto Healing
• 起動されたインスタンス上ではagentがOpsWorksへpollingし
ている。
• レイヤーでAuto Healingが有効になっている場合
• レイヤーの1つのインスタンスが、およそ3-‐‑‒5分間接続できない場
合に、OpsWorksは新規インスタンスを⽴立立ち上げる
古いインスタンス
Elastic IP
Elastic IP
agent
agent
30
新規インスタンス
・EIP利用時は同じEIPをアタッ
チ
・外付けEBS利用時は同じEBS
を同じマウントポイントで利用
Volume
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 31. 構成管理理
! スタックの構成情報の例例→
(JSON形式)
"opsworks": {
"layers": {
"php-app": {
"id": "4a2a56c8-f909-4b39-81f8-556536d20648",
"instances": {
"php-app2": {
"elastic_ip": null,
"region": "us-west-2",
"booted_at": "2013-02-26T20:41:10+00:00",
"ip": "192.112.235.192",
"aws_instance_id": "i-34037f06",
"availability_zone": "us-west-2a",
"instance_type": "c1.medium",
"private_dns_name": "ip-10-252-0-203.us-west-2.com
"private_ip": "10.252.0.203",
"created_at": "2013-02-26T20:39:39+00:00",
"status": "online",
"backends": 8,
$ opsworks-agent-cli get-json
"public_dns_name": "ec2-192-112-235-192.uswest-2.compute.amazonaws.com"
},
"php-app1": {
...
}
},
"name": "PHP Application Server"
},
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
"lb": {
! ライフサイクルコマンドが
実⾏行行されると、そのインス
タンスに送られる。
! 下記コマンドでも取得可能
31
{
- 32. アプリケーションデプロイ
! ライフサイクルイベントのデプロイにより実⾏行行
! ⼿手動デプロイも可能
! アプリケーションリポジトリに以下も利利⽤用可能
• プライベートネットワーク内にあるリポジトリ
• SSH key認証が必要なプライベートリポジトリ
• 例例
– GitHub Enterprise
• SSH認証でのパスワードは利利⽤用不不可
32
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 33. ソフトウェアアップデート
! ライフサイクルイベントによるアップデート
• Setup / Configure / Deploy
! 個別にコマンドを実⾏行行することによるアップデートも可能
• Install Dependencies
• 全てのパッケージまたはRuby gemsをインストール
• Update Dependencies
• 全てのパッケージまたはRuby gemsをアップデート
• Update Cookbooks
• アップデートされたcookbookを
それぞれのインスタンスのキャッシュに
デプロイ
• Execute Recipes
• 指定したレシピを実⾏行行
33
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 34. 監視
! CloudWatchメトリクスを利利⽤用可能
• CPU / Memory / Load / Processes
レイヤー単体
インスタンス単体
スタック全体
34
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 35. アクセスコントロール
! AWS OpsWorksが必要とする権限を
スタック作成時に割り当てる
! OpsWorksを利利⽤用する上で不不⾃自由な
く使う場合は以下のポリシーを活⽤用
{
"Version": "2012-10-17",
"Statement": [ {
"Effect": "Allow",
"Action": [ "ec2:*", "s3:*", "opsworks:*", "iam:PassRole"],
"Resource": "*"
}
]
}
35
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 37. OpsWorksの構成例例(1)
Stack
HAProxy Layer
Github
Recipe & App
Repository
PHP App Server Layer
PHP
PHP
App
PHP
PHP
App
掲示板アプリ
MySQL Layer
Ganglia Layer
監視
37
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 38. OpsWorksの構成例例(2)
! VPC内に構築
• OpsWorksにより起動された
インスタンスはOpsWorks
サービスエンドポイントと接
続が必須
(Privateサブネット利利⽤用時は
NAT必須)
• プライベートサブネット内の
コードリポジトリを利利⽤用可能
PHP App Server
レイヤー
Internet
Gateway
NAT
VPC Public Subnet
Github
Recipe
Repository
MySQL DB レイヤー
• 同じレイヤーのインスタンス
を異異なるサブネットに配置可
能
App Code
Repository
VPC Private Subnet
Virtual Private Cloud
38
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 40. Language Cloud様
! サービス概要
•
!
成績表、宿題管理理、授業計画(シラバス)等の外
国語教師向けの管理理と分析プラットフォーム
OpsWorksを採⽤用した理理由
•
•
•
•
元々AWSを利利⽤用していた為、EC2との連携が必須
Continuous Integrationシステム(Jenkins)と
の連携が可能
コミュニティのクックブック(例例:statsd)を利利
⽤用可能
⾃自分でchefサーバー等を運⽤用するより楽
“node.jsや静的Webサーバの構成管理理にAWS OpsWorksを活⽤用す
ることで開発効率率率が⼤大幅に向上、スタックのバージョン管理理をシンプ
ルなUIで管理理ができるのは本当に気に⼊入っています”(英訳)
Language Cloud Co-‐‑‒founder, Franky Chung様
40
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 41. WorkFu様
! サービスの概要
• 仕事およびタレントを⾒見見つけるためのサービス
! 複数のレイヤーを活⽤用
•
•
•
•
•
•
•
HAProxy
PHP App Server
MySQL
Memcached
Que Worker
RabbitMQ
Sphinx
! 1⽇日に複数回デプロイを実施
41
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 43. OpsWorksトラブルシューティング
! カスタムレシピ実⾏行行時のログファイル
• /var/lib/aws/opsworks/chefにChefのログ
• /var/log/aws/opsworksにOpsWorksのログ
! SSHでインスタンスに接続して、agent CLIの
run_̲commandでレシピを試すと即座に結果が分かる
43
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 45. まとめ
! OpsWorksを使って、さまざまなタイプのアプリケー
ションをデプロイ、アップデート、構成管理理することが
可能
! Chefのレシピを使って、インスタンスにログインするこ
となく構築可能
! VPC利利⽤用などさまざまな構成に対応可能
新しいDevOpsソリューションを
是非ご活用ください!
45
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 46. Links
! OpsWorks User Guide
• http://docs.aws.amazon.com/opsworks/latest/userguide/
welcome.html
! OpsWorksよくある質問
• http://aws.amazon.com/jp/opsworks/faqs/
! <AWS OpsWorksを使ってみた(概要編)>
• http://tech-‐‑‒sketch.jp/2013/08/aws-‐‑‒opsworks.html
! <AWS OpsWorksを使ってみた(技術編)>
• http://tech-‐‑‒sketch.jp/2013/08/aws-‐‑‒opsworks-‐‑‒1.html
46
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 47. APPENDIX
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 48. Chef-‐‑‒Soloによるhttpdインストール(1)
! 1. Chef-‐‑‒Soloインストール
$ curl -L http://www.opscode.com/chef/install.sh | sudo bash
! 2. Cookbook作成
$ knife cookbook create apache -o cookbooks
! 3. Chef-‐‑‒Solo設定ファイル2つ作成
$ cat > solo.rb
file_cache_path "/tmp/chef-solo"
cookbook_path ["/home/ec2-user/cookbooks"]
48
$ cat > localhost.json
{
"run_list" : [
"recipe[apache]"
]
}
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 49. Chef-‐‑‒Soloによるhttpdインストール(2)
! 4. レシピ作成・編集
$ cat > ./cookbooks/apache/recipes/default.rb
package “httpd" do
action :install
end
! 5. Chef-‐‑‒Soloを実⾏行行してパッケージインストール
$ sudo chef-solo -c solo.rb -j ./localhost.json
49
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 50. App ServerからRDSへ接続
! Stackの設定でRDSへの接続情報を追加
! 詳細
http://docs.aws.amazon.com/opsworks/latest/
userguide/customizing-‐‑‒rds.html
50
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 52. AWS Management Consoleに
ログイン
1. http://aws.amazon.com/jp/consoleへアクセス
2. サインアップ
3. OpsWorksを選択
52
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 53. Stackの作成
53
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 54. Stackの作成
54
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 55. PHP App Server Layerの作成
55
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 56. PHP App Server Layerの追加
56
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 57. PHP App Server LayerへInstanceを追
加
57
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 58. PHP App Server Layerへ
Instanceを追加
58
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 59. PHP App Server Layerへ
Instanceを追加
59
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 60. PHP App Server Layerの
Instanceを起動
60
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 61. PHP App Server Layerの
Instanceを起動
61
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 62. Appの作成
! NavigationパネルのAppsを選択
62
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 64. Appのデプロイ
64
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 66. Appのデプロイ完了了、ログ表⽰示
66
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 67. ログ表⽰示
67
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 68. Appのデプロイの確認
! NavigationパネルのInstanceを選択
68
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
- 69. Appのデプロイの確認
69
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.