按照上一篇文章安裝後,重新開機collectd
/etc/init.d/collectd restart
報錯如下:
ERROR: lt_dlopen ("/opt/collectd/lib/collectd/redis.so") failed: file not found. The most common cause for this problem is missing dependencies. Use ldd(1) to check the dependencies of the plugin / shared object.
Stopping collectd: [ OK ]
Starting collectd: ERROR: lt_dlopen ("/opt/collectd/lib/collectd/redis.so") failed: file not found. The most common cause for this problem is missing dependencies. Use ldd(1) to check the dependencies of the plugin / shared object.
[ OK ]
按照提示有ldd指令來分析:
ldd /opt/collectd/lib/collectd/redis.so
linux-vdso.so.1 => (0x00007fffebdd4000)
libhiredis.so.0.13 => not found
libdl.so.2 => /lib64/libdl.so.2 (0x00007ff213abd000)
libc.so.6 => /lib64/libc.so.6 (0x00007ff213729000)
/lib64/ld-linux-x86-64.so.2 (0x00000032c5600000)
原因很明顯,找不到 libhiredis.so.0.13,它位于hiredis解壓後的目錄中。
把這個檔案複制到對應位置:
cp ../hiredis/libhiredis.so /lib64/libhiredis.so.0.13
再用ldd指令檢視:
ldd /opt/collectd/lib/collectd/redis.so
linux-vdso.so.1 => (0x00007fffb4bff000)
libhiredis.so.0.13 => /lib64/libhiredis.so.0.13 (0x00007f2fe0987000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f2fe0783000)
libc.so.6 => /lib64/libc.so.6 (0x00007f2fe03ee000)
/lib64/ld-linux-x86-64.so.2 (0x00000032c5600000)
依賴已經完整
/etc/init.d/collectd restart
Stopping collectd: [ OK ]
Starting collectd: [ OK ]