# ã¿ã¤ãã«é·ãã
Amazon EBS(Elastic Block Store)ã§ã¯ãã¹ãããã·ã§ããæ©è½ã¨å¼ã°ãããããªã¥ã¼ã (ãã£ã¹ã¯)ãç¬æã«ããã¯ã¢ããããæ©è½ãAPIçµç±ã§ç°¡åã«ä½¿ããã¨ãã§ãã¾ãã
åè
- 最近発表されたストレージサービスAmazon EBS(Elastic Block Store)をEC2から利用する - 元RX-7乗りの適当な日々
- Amazon EBSを活用してデータをバックアップしてみよう ~Amazon EC2/S3環境構築のすべて~ (1/6):CodeZine(コードジン)
ãããªä¾¿å©æ©è½ãªEBSã¹ãããã·ã§ããåã§ããããã®ããã¯ã¢ãããã¼ã¿ã®ä¿åå
ã¯Amazon S3ã¨ãããã¨ã§ãS3ã®å©ç¨å®¹éç¡å¶éï¼ã¨ããç´ æ´ãããæ©æµãåãã¡ãã£ã¦ãã¦ãå½ç¶ãããã¯ã¢ãããã¼ã¿ã®ä¸ä»£ç®¡çã¯ä½¿ãæèªèº«ã«å§ãããã¦ãã¾ãã
ã¨ãããã¨ã§ãæå®ããEBSããªã¥ã¼ã ã«å¯¾ãã¦ãã¹ãããã·ã§ãã(ããã¯ã¢ãã)åå¾ãã¤ã¤ãä¸ä»£ç®¡ç(æå®ä¸ä»£æ°ã«åºã¥ãã¦å¤ããã¼ã¿ãåé¤)ããããããªã¹ã¯ãªãããæã«æ¸ããã®ã§ãããã¨ãªãå ¬éãã¾ãã
ããããAmazon EC2ã§éç¨ããã®ã ã¼ãã¨ããæ¹ã«ã¯ééããªãå½¹ã«ç«ã¤ã¯ãã
åæ
- ec2-api-toolsãåããã¨
- EC2ã®X.509証ææ¸ãæå (ãµã¼ã)ã«ãããã¨
ã¹ã¯ãªããã®ä¸èº«
以ä¸ã®ãããªæãã§ãã
#!/bin/sh export JAVA_HOME=/usr export EC2_HOME=/opt/ec2-api-tools export PATH=${PATH}:/bin:/usr/bin:${EC2_HOME}/bin # ----- config AWS_PRIVATE_KEY=/etc/ec2_keys/pk.pem AWS_CERTIFICATE=/etc/ec2_keys/cert.pem EBS_VOLUME_ID="vol-ead8e482" EBS_GENERATION_COUNT=3 AWS_REGION=`curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed -e 's/[a-z]$//'` # ----- # ã¹ãããã·ã§ããã®åå¾ echo -n "[creating...] " ec2-create-snapshot --private-key ${AWS_PRIVATE_KEY} --cert ${AWS_CERTIFICATE} --region ${AWS_REGION} ${EBS_VOLUME_ID} # ã¹ãããã·ã§ããã®ä¸è¦§ãåå¾ SNAPSHOTS=`ec2-describe-snapshots --private-key ${AWS_PRIVATE_KEY} --cert ${AWS_CERTIFICATE} --region ${AWS_REGION} | grep ${EBS_VOLUME_ID} | sort -k5 -r | awk '{print $2}'` # ä¸ä»£ä¿ç®¡åã®èª¿æ´(éå»ã¹ãããã·ã§ããã®ã¯ãªã¢) COUNT=1 for SNAPSHOT in ${SNAPSHOTS}; do if [ ${COUNT} -le ${EBS_GENERATION_COUNT} ]; then # ä¿ç®¡å¯¾è±¡ãªã®ã§N/A echo "[keeping] " ${SNAPSHOT} else # ä¿ç®¡å¯¾è±¡å¤ãªã®ã§åé¤ echo -n "[deleting...] " ec2-delete-snapshot --private-key ${AWS_PRIVATE_KEY} --cert ${AWS_CERTIFICATE} --region ${AWS_REGION} ${SNAPSHOT} fi COUNT=`expr ${COUNT} + 1` done
ãã®ã¹ã¯ãªããã¯ããµã¼ããèªåèªèº«ã«æ¥ç¶ããã¦ããEBSããªã¥ã¼ã ã«å¯¾ãã¦åå¾ãããã¨ãæ³å®ããç°¡åãªå®è£ ä¾ã§ãã
- ä¸é¨ã®PATHãè¨å®é¨åã¯ãé©å®æ¸ãæããããã«ãã¦ãã ããã
- ec2-api-toolsãX.509証ææ¸ã¯ããµã¼ãã«é ç½®ã®ä¸ãè¨å®ã®ãã¡ã¤ã«ã»ãã£ã¬ã¯ããªãã¹ãæ¸ãæãã¦ãã ããã
- "EBS_VOLUME_ID"ã«ã¯ãåå¾ãããEBSããªã¥ã¼ã ã®IDãå
¥ãã¦ãã ããã
- è¤æ°ã®EBSããªã¥ã¼ã ã対象ã«ãããã¨ãã¯ãé©å½ã«ã«ã¼ãã§ã¾ããããã«æ¸ãæãã¦ãã ããã
- "EBS_GENERATION_COUNT"ã«ã¯ãä¿æãã¦ããããä¸ä»£æ°ãå ¥ãã¦ãã ããã
- "AWS_REGION"ã®é¨åã¯ãä¸è¨ã§ã¯èªåã§ãµã¼ãèªèº«ãåãã¦ããRegionãå
¥ãããã«ãã¦ãã¾ãã
- EC2å¤ã®ãµã¼ãããå¥Regionã®ãµã¼ã(EC2ã¤ã³ã¹ã¿ã³ã¹)ããå®è¡ãããå ´åã¯ãæåã§Region("us-west-1"ãªã©)ãå ¥ããããã«ãã¦ãã ããã
(ãã¾ãæ¸ããããªããã©)注ææ¸ã
ãã¨ããã®ã¹ã¯ãªããã使ã£ã¦ä½ããã£ã¦ã(ããã¯ã¢ãããåãã¦ãªãã£ãï¼ã¨ã)責任ã¯åãã¾ããã®ã§ããã¡ãã¨ãã¹ãããä¸ã§ãããã¦èªå·±è²¬ä»»ã§ãå©ç¨ãã ããããããããé¡ããã¾ãã
ã¾ã¨ã
ã¯ã©ã¦ãAMAZON EC2/S3ã®ãã¹ã¦ (ITpro BOOKs)
- ä½è : 並河ç¥è²´,å®éè¼é,ITpro/æ¥çµSYSTEMS
- åºç社/ã¡ã¼ã«ã¼: æ¥çµBP社
- çºå£²æ¥: 2009/11/05
- ã¡ãã£ã¢: åè¡æ¬
- è³¼å ¥: 4人 ã¯ãªãã¯: 372å
- ãã®ååãå«ãããã° (18件) ãè¦ã