Author Topic: apache , No space left on device: mod_rewrite: could not create rewrite_log_lock  (Read 9211 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
apache , No space left on device: mod_rewrite: could not create rewrite_log_lock
« on: ธันวาคม 13, 2013, 10:22:44 AM »
วันนี้ เจอปัญหา ว่า apache start ไม่ขึ้น แล้วดูจาก log error_log แสดงดังนี้
No space left on device: mod_rewrite: could not create rewrite_log_lock Configuration Failed
เกิดจากตัว apache ไม่สามารถเขียน rewrite log ได้เนื่องจาก space ของบน device เต็ม ครับ

ถ้าลองสั่งให้ start จะเห็นว่าไม่สามารถ start ขึ้นได้
root@roy:/etc/init.d# /etc/init.d/apache2 start
Starting web server (apache2)...Warning: DocumentRoot [/var/www/club.com/holy/htdocs] does not exist
 failed!

ทำการเชค log calling process has read acccess ตัว user apache ขึ้นอยู่กับว่าตอนที่ทำการลง apache application ระบุเป็น user อะไรนะครับ ใส่ให้ถูกด้วย ไม่งั้นจะไม่เจอ
อาจจะเป็น : apache , httpd , www-data , web ก็ใส่ให้ตรงด้วย ของผมเป็น www-data
 
root@roy:/etc/init.d# ipcs -s | grep www-data
0x00000000 37683200   www-data  600        1        
0x00000000 37715969   www-data  600        1        
0x00000000 39354370   www-data  600        1        
0x00000000 39387139   www-data  600        1        
0x00000000 39550980   www-data  600        1        
0x00000000 39583749   www-data  600        1        

ทำการเครียร์ค่า log ดังนี้
#ipcs -s | grep www-data | awk '{print "ipcrm sem " $2}' | sh

#/etc/init.d/apache2 restart
ก็จะใช้งานได้ ปกติครับผม
« Last Edit: ธันวาคม 15, 2013, 10:58:05 AM by golfreeze »

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: apache , No space left on device: mod_rewrite: could not create rewrite_log_lock
« Reply #1 on: เมษายน 23, 2016, 11:44:57 AM »
[root@log httpd]# tail -f error_log
AH00016: Configuration Failed
[Sat Apr 23 04:23:08.000862 2016] [core:emerg] [pid 8301] (28)No space left on device: AH00023: Couldn't create the proxy mutex
[Sat Apr 23 04:23:08.001035 2016] [proxy:crit] [pid 8301] (28)No space left on device: AH02478: failed to create proxy mutex
AH00016: Configuration Failed
[Sat Apr 23 04:24:02.000742 2016] [core:emerg] [pid 8625] (28)No space left on device: AH00023: Couldn't create the proxy mutex
[Sat Apr 23 04:24:02.000934 2016] [proxy:crit] [pid 8625] (28)No space left on device: AH02478: failed to create proxy mutex
AH00016: Configuration Failed
[Sat Apr 23 04:24:08.000923 2016] [core:emerg] [pid 8651] (28)No space left on device: AH00023: Couldn't create the proxy mutex
[Sat Apr 23 04:24:08.001127 2016] [proxy:crit] [pid 8651] (28)No space left on device: AH02478: failed to create proxy mutex
AH00016: Configuration Failed


เกิดจากตัว httpd ไม่สามารถติดต่อสื่อสารกับตัว child process ของมันได้ เนื่องจาก มีการเปิดการใช้งานถึง limit ที่ตั้งไว้
ทำการเชคได้โดย

#ipcs -s
0x00000000 37683200   www-data  600        1         
0x00000000 37715969   www-data  600        1         
0x00000000 39354370   www-data  600        1         
0x00000000 39387139   www-data  600        1         
0x00000000 39550980   www-data  600        1         
0x00000000 39583749   www-data  600        1

หลังจากทราบแล้วทำการเครียร์ได้โดย
#for i in `ipcs -s | awk '/httpd/ {print $2}'`; do (ipcrm -s $i); done

หรือถ้ายังไม่ออก

#ipcs -s | grep httpd | awk '{print "ipcrm sem " $2}' | sh

หรือสามารถปรับขยาย limitในส่วนของ sysctl ของ OS ได้ครับผม
kernel.msgmni = 1024
kernel.sem = 250 256000 32 1024

ให้ค่าใหม่เริ่มทำงาน มันเพิ่มขนาดของตัว msgmni เพิ่มขึ้นครับ
#sysctl -p

#/etc/init.d/httpd restart
ก็จะเข้าใช้งานเว็บได้ปกติครับผม
« Last Edit: พฤษภาคม 11, 2017, 12:36:18 AM by golfreeze »

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: apache , No space left on device: mod_rewrite: could not create rewrite_log_lock
« Reply #2 on: กุมภาพันธ์ 21, 2019, 12:42:38 PM »
หรือสามารถเขียนเป็น shell script ให้รันทุกวัน ได้นะครับเพื่อทำการเครียร์  apache semaphores

cd /etc/cron.daily
vi ipcs_check

#!/bin/sh

EMAIL=your@email.com
MAX_SEMAPHORES=15

IPCS=/usr/bin/ipcs
IPCRM=/usr/bin/ipcrm
MAIL=/bin/mail

COUNT=`${IPCS} | grep apache | wc -l`

if [ "$COUNT" -le $MAX_SEMAPHORES ]; then
       #all is well, there are no semaphore build-ups.
       exit 0;
fi

#we have more than MAX_SEMAPHORES, so clear them out and restart Apache.

LIST=/root/sem.txt

${IPCS} | grep apache | awk '{print $2}' > ${LIST}
for i in `cat ${LIST}`; do
{
       ${IPCRM} -s $i;
};
done;

/etc/init.d/httpd restart

TXT="${COUNT} semaphores cleared for apache for `hostname`"
echo "${TXT}" | ${MAIL} -s "${TXT}" ${EMAIL}

exit 1;

แล้วทำการปรับสิทธิ์ให้ execute ได้
chmod 755 ipcs_check
./ipcs_check

ถ้าจะไม่ให้ส่งเมลก็ comment
#echo "${TXT}" | ${MAIL} -s "${TXT}" ${EMAIL}
ด้วยนะครับ