ãã£ã¨éãã¦ããããã¹ããé ¼ã
ä»ãã£ã¦ãããã¸ã§ã¯ãã®ãã¹ãã±ã¼ã¹ã¨ãã¹ããã¼ã¿ãçµæ§ãªéãããç§ã®ãã·ã³ã§å®è¡ããã¨15å以ä¸ããã£ã¦ãã¾ãã¾ãããã¹ãç°å¢ã¯ã VMwareã§CentOSãã²ã¹ãOSã«ãã¦ãWindows7ããã¹ãOSã«ãã¦ã¾ãããã¼ãPCã¯8Gã¡ã¢ãªã5400rpmã®HDDãä¸çªã®åå ã¯ã5400rpmã®HDDãã¤VMwareã®ã²ã¹ãOSã®ãã£ã¹ã¯I/Oãé ãã¨ãããã¨ã§ãããã®ãããã¹ããã¼ã¿(Fixture)ããã¹ãã±ã¼ã¹ãã¨ã«ãªã¹ãã¢ãã¦ã¨ããåä½ã«æéããããã¾ãã
ã¾ãã¯ãHDDãIntel SSDã«å¤ãã¦ããã10å以ä¸ã«ç縮ã§ãã¾ãããSSDå¿«é©ããããIntelSSDã¯ç§»è¡ãã¼ã«ãç¡æã§ä»ãã¦ãã®ã§ä¾¿å©ã§ãã
SSDã§å¿«é©ã«ã¯ãªãã¾ãããããã£ã¨éããããã³ã¨ãããã®ãã¾ããSSDã«ãã£ã¹ã¯I/Oçºè¡ãã¾ããã®ã¯SSDã®å¯¿å½ã縮ããã®ã§ç²¾ç¥çã«è¯ããªãã§ãã(SSDã¯ãã¼ã¿ãããã¯ã®æ¸ãæãåæ°ã«ä¸éãããã®ã§ï¼
ã¨ãããã¨ã§ãOSèµ·åæã«ãMySQLã®ãã¼ã¿ãã©ã«ããã¡ã¢ãªã«å ¨é¨è¼ãã¦ãã¾ã£ã¦ãã·ã£ãããã¦ã³ããã¨ãã«ãã£ã¹ã¯ã«æ»ãã¨ããã¢ã¤ãã£ã¢ãå®è¡ãã¾ããã
çµè«ããè¨ãã¨ããã¹ãã¯5åãããã«åã¾ãã¾ããï¼
[追è¨] phpã®xdebugã¯ãã¹ãå®è¡ä¸ã¯OFFã«ããã»ããè¯ãã§ãã ï¼åãããç縮ã§ãã¾ããã
ã¡ã¢ãªã«è¼ããã¨ã¯ãLinuxã®tmpfsã¨ããã¡ã¢ãªãã¡ã¤ã«ã·ã¹ãã ã®æ©è½ã使ã£ã¦(Windowsã®RAM diskã¿ãããªãã¤ï¼ãããã«MySQLãã¼ã¿ãmvã³ãã³ãã§ç§»åãããã ãã§ããCentOSã®ãããªRedhatã¯ãã¼ã³ã®Linuxã ã¨ãæ¨æºã§/dev/shmã¨ãããã£ã¬ã¯ããªãtmpfsã¨ãã¦ãã¦ã³ãããã¦ããã®ã§ãä»åã¯ãããå©ç¨ãã¾ããCentOSã«2Gã®ã¡ã¢ãªãå²ãå½ã¦ããã/dev/shmã¯500Mã»ã©ãã¦ã³ãããã¾ããã
ã¡ãªã¿ã«ããã¹ããã¼ã¿ã¯ä¸åº¦ããã¯ã¢ãããåã£ã¦ããã¦ããã¤ã§ãå¹ã£é£ãã§è¯ãããã«ãã¾ãã(OSãã¯ã©ãã·ã¥ããã¨å ¨é¨æ¶ããã®ã§ï¼
/etc/rc.d/init.d/mysql stop cp -rp /var/lib/mysql /var/lib/mysql-bkup
ä»åï¼ã¤ã®ã¹ã¯ãªãããä½ãã¾ããã
- onMemoryDeploy.sh:
- DBãã¡ã¤ã«ã/dev/shmã«ç§»åããã¦ã/var/lib/mysqlã«ãªã³ã¯ãè²¼ãã¹ã¯ãªããï¼ãã®éã®åä½ãï¼
- onMemoryMySQL:
- CentOSã®init scriptã /etc/rc.d/init.d/以ä¸ã«ããã¦OSèµ·åãåæ¢æã«onMemoryDeploy.shãå®è¡ãã
Ubuntuã®äººã¨ãMacã®äººã¯init scriptãèªä½ãã¦ãonMemoryDeploy.shã®ãã©ã¡ã¼ã¿ãå¤ããã°ãããã¨æãã¾ãã
ã§ã¯ã¾ããonMemoryDeploy.shããã
ãã£ã¦ããäºã¯ãmysqlåæ¢ãã¦ãtmpfsã«ãã¼ã¿ãmvãã¦ã/var/lib/mysqlã«ã·ã³ããªãã¯ãªã³ã¯ãè²¼ã£ã¦ãã ãã§ããæåã®ï¼è¡ã®ãã©ã¡ã¼ã¿ãèªåã®ç°å¢ç¨ã«å¤æ´ããã°ãããã¨æãã¾ãã
次ã«ãCentOSç¨ã®init script.
ä»åã¯ãï¼ã¤ã®ã¹ã¯ãªãããä¸è¨ã®ãã£ã¬ã¯ããªã«è¨ç½®ã
/root/onMemoryDeploy.sh /etc/rc.d/init.d/onMemoryMySQL
ããã¦ãèµ·åæã«å®è¡ãããããã«ãã
/sbin/chkconfig --add onMemoryMySQL /sbin/chkconfig onMemoryMySQL on
ããã ãã§ããEnjoy!
ä½è«
CentOSç¨ã®init scriptã§ã/var/lock/subsys/onMemoryMySQLã«ãã¡ã¤ã«ãä½ã£ã¦ããã®ã¯ããã®ãã¡ã¤ã«ãåå¨ããªãã¨åæ¢æã«å®è¡ãã¦ãããªããªãã®ã§ãå®é¨ä¸ã¯ä½åº¦ããã¼ã¿æ¶ãã¾ããããã