éå§
ãã¹ãã£ã³ã°ã¯ãå žåçãªLinux + Apache + Mysql + PHPã¹ã¿ãã¯ãšç®¡çã©ãããŒããŠãŒã¶ãŒã«æäŸããŸããç§ãã¡ã®å Žåãããã¯CloudLinuxã«å€æãããCentos 7ã«åºã¥ãISP Manager 5ããžãã¹ã§ãã CloudLinuxã¯ã管çåŽãããå¶éã管çããããã®ããŒã«ãšãããŸããŸãªæäœã¢ãŒãïŒCGIãFastCGIãLSAPIïŒãåããPHPã»ã¬ã¯ã¿ãŒãæäŸããŸãã
ä»åãã¯ã©ã€ã¢ã³ããã以äžã®åé¡ããããŸããã Wordpressãšã³ãžã³äžã®åœŒã®ãµã€ãã¯å®æçã«503ãšã©ãŒãåºãå§ããŸããã
50xã§å§ãŸãå¿çã³ãŒãã¯ããµãŒããŒåŽã®åé¡ãåç §ããŠããŸãããããã¯ããµã€ãèªäœãšããããæäŸããWebãµãŒããŒã®äž¡æ¹ã®åé¡ã§ããå¯èœæ§ããããŸãã
次ã®ãšã©ãŒã衚瀺ãããäžè¬çãªç¶æ³ïŒ
- 500å éšãµãŒããŒãšã©ãŒ-å€ãã®å Žåããµã€ãã³ãŒãã®æ§æãšã©ãŒããã©ã€ãã©ãªãèŠã€ãããªããããµããŒããããŠããªãPHPããŒãžã§ã³ã§ãããŸãããµã€ãããŒã¿ããŒã¹ãžã®æ¥ç¶ã«åé¡ããããããã¡ã€ã«/ãã£ã¬ã¯ããªã®äžæ£ãªæš©éãããå¯èœæ§ããããŸã
- 502äžæ£ãªã²ãŒããŠã§ã€-ããšãã°ãNginxãééã£ãApacheãŠã§ããµãŒããŒããŒããåç §ããŠããå ŽåããŸãã¯Apacheããã»ã¹ãäœããã®çç±ã§åäœãåæ¢ããå Žå
- 504ã²ãŒããŠã§ã€ã¿ã€ã ã¢ãŠã-Apacheããã®å¿çãWebãµãŒããŒæ§æã§æå®ãããæéå ã«åä¿¡ãããŸããã§ãã
- 508ãªãœãŒã¹å¶éã«éããŸãã-ãŠãŒã¶ãŒã«å²ãåœãŠããããªãœãŒã¹ã®å¶éãè¶ ããŸãã
ãã®ãªã¹ãã«ã¯ãæãäžè¬çãªã±ãŒã¹ã®äžéšã®ã¿ãå«ãŸããŠããŸãããŸããå¶éãè¶ ãããšããŠãŒã¶ãŒã¯500ãšã©ãŒãš503ãšã©ãŒã®äž¡æ¹ãåãåãå¯èœæ§ãããããšã«ã泚æããŠãã ããã
ãããã®ãšã©ãŒã蚺æããå Žåãæåã®ã¹ãããã¯WebãµãŒããŒã®ãã°ã確èªããããšã§ããããã¯éåžžãåå ãç¹å®ããŠåé¡ã解決ããã®ã«ååã§ãã
ãã®å Žåã®503ãšã©ãŒã«é¢ããŠã¯ããã°ã«ãšã³ããªã衚瀺ãããŸããã
[lsapiïŒãšã©ãŒ] [pid 49817] [ã¯ã©ã€ã¢ã³ãxxxxïŒ6801] [ãã¹ãXXX.XX]ãªã¯ãšã¹ãéä¿¡æã®ãšã©ãŒïŒGET /index.php HTTP / 1.0ïŒ; uriïŒ/index.phpïŒcontent-lengthïŒ0ïŒïŒReceiveAckHdrïŒããã¯ãšã³ãããèªã¿åããã®ã¯äœããããŸããïŒLVE ID 8514ïŒãdocs.cloudlinux.com/ mod_lsapi_troubleshooting.htmlã確èªããŠãã ãããã®ãã°ã®ã¿ã«åºã¥ããŠãåé¡ãäœã§ããããå€å¥ããããšã¯ã§ããŸããã§ããã
äžæ¬¡èšºæ
æåã«ãå¶éãè¶ ãããŠãŒã¶ãŒã®çµ±èšããã§ãã¯ããŸãããåæ¥ã®ããããªè¶ éãèšé²ãããŸãããããã°ã®ãšã©ãŒã¯æ°é®®ã§ãããã«ã1ãæ°åééã§ãã°ã«è¡šç€ºãããŸããã
ãšã©ãŒãã°ã§æäŸããããªã³ã¯ã䜿çšããŠãCloudLinuxã®æšå¥šäºé ã«ã€ããŠã調æ»ããŸããã
ãã©ã¡ãŒã¿ãå€æŽããŠãçµæã¯åŸãããŸããã§ããã
ãµã€ãã¯ãDockerã³ã³ãããŒå ã®åããµãŒããŒäžã§å®è¡ãããMysql 5.7ãµãŒããŒäžã®ããŒã¿ããŒã¹ã䜿çšããŸãããã³ã³ãããã°ã«å«ãŸããã¡ãã»ãŒãžïŒ
[Note] Aborted connection 555 to db: 'dbname' user: 'username' host: 'x.x.x.x' (Got an error reading communication packets)
ãããã®ã¡ãã»ãŒãžã®äžã«ã¯ã調æ»äžã®ãµã€ãã®æ¥ç¶ã®äžæã«é¢ããã¡ãã»ãŒãžãå«ãŸããŠããŸãããããã¯ãDBMSãžã®æ¥ç¶ãæ£ããå®è¡ãããŠããªãããšãåæãšããŠããŸããããã確èªããããã«ããµã€ãã®ã³ããŒããã¹ããã¡ã€ã³ã«å±éãããµã€ãããŒã¿ããŒã¹ã5.5.65-MariaDB DBMSã®ãã€ãã£ãCentos 7ããŒãžã§ã³ã«å€æããŸããããã¹ããµã€ãã§ã¯ãcurlãŠãŒãã£ãªãã£ã䜿çšããŠæ°çŸã®ãªã¯ãšã¹ããå®è¡ãããŸããããšã©ãŒãåçŸã§ããŸããã§ããããããããã®çµæã¯æ«å®çãªãã®ã§ãããæ¬çªãµã€ãã§ããŒã¿ããŒã¹ãå€æããåŸãåé¡ã¯æ®ããŸããã
ãããã£ãŠãDBMSãžã®èª€ã£ãæ¥ç¶ã®åé¡ã解æ¶ãããŸããã
次ã®ææ¡ã¯ããµã€ãèªäœã«åé¡ããããã©ããã確èªããããšã§ããããããè¡ãã«ã¯ãå¥ã®ä»®æ³ãµãŒããŒãã»ããã¢ãããããã®äžã§æãé¡äŒŒããç°å¢ãäœæããŸãããå¯äžã®å€§ããªéãã¯ãCloudLinuxããªãããšã§ãããã¹ããµãŒããŒã§åé¡ãåçŸã§ããŸããã§ããããããã£ãŠããµã€ãã³ãŒãã§ã¯ãã¹ãŠãæ£ãããšå€æããŸããããã ããåãæ¹æ³ã§Wordpressãã©ã°ã€ã³ãç¡å¹ã«ããããšããŸããããåé¡ã¯è§£æ±ºããŸããã§ããã
ãã®çµæãåé¡ã¯ãã¹ãã£ã³ã°ã«ãããšããçµè«ã«éããŸããã
ä»ã®ãµã€ãã®ãã°ãåæããåŸãåé¡ããããã®å€ãã§èŠ³å¯ãããŠããããšãããããŸãããçŽ100åæ€èšŒæïŒ
/var/www/httpd-logs# grep -Rl "ReceiveAckHdr: nothing to read from backend" ./ | wc -l
99
ãã¹ãäžã«ãæ°ããã€ã³ã¹ããŒã«ãããã¯ãªãŒã³ãªCMS Wordpressã§ãå®æçã«ãšã©ãŒ503ãçºçããããšãããããŸããã
ãã®çŽ2ãæåã«ããµãŒããŒã®è¿ä»£åã«é¢ããäœæ¥ãå®è¡ããŸãããç¹ã«ãPHPã䜿çšã§ããããã«ãApacheã®åäœã¢ãŒããWorkerããPreforkã«å€æŽããŸãããé ãCGIã§ã¯ãªãLSAPIãããã圱é¿ããå¯èœæ§ãããããŸãã¯è¿œå ã®Apacheèšå®ãå¿ èŠã§ãããšããæ³å®ããããŸããããã¯ãŒã«ãŒã¢ãŒããæ»ãããšãã§ããŸããã§ããã Apacheåäœã¢ãŒãã®å€æŽäžã«ããã¹ãŠã®ãµã€ãæ§æãå€æŽãããŸããããã»ã¹ã¯é«éã§ã¯ãªãããã¹ãŠãã¹ã ãŒãºã«é²ããšã¯éããŸããã
Apacheèšå®ãä¿®æ£ããŠããæãŸããçµæãåŸãããŸããã§ããã
ãã®éçšã§ãæ€çŽ¢ãšã³ãžã³ã§åæ§ã®åé¡ãæ¢ããŸããããã©ãŒã©ã ã®1ã€ã§ãåå è ã¯ãã¹ãã£ã³ã°æ¥è ã«åé¡ããããåé¡ã解決ããªãå Žåã¯å€æŽããå¿ èŠããããšäž»åŒµããŸãããå察åŽã«ãããšãã¯æ¥œèŠ³çã«èãããŸããããã¯ã©ã€ã¢ã³ãã¯ç解ã§ããŸãããªã圌ã¯é皌åãã¹ãã£ã³ã°ãå¿ èŠãšããã®ã§ããïŒ
ãã®æ®µéã§ãå©çšå¯èœãªæ å ±ãšå®è¡ãããäœæ¥ã®çµæãåéããŸãããCloudLinuxããµããŒãããããã«åœŒãã«é£çµ¡ããŸããã
詳现ãªèšºæ
æ°æ¥éãCloudLinuxãµããŒãã¹ã¿ããããã®åé¡ã詳ãã調æ»ããŸãããåºæ¬çã«ãæšå¥šäºé ã¯ç¢ºç«ããããŠãŒã¶ãŒå¶éã«é¢ãããã®ã§ããããã®è³ªåããã§ãã¯ããŸãããå¶éãç¡å¹ã«ããŠïŒãŠãŒã¶ãŒã®CageFSãªãã·ã§ã³ïŒãApacheã¢ãžã¥ãŒã«ãšããŠPHPã¢ãŒãã§å¶éãæå¹ã«ãããšãåé¡ã¯èŠ³å¯ãããŸããã§ãããããã«åºã¥ããŠãCloudLinuxãäœããã®åœ¢ã§åœ±é¿ããŠããããšã瀺åãããŠããŸãããã®çµæãé±ã®çµãããŸã§ã«ãªã¯ãšã¹ãã¯ç¬¬3ã¬ãã«ã®ãµããŒãã«ãšã¹ã«ã¬ãŒããããŸãããããŸã 解決çã¯ãããŸããã§ããã
ãã®éçšã§ãCGIããã³LSAPIã¢ãŒãã«é¢ããApacheã®ããã¥ã¡ã³ãã調æ»ãããã¹ãã£ã³ã°ãµãŒããŒã®ãã¹ããµã€ãã®ããå¥ã®ããŒãã«2ã€ç®ã®Apacheã€ã³ã¹ã¿ã³ã¹ãã»ããã¢ããããApacheã«ãªã¯ãšã¹ããçŽæ¥éä¿¡ããŠåããšã©ãŒã³ãŒããåä¿¡ããããšã«ãããNginxã®åœ±é¿ãæé€ããŸããã
ïŒLSAPIã®ããã¥ã¡ã³ãã¯ãã¡ããã©503ãšã©ãŒã®èšºæã«ãå°é¢ããªãã«ååŸããããã«å©ãã
www.litespeedtech.com/support/wiki/doku.php/litespeed_wikiïŒPHPïŒ503-ãšã©ãŒ
é«åºŠãªãã©ãã«ã·ã¥ãŒãã£ã³ã°ã®ã»ã¯ã·ã§ã³ã§ã¯ãããã»ã¹ããã¬ãŒã¹ããããšãææ¡ãããŠããã·ã¹ãã ã§èŠã€ãããŸããïŒ
while true; do if mypid=`ps aux | grep $USERNAME | grep lsphp | grep $SCRIPTNAME | grep -v grep | awk '{print $2; }' | tail -1`; then strace -tt -T -f -p $mypid; fi ; done
ãã®ã³ãã³ãã¯ããã¹ãŠã®ããã»ã¹ããã®èå¥åãšãšãã«ãã¡ã€ã«ã«èšé²ããããã«æ¹è¯ãããŸããã
ãã¬ãŒã¹ãã¡ã€ã«ãèŠããšãåãè¡ãããã€ã衚瀺ãããŸãã
cat trace.* | tail
...
47307 21:33:04.137893 --- SIGHUP {si_signo=SIGHUP, si_code=SI_USER, si_pid=42053, si_uid=0} ---
47307 21:33:04.140728 +++ killed by SIGHUP +++
...
ããã»ã¹ã«ãã£ãŠéä¿¡ãããã·ã°ãã«ã®æ§é ã®èª¬æãèŠããšã
pid_t si_pid; /* Sending process ID */
ã·ã°ãã«ãéä¿¡ããããã»ã¹ã®èå¥åã瀺ããŸãã
ãã¬ãŒã¹ã調æ»ããæç¹ã§ã¯ãPID 42053ã®ããã»ã¹ã¯ã·ã¹ãã ã«ååšããªãããããã¬ãŒã¹ããã£ããã£ããããã»ã¹ã§ã¯ãSIGHUPä¿¡å·ãéä¿¡ããããã»ã¹ãç£èŠããããšã«ããŸããã
ã¹ãã€ã©ãŒã®äžã§ããããã©ã®ãããªããã»ã¹ã§ããããå€å¥ãããã®ãã¬ãŒã¹ãšãSIGHUPã·ã°ãã«ãéä¿¡ããããã»ã¹ã«é¢ããè¿œå æ å ±ãååŸã§ããããã«ããã¢ã¯ã·ã§ã³ã説æãããŠããŸãã
ãã¬ãŒã¹ãã¯ããã¯
ã³ã³ãœãŒã«1ã
ã³ã³ãœãŒã«2ã
ã³ã³ãœãŒã«3ã
4.
1 , 4 503, 4.
tail -f /var/www/httpd-logs/sitename.error.log
ã³ã³ãœãŒã«2ã
while true; do if mypid=`ps aux | grep $USERNAME | grep lsphp | grep "sitename" | grep -v grep | awk '{print $2; }' | tail -1`; then strace -tt -T -f -p $mypid -o /tmp/strace/trace.$mypid; fi ; done
ã³ã³ãœãŒã«3ã
while true; do if mypid=`cat /tmp/strace/trace.* | grep si_pid | cut -d '{' -f 2 | cut -d'=' -f 4 | cut -d',' -f 1`; then ps -aux | grep $mypid; fi; done;
4.
seq 1 10000 | xargs -i sh -c "curl -I http://sitename/"
1 , 4 503, 4.
ãã®çµæãããã»ã¹ã®ååããããã
/opt/alt/python37/bin/python3.7 -sbb /usr/sbin/cagefsctl --rebuild-alt-php-ini
ãã®ããã»ã¹ã¯ã·ã¹ãã ã§1åã«1åå®è¡ãããŸããã
ããã€ãã®cagefsctlããã»ã¹ããã¬ãŒã¹ããŠãæåããæåŸãŸã§å°ãªããšã1ã€ããã¬ãŒã¹ããŸãã
for i in `seq 1 100`; do strace -p $(ps ax | grep cagefsctl | grep rebuild-alt-php-ini | grep -v grep | awk '{print $1}') -o /tmp/strace/cagefsctl.trace.$(date +%s); done;
次ã«ãç§ãã¡ã¯åœŒãäœããããã調ã¹ãŸããäŸãã°ïŒ
cat /tmp/strace/cagefsctl.trace.1593197892 | grep SIGHUP
SIGHUPã·ã°ãã«ã§çµäºããããã»ã¹IDãååŸãããŸãããçµäºããããã»ã¹ã¯ãçŸåšå®è¡äžã®PHPããã»ã¹ã§ãã
åä¿¡ããããŒã¿ã¯ããã®ããã»ã¹ã®æ£åœæ§ãšããã®ãããªé »åºŠã§åäœãããã©ãããæ確ã«ããããã«ãCloudLinuxãµããŒãã«è»¢éãããŸããã
ãã®åŸãããŒã ã®äœæ¥
/usr/sbin/cagefsctl --rebuild-alt-php-ini
ãæ£ããè¡ãããŠãããšããåçãåãåããŸããããå¯äžã®æ³šæç¹ã¯ãããŒã ãé »ç¹ã«å®è¡ãããŠããããšã§ããéåžžãã·ã¹ãã ã¢ããããŒããŸãã¯PHPèšå®ãå€æŽããããšãã«åŒã³åºãããŸãã
ãã®å Žåã®å¯äžã®ææããã¯ãcagefsctlããã»ã¹ã®èŠªã誰ã§ãããã確èªããããšã§ãã
çµæã¯éããªãã§ãç§ãã¡ãé©ããããšã¯äœã§ãããcagefsctlã®èŠªããã»ã¹ã¯ispmgrnodeããã»ã¹ã§ãããISPãããŒãžã£ãŒã®ãã°ã¬ãã«ãæ倧ã«èšå®ãããŠããŠãcaspfsctlåŒã³åºããispmgr.logã«è¡šç€ºãããŠããªãã£ããããå°ãå¥åŠã§ããã
ããã§ãISPã·ã¹ãã ãµããŒãã«é£çµ¡ããã®ã«ååãªããŒã¿ãæããŸããã
æŠèŠ
ãã®åé¡ã¯ãISPãããŒãžã£ãŒã®ã¢ããããŒããå®è¡ããåŸã«ããªã¬ãŒãããŸãããäžè¬ã«ãISPãããŒãžã£ãŒã®æŽæ°ã¯éåžžã®ç¶æ³ã§ãããåæããã»ã¹ãéå§ããããšã©ãŒã§çµäºããæ¯ååèµ·åãããŸãããåæããã»ã¹ã«ãããCagefsctlããã»ã¹ãåŒã³åºãããPHPããã»ã¹ãçµäºããŸããã
åæããã»ã¹ã®ãã³ã°ã¢ããã®çç±ã¯ãæ©åšãææ°åããããã«ãã¹ãã£ã³ã°ã§å®è¡ãããäœæ¥ã§ãããåé¡ãçºçããæ°ãæåã«ãPCI-e NVMeãã©ã€ãããµãŒããŒã«ã€ã³ã¹ããŒã«ãããXFSããŒãã£ã·ã§ã³ãäœæããã/ varãã£ã¬ã¯ããªã«ããŠã³ããããŸããããŠãŒã¶ãŒã®ãã¡ã€ã«ãããã«è»¢éãããŸãããããã£ã¹ã¯ã¯ã©ãŒã¿ã¯æŽæ°ãããŸããã§ãããããŠã³ããªãã·ã§ã³ã¯ååã§ã¯ãªããISP Managerãã©ã¡ãŒã¿ã®ãã¡ã€ã«ã·ã¹ãã ã¿ã€ããå€æŽããå¿ èŠããããŸãããã³ãã³ããåŒã³åºããŠãã£ã¹ã¯ã¯ã©ãŒã¿ãæŽæ°ããŸããExt4ãšXFSã®å Žåããããã®ã³ãã³ãã¯ç°ãªããŸãã
ãããã£ãŠãåé¡ã¯äœæ¥ã®æ°ãæåŸã«æããããŸããã
çµè«
ç§ãã¡èªèº«ãåé¡ãäœæããŸããããæåŸã®ç¬éãŸã§æ確ã§ã¯ãããŸããã§ãããå°æ¥çã«ã¯ãã§ããã ãå€ãã®ãã¥ã¢ã³ã¹ãèæ ®ã«å ¥ããããåªããŸããCloudLinuxãšISPã·ã¹ãã ãµããŒããããã¬ãŒãã³ã°ãåããååã®å©ããåããŠãåé¡ã¯è§£æ±ºããŸãããçŸåšããã¹ãã£ã³ã°ã¯å®å®ããŠããŸãããããŠãç§ãã¡ã¯å°æ¥ã®ä»äºã«åœ¹ç«ã€ã§ãããçµéšãç©ãã§ããŸãã
PSïŒç§ã¯ããªããèšäºãèªãããšã«èå³ãæã£ãŠããã°å¹žãã§ãããããŠããã誰ããåæ§ã®åé¡ãçŽ æ©ã解決ããã®ãå©ããã§ãããã