ãããã¯ã¼ã¯åå¿è ãããããã¯ã©ã¦ãããAWSã«ç§»è¡ããæã®ã¡ã¢
ネットワーク素人が、さくらクラウドで負荷分散構築した時のメモ1【準備編】 - なりせなるてず
ãã®è¨äºã4æã«æ¸ãã¦ãããã£ã5ã¶æã§ããAWSã«åå移è¡ãã¾ããã
AWSã«ç§»è¡ãããã£ãã
å¬ãããã¨ã«èªç¤¾ãµã¼ãã¹ãé 調ã«æé·ãã¦ã¦ãã¢ã¯ãã£ãã¦ã¼ã¶ã¼ãã ããã常æ300以ä¸ãå¤ãæã¯1500ãã3000ä½ã«ã¾ã§ã¢ã¯ã»ã¹ãéã¾ãããã«ãªã£ããã¨ã§ãã
å¿è«ãããã¯ã©ã¦ãã§ã対å¿åºæ¥ããã§ãããç¬éçã«é常æã®5åãã10åã®ã¢ã¯ã»ã¹ãæãã¤ã¤ãé常æã¯ãµã¼ãã¼ãæ¸ããã¦å®ãæãããã¨ããè¦æ±ãå¶ããããã«ã¯ãããã¯ã©ã¦ãããã ãªã ããã¨ãããã¨ã«ãªãã¾ããã
ãããã¯ã©ã¦ãã¯ãªã¼ãã¹ã±ã¼ãªã³ã°å¯¾å¿ãã¦ã¾ããããä»ã®ã¨ãããã®äºå®ããªããããªã®ã§AWSã®åºçªã¨ããããã§ãã
ãªã¼ãã¹ã±ã¼ã«ã«å¯¾å¿ããã¯ã©ã¦ããµã¼ãã¹ã¯AWS以å¤ã«ãããã¾ãããã¾ãAWSä¸æã§ãããã
AWSã®ãåå¼·
AWSã¯ãªã¼ãã¹ã±ã¼ã«åºæ¥ã¦åãï¼ãããã®ç¥èããç¡ãã£ãã®ã§ãåå¼·ã§ã
ããã¨
èªåããããã¨æã£ã¦ããã¨ã¯ã»ã¼ãã®2ã¤ã«æ¦è¦ããããæ¹ã¾ã§æ¸ãã¦ãããé常ã«åèã«ãªãã¾ããã
ãã ãAWSã®ã³ã³ã½ã¼ã«ç»é¢ã¯ããã£ã¡ã
ãå¤ãã£ã¦ãã®ã§ãAWSã³ã³ã½ã¼ã«ãããªã¼ãã¹ã±ã¼ãªã³ã°ãããè¨å®ã¯
AWS - 【AutoScalingをManagementConsoleから設定してみる】 - Qiita
ãã¡ããåèã«ãã¾ããã
EC2ã®ã¤ã³ã¹ã¿ã³ã¹ãä½ãã¨ãã«Amazon Linuxãé¸ã¶ã¨ãã¹ããã¯ã¯ããã¼ãã§ãã1å¹´éç¡æã§ä½¿ãããã©ã³ãããã®ã§è²ã
ãã¹ãã§ãã¾ãã
クラウドサービス無料利用枠 | アマゾン ウェブ サービス(AWS 日本語)
ãµã¼ãã¼æ§æ
å
ã»ã©ã®ã¹ã©ã¤ãã«ããã¾ãããããããæ§ç¯ã«ããã»ãããããï¼ã£ã¦ã®ãã»ã¼ä¸¸ãã¯ãªãã¦æ§ç¯ãããã¨èãã¾ããã
ãªã¼ãã¹ã±ã¼ãªã³ã°ã使ãæµãã¨ãã¦ã¯ã
1.EC2ã§webãµã¼ãã¼ã¨ãã¦æ©è½ãããã®ãä½ããèµ·åæã«èªåã§ææ°ã®ããã¸ã§ã¯ãããããã¤ããä»çµã¿ãä½ã£ã¦ãã
2.EC2ã§webãµã¼ãã¼ãåºæ¥ãããã¤ã³ã¹ã¿ã³ã¹ãstopãã¦ãAMIãä½ã
3.ãã¼ããã©ã³ãµã¼ãä½ã
4.ãªã¼ãã¹ã±ã¼ãªã³ã°ã®è¨å®ãä½ã
ãããªæãã§ä½ã£ã¦ç§»è¡ãã¦ã¿ããã§ããã移è¡3æéã§è»¢ééããã¡ããã¡ãããã£ã¦ãã°ãäºãå¤æã
ãã®ã¾ã¾è¡ãã¨æé¡80ä¸ä½ãããè¨ç®ã§ããã»ã»ã»(ï¾Ð´ï¾;)
å·ãæ±ãæ¢ã¾ããªãã£ãã§ãã
æ¥ãã§è»¢ééãããããªããããã¯ã©ã¦ãã«ç»åãç½®ããã¨ã«ãã¾ããã
ã§ãçµå±æçµçã«ã¯ããããæ§ç¯ã«ãªãã¾ããã
ç»åãNFSã§ãããã¯ã©ã¦ãã®ãã¡ã¤ã«ãµã¼ãã¼ã«ã¢ãããã¼ããã¦ãç»åã®URLããããã¯ã©ã¦ãå´ã«ãã¢ã¯ã»ã¹ãããããã«ãã¾ããã
webãµã¼ãã¼ã¯ãªã¼ãã¹ã±ã¼ãªã³ã°åºæ¥ãAWSã使ããç»åã¯è»¢ééã§ãéãããããªããããã¯ã©ã¦ãã«ãã¦ã両è
ã®ããã¨ãåããå®ç¾ãã¾ããã
æ¸æã£ããã¨
移è¡ããã«ããã£ã¦è²ã ããã£ãäºããã£ãã®ã§ã¡ã¢
RDSã¯UTCåºå®
RDSã®ã¿ã¤ã ã¾ã¼ã³ã¯UTCåºå®ã§åºæ¬çã«ã¯å¤æ´ã§ãã¾ããã
è²ã
å¤æ´ããæ¹æ³ã¯ããã£ã½ãã§ãããå®æã¡ã³ããã³ã¹æã«è½ã¡ãã¨ããã人ã¦æãã®ã§ãã£ã¦ã¾ããã
RDSã®ã¹ãã¬ã¼ã¸ã¯è¿½å åºæ¥ããã©æ¸ãããã¨ã¯åºæ¥ãªã
ä½ã£ããã¨ã§ãããªã«å®¹éè¦ããªããã¨æã容éã®å¤æ´ããããã¨æã£ãã®ã§ããã追å ãããã¨ã¯åºæ¥ã¦ãåé¤ãããã¨ã¯åºæ¥ã¾ããã§ããã
CentOSãè²ã å ¥ã£ã¦ãªã
vimã¨ãwgetã¨ãããã¨è²ã
ãµã¼ãã¹ç¾¤ãå
¥ã£ã¦ã¾ããã§ããã
ãããã¯ã©ã¦ãã®CentOSã«ã¯åæããè²ã
ãµã¼ãã¹ãå
¥ã£ã¦ã¦ãã使ããã®ã§ä¾¿å©ã§ããã
ãã ãã®åé¢åæããèµ·åãã¦ããµã¼ãã¹ã¯ãã®ã¾ã¾ã«ãã¦ãã¨ãããªãã®ç¢ºçã§DDosãªã©ã®è¸ã¿å°ã«ãããã®ã§å¯¾å¿ããªããã°ãªããé¢åã§ãã
å½ç¶ã¨ããã°å½ç¶ã§ãããAWSã®CentOSã¯ä½è¨ãªãµã¼ãã¹ã¯å
¥ã£ã¦ããã軽éã§ãã
topã³ãã³ãã§è¦ããCPU使ç¨çããã¦ã«ãªããªã
ApacheBenchã§è² è·ãã¹ãããã¦ãæãåææ¥ç¶æ°ããããå¢ããã¦ã40%ä½ãé度ã«ãã以ä¸CPU使ç¨çãä¸ããã¾ããã§ããã
Amazon EC2 インスタンスの負荷測定 : まだプログラマーですが何か?
ããããçç±ãããã¿ããã§ãã
ELBã¯IPã¢ãã¬ã¹ããªã
ELBã«ã¯IPã¢ãã¬ã¹ãç¡ããEIPã使ã£ã¦ãè¨å®ãããã¨ãåºæ¥ã¾ããã
ã¤ã¾ãAã¬ã³ã¼ãã§DNSãè¨å®ãããã¨ãåºæ¥ããCNAMEããç¡çã¨ãããã¨ã§ãã
ä¸åå¼·ã§ç¥ããªãã£ãã®ã§ãããCNAMEã¯ãµããã¡ã¤ã³ããæå®ãããã¨ãåºæ¥ãªãã®ã§ã
ãwww.example.comãã¿ãããªã¢ãã¬ã¹ã§è¯ããã°ããã®ã§ããããexample.comãã¿ãããªURLã§ã¢ã¯ã»ã¹ããããã¨ãåºæ¥ã¾ããã
ããã解決ããã«ã¯Route53ã使ãããããã¾ãããããåºæ¥ã¦ã¾ããã»ã»ã»ã
営業でも簡単!Route 53の基本設定 « サーバーワークス エンジニアブログ
ä¸è¨ãè¦ã¦è¨å®ãã¾ããã
ãªã¼ãã¹ã±ã¼ãªã³ã°ã°ã«ã¼ãã®è¨å®ãå¤ããã¨çªç¶EC2ãæ»ã¬ãã¨ããã
AMIãæ´æ°ãã¦ãªã¼ãã¹ã±ã¼ãªã³ã°ã°ã«ã¼ããå¤æ´ããããããã§ããããããããã¨æ°æéå¾ï¼ã¿ã¤ãã³ã°ã¯ä¸æï¼ã§çªç¶EC2群ãæ»ãã§ãæ°ããAMIã§ç«ã¡ä¸ããã¾ãã
æ¤ç´¢ãã¦ãåºã¦ããªãç¾è±¡ãªã®ã§è©³ç´°ã¯ä¸æã§ãã
ããåºã¦ããæå³åãããªãã£ãåèª
AMI
Amazon Machine Imageã®ç¥ã
ã¤ã³ã¹ã¿ã³ã¹ãä½ãã¨ãã®ã²ãªå½¢ã
ApacheãPHPãªã©å¿
è¦ãªãã®ãã¤ã³ã¹ãã¼ã«ãã¦ããã¦ããªã¼ãã¹ã±ã¼ãªã³ã°ããã¨ãã«ãªã©ã«ãã®ã²ãªå½¢ãå
ã«ã¤ã³ã¹ã¿ã³ã¹ãèªå追å åºæ¥ãã
ELB
Elastic Load Balancingã®ç¥ã
ãã¼ããã©ã³ãµã§ãããã ãæ®éã®ãã¼ããã©ã³ãµã¨éãããã¼ããã©ã³ãµèªä½ãã¹ã±ã¼ã«ã¢ããåºæ¥ãã
EBS
Elastic Block Storeã®ç¥ã
ã¹ãã¬ã¼ã¸ã®ãã¨ã
èµ·åä¸ã®EC2ã«ã¹ãã¬ã¼ã¸ã追å ã§ãããããã
AZ
Availability Zoneã®ç¥ã
ãã¼ã¿ã»ã³ã¿ã¼ã®ä¸ã§ãé»æºãªã©ãç©ççã«åããã¦ããå ´æã®äºãããã§ãã
Multi-AZã¯å¥ã
ã®AZã«EC2ãRDSãé
ç½®ãããã¨ã§ã天ç½æãªã©ã§ä¸ãä¸ã©ã¡ããã®é»æºãè½ã¡ãããã¦ãå¥ã®AZã«ã¯ã¢ã¯ã»ã¹ã§ããèé害æ§ã«åªãã¦ããã¨ãããã¨ã¿ããã§ãã
IOPS
I/O per Secondã®ç¥ã
HDDãªã©ã®ãã£ã¹ã¯ã1ç§éã«åºæ¥ãI/Oå¦çã®æ°ã®ãã¨ãããã
ãã®æ°å¤ãé«ãã»ã©æ§è½ãããã¨ãããã¨ã100IOPSã ã£ãã1ç§éã«100åãã©ã³ã¶ã¯ã·ã§ã³å¦çãåºæ¥ãï¼å¤åï¼
ãããã¯ã©ã¦ã vs AWS
ãããã¯ã©ã¦ããæå©ã ã¨æãç¹
1. ãããã®ã»ããï¼ã¤ã³ã¹ã¿ã³ã¹ã«å¯¾ãã¦ã®è²»ç¨å¯¾ã¹ããã¯ãããã§ãã
ä¾ãã°ç¤¾å
åãã®ã³ãã¥ãã±ã¼ã·ã§ã³ãã¼ã«ã¿ããã«ãããç¨åº¦ã¢ã¯ã»ã¹ãã人æ°ãPVãããã£ã¦ããç¶æ
ã§ã¯ãããã¯ã©ã¦ãã§æ§ç¯ããã»ããå®ä¸ããã«ãªãã¨æãã¾ãã
2. ããã¥ã¡ã³ããã³ã³ã½ã¼ã«ãæ¥æ¬èª
AWSã®ããã«é »ç¹ã«ã³ã³ã½ã¼ã«ç»é¢ãå¤ãããã¨ãç¡ãã®ã§ããã¥ã¡ã³ããããã°ã§è¦ãæ
å ±ã®ã¾ã¾ä½¿ãããã¨ãå¤ãã§ã
3. 転ééãããããªã
æ¨æºçãªWebãµã¼ãã¹ãAWSã§éç¨ããæãæããéããããã®ãç»åãªã©ã®è»¢ééã ã¨æãã¾ãã
ããã«ãéãããããªãã®ã¯ç¸å½ãã«ã¤ã§ãã
AWSãæå©ã ã¨æãç¹
1. ã»ãã¥ãªãã£ã°ã«ã¼ã
ããã®ãé°ã§iptablesã¨ãæ¸ããªãã¦ãããããä½ç¨å¤ãªè¨å®ã«ããªãéãã»ãã¥ãªãã£ã®ç©´ã«ãªããã¨ããªãã®ããªãã¨æãã¾ãã
2. ãªã¼ãã¹ã±ã¼ãªã³ã°
ããããããã¯ã©ã¦ãããAWSã«ç§»è¡ãã決ãæã§ã
3. èµ·åä¸ã®ã¤ã³ã¹ã¿ã³ã¹ã«ã¹ãã¬ã¼ã¸è¿½å åºæ¥ã
è¦ç©ãã£ã¦ãããå¤ãã®ã¹ãã¬ã¼ã¸ãå¿
è¦ã«ãªã£ãæããµã¼ãã¼ãæ¢ãããã¨ç¡ãã¹ãã¬ã¼ã¸ã追å åºæ¥ãã®ã§ãµã¼ãã¹ã«å½±é¿ãªãé²ãããã¾ã
4. å§åçãªå¤æ©è½
ä½ããªãã ãåãããªããµã¼ãã¹ããã£ã±ãããã¾ã
ãããã«
移è¡ããåã¯AWSã«ç§»è¡ãããå ¨é¨è§£æ±ºã§ããã¿ãããªå¹»æ³ããã£ããã§ãããå¿è«å®éã«ã¯ãããªãã¨ã¯ãªãããããã¯ã©ã¦ãã®ã»ããåªãã¦ããé¨åãå¤ãã工夫次第ã§ã©ãã«ããªããªãã¨æãã¾ããã