前幾天主機大爆炸,apachectl stop 時狂噴錯誤訊息:
Fatal error 'Cannot allocate red zone for initial thread' at line 384 in file usr/src/lib/libthr/thread/thr_init.c (errno = 12)
餅乾要我 ldd /usr/local/sbin/httpd,看看會用到哪些 lib:
/usr/local/sbin/httpd:
libm.so.4 => /lib/libm.so.4 (0x280ca000)
libaprutil-1.so.2 => /usr/local/lib/libaprutil-1.so.2 (0x280e0000)
libdb-4.2.so.2 => /usr/local/lib/libdb-4.2.so.2 (0x280f4000)
libexpat.so.6 => /usr/local/lib/libexpat.so.6 (0x281b2000)
libiconv.so.3 => /usr/local/lib/libiconv.so.3 (0x281d2000)
libapr-1.so.2 => /usr/local/lib/libapr-1.so.2 (0x282c6000)
libcrypt.so.3 => /lib/libcrypt.so.3 (0x282e6000)
libpthread.so.2 => /lib/libpthread.so.2 (0x282fe000)
libc.so.6 => /lib/libc.so.6 (0x28323000)
libc.so.7 => /lib/libc.so.7 (0x2840a000)
錯誤原因是因為 kernel 更新以後,卻沒有更新函式庫,所以用到的全部是舊的函式庫,剛好 FreeBSD 6.x to 7.0 東西又改很大,所以倒台很正常。若有大的更新,步驟就不要偷跑,最好按照 Makefile 上的說明一步一步慢慢做:
- make buildworld
- make buildkernel KERNCONF=YOUR_KERNEL_HERE’ (default is GENERIC)
- make installkernel KERNCONF=YOUR_KERNEL_HERE’ (default is GENERIC)
- reboot (in single user mode: boot -s from the loader prompt)
- mergemaster -p
- make installworld
- make delete-old
- mergemaster
- reboot
- make delete-old-libs
最後一個步驟就是把舊的函式庫清除。
清除舊的函式庫以後,其他的套件執行時還是會去使用舊的函式庫,這時就會發生我遇到的錯誤。必須 pkg_delete -af 並重新編譯所有的套件,套件才會連到正確的函式庫。
更新後在 ldd 一次:
/usr/local/sbin/httpd:
libm.so.5 => /lib/libm.so.5 (0x280d2000)
libaprutil-1.so.2 => /usr/local/lib/libaprutil-1.so.2 (0x280e7000)
libdb-4.2.so.2 => /usr/local/lib/libdb-4.2.so.2 (0x280fc000)
libexpat.so.6 => /usr/local/lib/libexpat.so.6 (0x281d0000)
libiconv.so.3 => /usr/local/lib/libiconv.so.3 (0x281f0000)
libapr-1.so.2 => /usr/local/lib/libapr-1.so.2 (0x282e5000)
libcrypt.so.4 => /lib/libcrypt.so.4 (0x28308000)
libthr.so.3 => /lib/libthr.so.3 (0x28321000)
libc.so.7 => /lib/libc.so.7 (0x28334000)