Suche senden
Hochladen
オリジナルAMIの作成(CentOS)
•
2 gefällt mir
•
1,076 views
Hiroyasu Suzuki
Folgen
Melden
Teilen
Melden
Teilen
1 von 16
Jetzt herunterladen
Downloaden Sie, um offline zu lesen
Empfohlen
Puppet入门
Puppet入门
huangmingyou
whatsoever, hardening linux webserver in 60 minutes
whatsoever, hardening linux webserver in 60 minutes
idsecconf
Fundamental know-how of Linux tech
Fundamental know-how of Linux tech
Michael Huai
Banquet 09
Banquet 09
Koubei UED
Вебинар Томулевича materialized.path 2
Вебинар Томулевича materialized.path 2
Media Gorod
JAWS-UGコンテナ支部#2「EC2」から「ECS」へ
JAWS-UGコンテナ支部#2「EC2」から「ECS」へ
Hiroyasu Suzuki
AWStatsでS3&CloudFrontのアクセス解析
AWStatsでS3&CloudFrontのアクセス解析
Hiroyasu Suzuki
VIOPS09 AWSで実現するクラウドと物理製品の融合
VIOPS09 AWSで実現するクラウドと物理製品の融合
Hiroyasu Suzuki
Empfohlen
Puppet入门
Puppet入门
huangmingyou
whatsoever, hardening linux webserver in 60 minutes
whatsoever, hardening linux webserver in 60 minutes
idsecconf
Fundamental know-how of Linux tech
Fundamental know-how of Linux tech
Michael Huai
Banquet 09
Banquet 09
Koubei UED
Вебинар Томулевича materialized.path 2
Вебинар Томулевича materialized.path 2
Media Gorod
JAWS-UGコンテナ支部#2「EC2」から「ECS」へ
JAWS-UGコンテナ支部#2「EC2」から「ECS」へ
Hiroyasu Suzuki
AWStatsでS3&CloudFrontのアクセス解析
AWStatsでS3&CloudFrontのアクセス解析
Hiroyasu Suzuki
VIOPS09 AWSで実現するクラウドと物理製品の融合
VIOPS09 AWSで実現するクラウドと物理製品の融合
Hiroyasu Suzuki
Avoid Fraud -- and Secure the Life You Want
Avoid Fraud -- and Secure the Life You Want
Brian Weatherdon
Life Horizons -- Money Can Serve the Life You Want
Life Horizons -- Money Can Serve the Life You Want
Brian Weatherdon
Retirement lifestyles -- Money Can Serve the Life You Want
Retirement lifestyles -- Money Can Serve the Life You Want
Brian Weatherdon
Pension platforms for Life Income -- Feb2012
Pension platforms for Life Income -- Feb2012
Brian Weatherdon
A lifetime of wealth - and how not to lose it
A lifetime of wealth - and how not to lose it
Brian Weatherdon
雲(AWS)に願いを!
雲(AWS)に願いを!
Hiroyasu Suzuki
Vyatta AWS
Vyatta AWS
Hiroyasu Suzuki
Browser Uploads to S3 using HTML POST Forms
Browser Uploads to S3 using HTML POST Forms
Hiroyasu Suzuki
Routine and time expressions -exercises
Routine and time expressions -exercises
Henrique Semeghini
CDP キャンペーンサイト編 UPDATE
CDP キャンペーンサイト編 UPDATE
Hiroyasu Suzuki
Lecture 'Service Offering - From Service Specifying to Service Cataloguing' V...
Lecture 'Service Offering - From Service Specifying to Service Cataloguing' V...
Paul G. Huppertz
Servicialisation - From Service Identifying to Service Billing V01.02.00
Servicialisation - From Service Identifying to Service Billing V01.02.00
Paul G. Huppertz
AWS+が提供する運用・保守サービス
AWS+が提供する運用・保守サービス
Hiroyasu Suzuki
Servicialisation - Service Specifying: Example E-mailing Service V01.05.00
Servicialisation - Service Specifying: Example E-mailing Service V01.05.00
Paul G. Huppertz
Lecture 'Servicialisation - Service Consumers Center Stage' 2012-05-24 V01.02.00
Lecture 'Servicialisation - Service Consumers Center Stage' 2012-05-24 V01.02.00
Paul G. Huppertz
Routine part 1a
Routine part 1a
Henrique Semeghini
Uso de la Programación para la Seguridad en Redes (a.k.a. Sockets y Shellcoding)
Uso de la Programación para la Seguridad en Redes (a.k.a. Sockets y Shellcoding)
Pedro Valera
Unix training
Unix training
qywang1983
FISL11 2010 - Automação de Datacenters
FISL11 2010 - Automação de Datacenters
iG - Internet Group do Brasil S/A
Selinux twnic 201008-sa
Selinux twnic 201008-sa
CYJ
Symfony2 en pièces détachées
Symfony2 en pièces détachées
Hugo Hamon
我的Kissy学习笔记
我的Kissy学习笔记
satans17
Weitere ähnliche Inhalte
Andere mochten auch
Avoid Fraud -- and Secure the Life You Want
Avoid Fraud -- and Secure the Life You Want
Brian Weatherdon
Life Horizons -- Money Can Serve the Life You Want
Life Horizons -- Money Can Serve the Life You Want
Brian Weatherdon
Retirement lifestyles -- Money Can Serve the Life You Want
Retirement lifestyles -- Money Can Serve the Life You Want
Brian Weatherdon
Pension platforms for Life Income -- Feb2012
Pension platforms for Life Income -- Feb2012
Brian Weatherdon
A lifetime of wealth - and how not to lose it
A lifetime of wealth - and how not to lose it
Brian Weatherdon
雲(AWS)に願いを!
雲(AWS)に願いを!
Hiroyasu Suzuki
Vyatta AWS
Vyatta AWS
Hiroyasu Suzuki
Browser Uploads to S3 using HTML POST Forms
Browser Uploads to S3 using HTML POST Forms
Hiroyasu Suzuki
Routine and time expressions -exercises
Routine and time expressions -exercises
Henrique Semeghini
CDP キャンペーンサイト編 UPDATE
CDP キャンペーンサイト編 UPDATE
Hiroyasu Suzuki
Lecture 'Service Offering - From Service Specifying to Service Cataloguing' V...
Lecture 'Service Offering - From Service Specifying to Service Cataloguing' V...
Paul G. Huppertz
Servicialisation - From Service Identifying to Service Billing V01.02.00
Servicialisation - From Service Identifying to Service Billing V01.02.00
Paul G. Huppertz
AWS+が提供する運用・保守サービス
AWS+が提供する運用・保守サービス
Hiroyasu Suzuki
Servicialisation - Service Specifying: Example E-mailing Service V01.05.00
Servicialisation - Service Specifying: Example E-mailing Service V01.05.00
Paul G. Huppertz
Lecture 'Servicialisation - Service Consumers Center Stage' 2012-05-24 V01.02.00
Lecture 'Servicialisation - Service Consumers Center Stage' 2012-05-24 V01.02.00
Paul G. Huppertz
Routine part 1a
Routine part 1a
Henrique Semeghini
Andere mochten auch
(16)
Avoid Fraud -- and Secure the Life You Want
Avoid Fraud -- and Secure the Life You Want
Life Horizons -- Money Can Serve the Life You Want
Life Horizons -- Money Can Serve the Life You Want
Retirement lifestyles -- Money Can Serve the Life You Want
Retirement lifestyles -- Money Can Serve the Life You Want
Pension platforms for Life Income -- Feb2012
Pension platforms for Life Income -- Feb2012
A lifetime of wealth - and how not to lose it
A lifetime of wealth - and how not to lose it
雲(AWS)に願いを!
雲(AWS)に願いを!
Vyatta AWS
Vyatta AWS
Browser Uploads to S3 using HTML POST Forms
Browser Uploads to S3 using HTML POST Forms
Routine and time expressions -exercises
Routine and time expressions -exercises
CDP キャンペーンサイト編 UPDATE
CDP キャンペーンサイト編 UPDATE
Lecture 'Service Offering - From Service Specifying to Service Cataloguing' V...
Lecture 'Service Offering - From Service Specifying to Service Cataloguing' V...
Servicialisation - From Service Identifying to Service Billing V01.02.00
Servicialisation - From Service Identifying to Service Billing V01.02.00
AWS+が提供する運用・保守サービス
AWS+が提供する運用・保守サービス
Servicialisation - Service Specifying: Example E-mailing Service V01.05.00
Servicialisation - Service Specifying: Example E-mailing Service V01.05.00
Lecture 'Servicialisation - Service Consumers Center Stage' 2012-05-24 V01.02.00
Lecture 'Servicialisation - Service Consumers Center Stage' 2012-05-24 V01.02.00
Routine part 1a
Routine part 1a
Ähnlich wie オリジナルAMIの作成(CentOS)
Uso de la Programación para la Seguridad en Redes (a.k.a. Sockets y Shellcoding)
Uso de la Programación para la Seguridad en Redes (a.k.a. Sockets y Shellcoding)
Pedro Valera
Unix training
Unix training
qywang1983
FISL11 2010 - Automação de Datacenters
FISL11 2010 - Automação de Datacenters
iG - Internet Group do Brasil S/A
Selinux twnic 201008-sa
Selinux twnic 201008-sa
CYJ
Symfony2 en pièces détachées
Symfony2 en pièces détachées
Hugo Hamon
我的Kissy学习笔记
我的Kissy学习笔记
satans17
Ähnlich wie オリジナルAMIの作成(CentOS)
(6)
Uso de la Programación para la Seguridad en Redes (a.k.a. Sockets y Shellcoding)
Uso de la Programación para la Seguridad en Redes (a.k.a. Sockets y Shellcoding)
Unix training
Unix training
FISL11 2010 - Automação de Datacenters
FISL11 2010 - Automação de Datacenters
Selinux twnic 201008-sa
Selinux twnic 201008-sa
Symfony2 en pièces détachées
Symfony2 en pièces détachées
我的Kissy学习笔记
我的Kissy学习笔记
Mehr von Hiroyasu Suzuki
VYATTA USERS MEETING Spring 2014
VYATTA USERS MEETING Spring 2014
Hiroyasu Suzuki
実践!AWSクラウドデザインパターン
実践!AWSクラウドデザインパターン
Hiroyasu Suzuki
cdp-night-01
cdp-night-01
Hiroyasu Suzuki
CDP in NAGOYA
CDP in NAGOYA
Hiroyasu Suzuki
AWS & cloudpack & CDP
AWS & cloudpack & CDP
Hiroyasu Suzuki
CDP(キャンペーンサイト編)
CDP(キャンペーンサイト編)
Hiroyasu Suzuki
Amazon Web Services(AWS)とcloudpack について
Amazon Web Services(AWS)とcloudpack について
Hiroyasu Suzuki
AWStatsでS3&CloudFrontのアクセス解析
AWStatsでS3&CloudFrontのアクセス解析
Hiroyasu Suzuki
RDS(MySQL)の利用と注意点
RDS(MySQL)の利用と注意点
Hiroyasu Suzuki
cloudpack(AWS運用事業)一周年でわかってきたこと
cloudpack(AWS運用事業)一周年でわかってきたこと
Hiroyasu Suzuki
AWSでスケールアウト&スケールアップ
AWSでスケールアウト&スケールアップ
Hiroyasu Suzuki
AWSのcloudpack流フルマネージメント
AWSのcloudpack流フルマネージメント
Hiroyasu Suzuki
AWS+でスケールアウト&スケールアップ
AWS+でスケールアウト&スケールアップ
Hiroyasu Suzuki
Mehr von Hiroyasu Suzuki
(13)
VYATTA USERS MEETING Spring 2014
VYATTA USERS MEETING Spring 2014
実践!AWSクラウドデザインパターン
実践!AWSクラウドデザインパターン
cdp-night-01
cdp-night-01
CDP in NAGOYA
CDP in NAGOYA
AWS & cloudpack & CDP
AWS & cloudpack & CDP
CDP(キャンペーンサイト編)
CDP(キャンペーンサイト編)
Amazon Web Services(AWS)とcloudpack について
Amazon Web Services(AWS)とcloudpack について
AWStatsでS3&CloudFrontのアクセス解析
AWStatsでS3&CloudFrontのアクセス解析
RDS(MySQL)の利用と注意点
RDS(MySQL)の利用と注意点
cloudpack(AWS運用事業)一周年でわかってきたこと
cloudpack(AWS運用事業)一周年でわかってきたこと
AWSでスケールアウト&スケールアップ
AWSでスケールアウト&スケールアップ
AWSのcloudpack流フルマネージメント
AWSのcloudpack流フルマネージメント
AWS+でスケールアウト&スケールアップ
AWS+でスケールアウト&スケールアップ
オリジナルAMIの作成(CentOS)
1.
オリジナルAMIの作成
(CentOS) suz-lab (AWS+)
2.
黒いブログ(suz-lab)、書いてます。
3.
目次 ext3の空イメージを作成 イメージマウントとデバイスファイル作成 fstabの作成とprocのマウント yumでCoreグループをインストール ネットワークの設定ファイルを作成 再びfstab、に追記 起動時にキー取得の仕込み Amazon EC2 AMI
Tools のインストール 登録用(S3アップロード用)イメージの作成 登録用イメージをS3にアップロード AMIとして登録
4.
ext3の空イメージを作成 全データがNULL(/dev/zero)のファイル(centos.img)を作成。 サイズは
count(1024) x bs(1M) = 1G とする。(最小構成) # dd if=/dev/zero of=centos.img count=1024 bs=1M 上記の空イメージに(-F)、ext3ジャーナルを持った(-j)ファイル システムを作成。 # mke2fs -F -j centos.img このイメージファイルがS3にアップロードされるAMIです。
5.
イメージマウントとデバイスファイル作成 ループバックデバイス(-o loop)としてイメージをマウント。
※ ファイルをブロック型デバイスのように扱う機能 # mkdir fs-centos # mount -o loop centos.img fs-centos イメージにデバイスファイル(fs-centos/dev)を作成します。 でも、ループの意味とか"-x"とか、よくわかりません... # mkdir fs-centos/dev # for i in console null zero; do # /sbin/MAKEDEV -d fs-centos/dev -x $i; # done
6.
fstabの作成とprocのマウント イメージ中に以下のようにfstabを作成 (AMI起動時、このイメージの内容は/dev/sda1になります)
# cat fs-centos/etc/fstab /dev/sda1 / ext3 defaults 11 none /dev/pts devpts gid=5,mode=620 0 0 none /dev/shm tmpfs defaults 00 none /proc proc defaults 00 none /sys sysfs defaults 00 procファイルシステムのマウント # mkdir fs-centos/proc # mount -t proc none fs-centos/proc
7.
yumでCoreグループをインストール Coreグループインストール用のyum設定ファイルを準備。 # cp
/etc/yum.conf yum-ami.conf # cat /etc/yum.repos.d/CentOS-Base.repo >> yum-ami.conf しかし、設定ファイル中の$releaseverが展開されない... [base] name=CentOS-$releasever - Base ... なので、無理やり置換 & インストール。 # sed -i 's/$releasever/5.4/g' yum-ami.conf # yum -c yum-ami.conf # --installroot=/mnt/fs-centos -y groupinstall Core
8.
ネットワークの設定ファイルを作成 インスタンス起動時に認識されるeth0に対してDHCPの設定。 # cat
fs-centos/etc/sysconfig/network NETWORKING=yes # cat fs-centos/etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=dhcp ONBOOT=yes TYPE=Ethernet USERCTL=yes PEERDNS=yes IPV6INIT=no
9.
再びfstab、に追記 インスタンス起動時に割り当てられる、大容量ディスク!? (/dev/sda2)とスワップ領域(/dev/sda3)に関して追記。 #
cat fs-centos/etc/fstab /dev/sda1 / ext3 defaults 11 none /dev/pts devpts gid=5,mode=620 0 0 none /dev/shm tmpfs defaults 00 none /proc proc defaults 00 none /sys sysfs defaults 00 /dev/sda2 /mnt ext3 defaults 00 /dev/sda3 swap swap defaults 00
10.
起動時にキー取得の仕込み(その1) fs-centos/etc/rc.localに記述
-------- ここから -------- #!/bin/sh touch /var/lock/subsys/local PUB_KEY_URI=http://169.254.169.254/1.0/meta-data/public-keys/0/openssh-key PUB_KEY_FROM_HTTP=/tmp/openssh_id.pub PUB_KEY_FROM_EPHEMERAL=/mnt/openssh_id.pub ROOT_AUTHORIZED_KEYS=/root/.ssh/authorized_keys if [ ! -d /root/.ssh ] ; then mkdir -p /root/.ssh chmod 700 /root/.ssh fi
11.
起動時にキー取得の仕込み(その2) curl --retry 3
--retry-delay 0 --silent --fail -o $PUB_KEY_FROM_HTTP $PUB_KEY_URI if [ $? -eq 0 -a -e $PUB_KEY_FROM_HTTP ] ; then if ! grep -q -f $PUB_KEY_FROM_HTTP $ROOT_AUTHORIZED_KEYS then cat $PUB_KEY_FROM_HTTP >> $ROOT_AUTHORIZED_KEYS echo "New key added to authrozied keys file from parameters"|logger -t "ec2" fi chmod 600 $ROOT_AUTHORIZED_KEYS rm -f $PUB_KEY_FROM_HTTP elif [ -e $PUB_KEY_FROM_EPHEMERAL ] ; then if ! grep -q -f $PUB_KEY_FROM_EPHEMERAL $ROOT_AUTHORIZED_KEYS then cat $PUB_KEY_FROM_EPHEMERAL >> $ROOT_AUTHORIZED_KEYS echo "New key added to authrozied keys file from ephemeral store"|logger -t "ec2" fi chmod 600 $ROOT_AUTHORIZED_KEYS chmod 600 $PUB_KEY_FROM_EPHEMERAL fi
12.
起動時にキー取得の仕込み(その3) if [ -e
/mnt/openssh_id.pub ] ; then if ! grep -q -f /mnt/openssh_id.pub /root/.ssh/authorized_keys then cat /mnt/openssh_id.pub >> /root/.ssh/authorized_keys echo "New key added to authrozied keys file from ephemeral store"|logger -t "ec2" fi chmod 600 /root/.ssh/authorized_keys fi -------- ここまで -------- 上記処理をすることで、sshにて、事前に登録したキーを使った rootでのログインが可能になります。 curlを利用しているので、別途インストール(yum)の必要あり。 Coreグループには含まれていない
13.
Amazon EC2 AMI
Tools のインストール その前に依存しているrsyncとrubyをインストール # yum install rsync # yum install ruby RPMの取得 & インストール # curl -OL http://s3.amazonaws.com/ec2-downloads/ec2- ami-tools.noarch.rpm # rpm -Uvh ec2-ami-tools.noarch.rpm
14.
登録用(S3アップロード用)イメージの作成 まず、fs-centosをアンマウント。 # umount
fs-centos 作成したイメージファイル(centos.img)を指定してアップロード用 のファイルセットを作成。 # ec2-bundle-image -i centos.img # -k pk-XXXXXXXX.pem # -c cert-XXXXXXX.pem # -u 000000000000 -k : 鍵ファイル(Access Identifiers ページ!?から取得可能) -c : 証明書ファイル(Access Identifiers ページ!?から取得可能) -u : Account Number (ハイフンをとったもの)
15.
登録用イメージをS3にアップロード ec2-bundle-imageで以下のファイルの作成を確認。 centos.img.manifest.xml centos.img.part.00 ... S3のBucket(-b)とmanifest.xml(-m)を指定してアップロード。 #
ec2-upload-bundle -b ami.suz-lab.com # -m centos.img.manifest.xml # -a XXXXXXXX # -s XXXXXXXXXXXXXXXX -a : アクセスキー(文字列) (Access Identifiers ページに) -s : シークレットキー(文字列) (Access Identifiers ページに)
16.
AMIとして登録 いろいろ方法があります。
コマンドライン(EC2 API Tools) AWS Management Console Elasticfox (Firefoxのアドオン) "Images"タブにて、"Machine Images"の領域で右クリッ クし、「Register a new AMI」を選択することで登録できま す。 選択時には、下記のようにBucket名からのXMLファイルを指定 することになります。 ami.suz-lab.com/centos.img.manifest.xml
Jetzt herunterladen