ãã£ãªï¼ã¿ããªãKyoto Tycoonã©ã¤ããã¨ã³ã¸ã§ã¤ãã¦ãããï¼ï¼
ä»æ¥ã¯KTã©ã¤ããæºå«ãã¦ããã¼ããã®éç¨TIPSã¢ã³ãã½ã¼ãªã³ããå±ãããYOï¼
kchashmgrã¨ktremotemgrã³ãã³ãã®è£å®
人éã®è³æ´»åã®ãã¼ã¯ã¯22æ³ã®ä»æ¥ãã®ãããã¿ãªãããããããããï¼ ãããããã¼ã¯å ¨ç¶ã³ãã³ããªãã·ã§ã³ã¨ãè¦ããããªãããã·ã§ã«(bash)ã§è£å®ãã¾ãã£ã¦ãYOï¼
kchashmgrã¨ktremotemgrã ãã ããªãã·ã§ã³ç¶²ç¾ ãã¦ãªããè£å®ã«ã¼ã«ãã¢ã¬ã ãã©ãªã¼ãã³ï¼ã·ã§ã¢ãªãã¤ã³ãã¨ã¬ããã§æ°ã«ãªã人ã¯fork & pushï¼
Nagiosã§æ»æ´»ç£è¦
ãã®ãªã¹ï¼ã¿ããªä½¿ã£ã¦ãããï¼
ãã¼ã¯check_httpã§KTã®HTTP RPCã®echoã«ã¢ã¯ã»ã¹ãã¦ããããªã¢ã¢ã©ã¤ãã®ç£è¦ãã¦ãï¼
define command { command_name check_kyototycoon command_line $USER1$/check_http -I $HOSTADDRESS$ -p $ARG1$ -u /rpc/echo } define service { use critical-service hostgroup_name kt service_description Kyoto Tycoon server health check check_command check_kyototycoon!1975 } define hostgroup { hostgroup_name kt members kt101, kt102 } define host { use service-only host_name kt101 address 10.19.75.1 } define host { use service-only host_name kt102 address 10.19.75.2 }
ã¬ããªã±ã¼ã·ã§ã³ã®å¾©æ§æ¹æ³
ã¡ãã£ã¨åèµ·åãã¡ãã£ã
ãã£ã¹ã¯ãã¼ã¹ã®DB使ã£ã¦ãã¨ãã¯åèµ·åã¯åé¡ãªããã ãã©ãStashDBã¨ããªã³ã¡ã¢ãªDBã使ã£ã¦ãã¨ãã«åèµ·åããã¨ãã¼ã¿æ¶ãã¡ããããï¼ã§ãã¤ã¤ã ããï¼ã©ãï¼
ãããªã¨ãã¯ããã¯ã°ã©ã¦ã³ãã¹ãããã·ã§ãã(èªåã¹ãããã·ã§ãã)ãã¨ãããã«ãã¦ããã°ãã¼ãããã¬ã ãï¼
ktserverã®ãªãã·ã§ã³ã«ã¹ãã·ã§ã®åºåå ãã£ã¬ã¯ããªã®æå®(-bgs)ã¨æ¸ãåºãã®ééç§(-bgsi)ãæå®ãããã±ï¼
ktserverã(å)èµ·åããã¨ãã¯èµ·åããã¨ãã¨åãã-bgsã¨-bgsiãã¤ããã¾ã¾ã§ã¹ã¿ã¼ãï¼ ãããã¨åæãã¼ã¿ã¯ã¹ãã·ã§ããèªã¿ããããã¬ããªã±ã¼ã·ã§ã³ã®ã¿ã¤ã ã¹ã¿ã³ããè¨é²ãã¦ããRTSãã¡ã¤ã«ããã®ã¾ã¾ããã ãããããè½ã¡ã¦ãéã«ã¬ããªã±ã¼ã·ã§ã³ã®ãã¢ã«ãªãããsetã¨ããã¬ãããã¦ãã¼ã¿åæãããï¼
ããã§ã«ã¸ã¥ã¢ã«ã«ãªã¹ã¿ã¼ãã§ãããï¼
ãã«ãã³ããã
KTã¯ãããããã¯ã¢ãããã¨ããYOï¼
ã¬ãã£ã¦ã¦çæ¹ã®ãµã¼ãã®ãã£ã¹ã¯ãæ¨ã£ç«¯å¾®å¡µã«ã¨ã¯ã¹ããã¼ããã¦ãããã¤ãªã¼ã§ãããããã¯ã¢ãããã¨ã£ã¦ããã°ããã®ãã«ãã³ãããæ°ããã¬ããã¢ãããããããã®ã§ããï¼
ãã¤ãªã¼ã§ã¨ã£ã¦ãªãã¦ããçèºç¶æ ã®çãã¦ããktserverããDOKIDOKIããªãããã®å ´ã§ãã«ãã³ãã¨ã£ã¦ããããã©ãï¼
ã ããktserverã«ã¯âã®ããã¥ã¡ã³ãã«ããããã«ã-cmdã¨dbbackupã¹ã¯ãªãããç½®ãã¦ããã®ããã³ããã©ã¼ã²ããï¼
ã¨ãã¦ã§ã¤ããããããã¯ã¢ãããã¨ãã®ã¯ãããªæãã§ã
$ ktremotemgr sync -host kt101 -port 1975 -cmd dbbackup
ã¦ã¼ãã¼ããããããã¯ã®æ令ã¯ãªã¢ã¼ããããçºè¡ã§ãããï¼
ãããããã¯ã¢ãããæåããã¨ããdb.kch.01306840014856000000ãã¨ãããã¡ã¤ã«ããã¼ã³ããããã¡ã¤ã«åã®æ«å°¾ã®ã¡ãã¼ã¡ãã¼ãªãã³ãã¼ã¯ããªã¼ã¤ã³ãã¼ã¿ã³ãã ããããã¤ãªã¼ã§ãã«ãã³ãã¨ã£ã¦å¥ãã¹ãã«ã³ãã¼ãã¦ä¿åããã¨ãã¯ããã®ãã¡ã¤ã«åã®ã¾ã¾ä¿åããããã«ãªï¼
ã§ããã®ãã«ãã³ãã使ã£ã¦ã©ããã£ã¦ãã©ã³ãã¥ã¼ã¬ããã¢ã®ãã¼ã¿ã»ãããä½ãä¸ãããã ãããããªæãã ï¼
# cd /kt/kt101 # cp -p db.kch.01306840014856000000 db.kch # echo 01306840014856000000 > 101.rts # chown kt:kt 101.rts; chmod 644 101.rts
ã¹ãã·ã§ãã¡ã¤ã«ãktserverãæå¾ ããDBãã¡ã¤ã«åã§cpããã®ã¯ããã¨ãã¦ããã½ã¯ã¹ãã·ã§ãã¡ã¤ã«åæ«å°¾ã®ã¡ãã¼ãªãã³ãã¼ã¯ã¹ãã·ã§ãã¨ã£ãæå»ãªã®ã§ããããã¬ããªã±ã¼ã·ã§ã³ãåéããã¿ã¤ã ã¹ã¿ã³ã(rts)ã¨ãã¦ããã¨ãããï¼rtsããªãã¨ããªã¼ã«ãã¼ã¿ãã¬ãããã®ã§æéã¨ãã£ã¹ã¯I/Oãã¡ãã¼çºçããããã¢ãã³ã·ã§ã³ããªã¼ãºãªï¼(ãã®ã¸ãã®æåã¨æé ã®å¦¥å½æ§ã¯ããªãã«ãããèªä¿¡ãªãã§ããâ¦)
ãã¼ã¿ã»ãããã§ãããktserverãã¹ã¿ã¼ãããã°ãï½ã
ãã¨ãã¨ãã¤ã¶ã¦ã§ã¤ããããããã¯ã¢ãããã¨ããã®ã¯ãã£ã¹ã¯ãã¼ã¹ã®DBã使ã£ã¦ãã¨ããªã³ãªã¼ãªï¼ãªã³ã¡ã¢ãªDBã®ã¨ãã¯(DBï¼ãã¡ã¤ã«ï¼ãåå¨ããªãã®ã§)ã¨ããªããï¼
ãããï¼ãã¦ãªKTãªããåè¿°ã®ããã¯ã°ã©ã¦ã³ãã¹ãããã·ã§ããã«ã¹ãã·ã§ä½ææã®ã¿ã¤ã ã¹ã¿ã³ããã¤ã³ã¯ã«ã¼ãããã¦ãããã§ããªã³ã¡ã¢ãªDBã§ãç¡é§ãªã復æ§ãã§ãããï¼è©³ããã¯âãèªãã§ã
kchãã¡ã¤ã«ãæ¶ãã¡ãã£ãï¼ãã£ãâ
ã¢ã«ã¢ã«ï¼ã¢ã«ããï¼ã¡ãã£ã¨æãã¹ãªãããã¡ãã£ã¦KTã®ãã¼ã¿ãã£ã¬ã¯ããªå ¨é¨rm -frãã¡ãã£ããã¨ãï¼
ã¬ãã£ã¦ããã°åè¿°ã®ã¨ããããããããã¯ã¢ãããããã¯ã°ã©ã¦ã³ãã¹ãããã·ã§ãããã復æ§ã§ããã®ã§ãã¼ãããã¬ãï¼
ãªã¼ã«ã¾ã¼ï¼ ã¬ãã£ã¦ãªãã¨ãï¼ ãã§ã¤ã¹ããã«ã¼ã«ãªããï¼ï¼
ãããªã¨ãã¯ã¡ãã£ã¨å¼·å¼ã ãã©ãããªæ¹æ³ã§å¾©å ã§ãããï¼(Linuxéå®)
ã¾ããç´ æ°ãæ°ãã¦å¿ãè½ã¡çãããï¼ã¨ã©ãã¹ããã¹ããµã³ã¯ã¹ï¼ï¼ã次ã«ãktserverã®ããã»ã¹IDã調ã¹ããã
ããã»ã¹IDãåãã£ãããããããã«KTã®å®å¹ã¦ã¼ã¶ãrootã§:
# ls -l /proc/$KT_PID/fd/
ã¼ã³ãktserverã®ããã»ã¹ããªã¼ãã³ãã¦ãããã¡ã¤ã«ã®ãã¡ã¤ã«è¨è¿°å(æ°å)ã¨ãã®å®ãã¡ã¤ã«ã®ãã¹ããªã¹ããããã®ã§ãkchãã¡ã¤ã«ãæ¢ãã¦ãã¡ã¤ã«è¨è¿°åã®ãã³ãã¼ããªã¡ã³ãã¼ï¼(ãã¶ã 3)
ããããã°ï¼ kchashmgrã®copyã³ãã³ãã§ããã£ãã®ãã¡ã¤ã«è¨è¿°åãªãã¡ã¤ã«ãããã¼ã¿ãèªãã§ãã³ãããï¼
# kchashmgr copy -onl /proc/$KT_PID/fd/3 dump.kch
ãªãã³ã¼ã¹ãcopyãã¨ãåã«ã¯ã¯ã©ã¤ã¢ã³ã(ã¢ããªã±ã¼ã·ã§ã³ãµã¼ãã¨ã)ãè½ããããiptablesã§KTã¸ã®ãªã¯ã¨ã¹ãããªã¸ã§ã¯ãããããã¦ãæ´æ°ãããããªãããã«ããã»ããã¢ã¢ãã¿ã¼ã ãï¼
ãããã«
ã¶ãããªã¼ã«ï¼ãããªãã¦ããªKyoto Tycoonãããããããã¦ããã[twitter:@fallabs]ãµã³ã«ããªã¼ãµã³ã¯ã¹ï¼ï¼ã¢ãã£ãªã¹ï¼
ããããã¡ãã£ã¨æä½ãå¤ããã®ã«ãæ°ã¥ãã«ãªãããã§ããããï¼ å·®ãæ¯ããªããã°åå¦ã®ãããããããã»ã³ãã³ã¹ãããããã°ãããé¸æãã¦ã¯ã¦ãªã¹ã¿ã¼ã¤ãã¦ããããã¨å¹¸çã§ãã