AWSã§IPã¢ãã¬ã¹ã¨ããæ¦å¿µãç¡ããæ¹æ³ãcloudpack大éªããã°ã
EC2ã¯æè»ã
EC2ã¯ããªã³ãã¬ãã¹ã§ä½ãããè¨è¨ã¨åãããã«æ§æåºæ¥ãæè»æ§ãæã£ã¦ãã¾ãã
ãã®ãããå
ã
ã®è¨è¨ã«ãã£ã¦ã¯å¤å°ã®å¤æ´ã¯å¿
è¦ã§ããããªã³ãã¬ãã¹æ代ã®è¨è¨ã§AWSç°å¢ãæ§ç¯ãããã¨ãåºæ¥ã¾ãã
ãã®ããã«ãªã³ãã¬ãã¹ã®è¨è¨ãæã¡è¾¼ãäºã§ããAWSã¸ã®ç§»è¡ã¡ãªããã¯ãããã¨æãã¾ãã
ä¾ãã°ããµã¼ãã®èª¿éãæ©ããªããã¹ããã¯ãæè»ã«å¤ããããã®ã§åç´ã«å®ããªã£ããå¤ã¯æ¢ãããã¨ã§ã³ã¹ããã¦ã³ãåºæ¥ãããªã©ã
ããããé常ã«å¤§ããªã¡ãªããã§ãããè¯ããµã¼ãã¹æä¾ãåºæ¥ãã§ãããã
ãã ããããã£ãããªãï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼
ãã£ããã¯ã©ã¦ããå©ç¨ãã¦ããã®ã§ã使ãããªããªãã¨ãã£ãããªãã§ãï¼
使ãããªãã«ã¯çºæ³ã®è»¢æãå¿
è¦ã¨ãªãã¾ããã使ãããªããã¨ã§ããä½ã³ã¹ãã§ããæè»ãªèªååãªã©ãå³ãã¾ãã
ãããã次ã®ã¹ãããã«ç§»ãã¾ãããï¼ï¼
ã¨ãããã¨ã§ãä»å¾ãããããè¨è¼ãã¦ããããã¨æãã¾ãããã¾ãã¯IPã¢ãã¬ã¹ã«ã¤ãã¦ã
IPã¢ãã¬ã¹ãªããç¡ããã¡ã¾ã
ããããã¹ã¿ã¼ããªãã¯ã®ããã«ãã³ããã¯ã¼ã§æ¶ããã¨ã§ãããã¯ã©ã¦ãã£ã½ã使ããããã«ãªãã¾ãã
ãªãIPã¢ãã¬ã¹ãç¡ãããããã¨ããã¨ãAutoScaleã使ã£ã¦ã¹ã±ã¼ã©ãã«ãªæ§æã«ãããã
é害æã®å¾©æ§ãªã©ãèªåçã«è¡ããããã«ããéç¨è² è·ã軽æ¸ããããã®ã§ãã
ãªã®ã§ãIPã¢ãã¬ã¹ã¯ã¢ãµã¤ã³ãããã®ã§ã¯ãªãã
æèããªãï¼DHCPã«ããèªåå²å½ï¼è¨è¨ãå¿
è¦ã«ãªãã¾ãã
æ¬é¡
ã§ã¯ãæ¬é¡ã«å
¥ãã¾ãã
以ä¸ã¯ããããæ§æãã¨æãã¾ãã
ããããæ§æ
ããã¯ELBé
ä¸ã«ãªãã®ã§EC2ä¸ã®Apacheã¯IPãã¼ã¹ã§ã¯ãªãNameãã¼ã¹ã®ãã¼ãã£ã«ãã¹ãã«ãªã£ã¦ãããã¨æãã¾ãã
ãã®ããã以ä¸ã®æãã«ãªãã¾ãã
Route53 -> ELB | A-Alias or CNAME |
ELB -> EC2 | ã¤ã³ã¹ã¿ã³ã¹IDã§ç´ä»ã |
EC2 -> RDS | DNS Name |
ä¸è¨ã«ã¯IPã¢ãã¬ã¹ã§ç´ä»ãããã¦ãã¾ãããå®è³ªçã«EC2ã«ã¯IPã¢ãã¬ã¹ãå²ãå½ã¦ããã¦ãã¾ããã
IPã¢ãã¬ã¹ã§ç¹ãã¦ããªãã®ã§ãä¾ãIPã¢ãã¬ã¹ãå¤ãã£ãã¨ãã¦ããµã¼ãã¹ã¯ç¶ç¶ããã¾ãã
ã¤ã¾ããAutoScaleãªã©ãå©ç¨å¯è½ã«ãªãã¾ãã
次ã«ã以ä¸ã®ãããªæ§æãå¤ãã¨æãã¾ãã
ããã¯Nothingä¾ã§ãã
Nothingä¾
ãã®ç¶æ
ã ã¨çæ¹ã®EC2ã®IPãåºå®åãããä¾ãã°çæ¹ã®EC2ãå£ãã¦å¾©å
ããå ´åã«ã
IPã¢ãã¬ã¹ãå¼ãç¶ãå¿
è¦ãããã¾ãã
復å
æã«è¦ãã¦ãããIPã¢ãã¬ã¹ãæä½æ¥ã§å¼ãç¶ãããæé æ¸ã«åãè¾¼ããã
ã³ã¼ãã«åãè¾¼ããããªã©ãã¾ããããã¨èªä½ã¯åç´ãªãã§ããã
IPã¢ãã¬ã¹ãå¤ãã£ãæãªã©ããã¡ãã¡ã®è³æãæ´æ°ããªãã¨ãããªããã¨ãã¤ããæãã§æãã¾ãããã
è¨ããããã¨ã¯ããã®ä½æ¥ãæ¬å½ã«å¿
è¦ãªã®ï¼ãã§ãã
ã¯ããã«è¨è¨ã§ä½ã¨ããã¨ãã°ãä¸è¦ãªä½æ¥ã«ãªãããã®ã§ãã
ã§ã¯ãä½ã¨ããã¦ã¿ã¾ããããdone.
ãªã¹ã¹ã¡ä¾
ã¯ãããã®æ§æã§ãEC2èµ·åæã«åçã«èªåã®IPã¢ãã¬ã¹ã調ã¹ã¦
Route53ã®Aã¬ã³ã¼ããæ¸ãæããå¦çï¼ä¸è¨ã³ã¼ãï¼ãå
¥ãã¦ããã ãã§
IPã¢ãã¬ã¹ãæèããäºç¡ãæ§æã«ãªãã¾ããã
è²»ç¨ã100~200åç¨åº¦ã§åºæ¥ã¾ããã
IPã®äºèããããè³ææ´æ°ãããããã©ã£ã¡ã®ã³ã¹ããå®ããã§ããããã
ã¾ããåçã«IPã¢ãã¬ã¹ãåå¾ãã¾ãã®ã§ã
ã³ã¼ãå
ã«ãIPã¢ãã¬ã¹ãåãè¾¼ã¾ãããã¨ããªããªãã¾ããã
ã³ã¼ãä¾
IP_ADDRESS=`curl -s http://169.254.169.254/latest/meta-data/local-ipv4` sed -e 's/hogehoge/$IP_ADDRESS/g' /home/ec2-user/template.json > /home/ec2-user/update.json aws route53 change-resource-record-sets --hosted-zone-id ABCDXYZ --change-batch file:////home/ec2-user/update.json
â»template.jsonãã¡ã¤ã«ã¯ã¬ã³ã¼ãå
容ã«å¿ãã¦å¥éçæããå¿
è¦ãããã¾ãã
http://docs.aws.amazon.com/cli/latest/reference/route53/change-resource-record-sets.html
ããã¦ããããIPã¢ãã¬ã¹ãæ¶ãã¾ããã
ã¡ã£ã¡ããã§ããããã®è¾ºãã«ä½æ¥ããªããªãã¾ãããã
復å æã«è¦ãã¦ãããIPã¢ãã¬ã¹ãæä½æ¥ã§å¼ãç¶ãããæé æ¸ã«åãè¾¼ããã
ã³ã¼ãã«åãè¾¼ããããªã©ãã¾ããããã¨èªä½ã¯åç´ãªãã§ãããIPã¢ãã¬ã¹ãå¤ãã£ãæãªã©ããã¡ãã¡ã®è³æãæ´æ°ããªãã¨ãããªããã¨ãã¤ããæãã§æãã¾ãããã
ãã®ããã«ãã¦ãä¸ã¤ã¥ã¤è²ã
ãªãã®ãå¼ãå¥ããã¦ãããã¨ã§ã
ä¸è¦ãªä½æ¥ãæ²æ»
ãã¦ããã¾ãããã
以ä¸ã