書籍『Amazon Web Services クラウドデザインパターン 実装ガイド』写経・実践メモ - 1章 Amazon EC2の基本操作



主に以下の書籍について、"実践編"のタイトル通り実際に読み進め、環境構築を行なっていった過程でのメモ書き等を後学の為にもエントリとしてUPする事にする。
Amazon Web Services クラウドデザインパターン実装ガイド

Amazon Web Services クラウドデザインパターン実装ガイド

なお、以下の書籍も時折参照。

Amazon Web Services クラウドデザインパターン 設計ガイド

Amazon Web Services クラウドデザインパターン 設計ガイド

Amazon Web Servicesプログラミング ―APIの基礎からElastic Beanstalkの利用まで

Amazon Web Servicesプログラミング ―APIの基礎からElastic Beanstalkの利用まで


1章 Amazon EC2の基本操作

  • アカウント作成の件は割愛。大分昔の話ですし(´・ω・`)w
  • DNS周りのそれぞれの用語について
    • Public DNS
      • グローバルなホスト名、インターネットから接続可能。
      • 動的ホスト名なのでインスタンス停止後に起動すると値は変わる。
    • Elastic IP
    • Private DNS
  • EC2起動:SSHログイン(from Mac)〜Apache導入〜Webページ確認
-KeiPair作成(ec2-demo-key.pem)
$ chmod 600 ec2-demo-key.pem
$ ssh -i ec2-demo-key.pem ec2-user@(EC2インスタンス作成時のPublic DNS)
$ sudo yum install -y httpd
$ sudo service httpd start
$ (EC2インスタンス作成時のPublic DNS) にブラウザアクセス、apacheページ表示確認完了。
  • Elastic IP アドレス取得→割当(associate)。
  • 再度SSHIPアドレス指定でアクセス試みる。
  • 怒られる。known_hostsファイルの整合性の問題なので、上記操作時に追加された該当ファイル該当行を削除して再挑戦。
$ ssh -i ec2-demo-key.pem ec2-user@(Elastic IP)
Warning: Identity file ec2-demo-key.pem not accessible: No such file or directory.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Please contact your system administrator.
Add correct host key in /Xxxx/xxxxxxxx/.ssh/known_hosts to get rid of this message.
Offending key in /Xxxx/xxxxxxxx/.ssh/known_hosts:3
RSA host key for (Elastic IP) has changed and you have requested strict checking.
Host key verification failed.
$ 
$ ssh -i ec2-demo-key.pem ec2-user@(Elastic IP)
The authenticity of host '(Elastic IP) ((Elastic IP))' can't be established.
RSA key fingerprint is XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '(Elastic IP)' (RSA) to the list of known hosts.
Last login: Sat Mar  9 07:40:22 2013 from XXXXXXXXXXXXXXXXXXXX.

       __|  __|_  )
       _|  (     /   Amazon Linux AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-ami/2012.09-release-notes/
There are 10 security update(s) out of 15 total update(s) available
Run "sudo yum update" to apply all updates.
$