1. 程式人生 > >在linux4.7上安裝net-snmp編譯遇到的問題

在linux4.7上安裝net-snmp編譯遇到的問題

grep: /usr/lib/libbeecrypt.la: No such file or directory
/bin/sed: can't read /usr/lib/libbeecrypt.la: No such file or directory
libtool: link: `/usr/lib/libbeecrypt.la' is not a valid libtool archive
make[1]: *** [libnetsnmpmibs.la] 錯誤 1
make[1]: Leaving directory `/usr/local/src/net-snmp-5.4.2.1/agent'
make: *** [subdirs] 錯誤 1


解決方法
說明缺少libbeecrypt.la ,libbeecrypt.so等共享庫
如果確認系統中有libbeecrypt.la,也許他安裝在/usr/local下面,可嘗試:
ln -s /usr/local/lib/libbeecrypt.la /usr/lib/libbeecrypt.la
如果/usr/local下面沒有,那麼你必須安裝beecrypt
下載路徑
http://down1.chinaunix.net/distfiles/beecrypt-4.1.2.tar.gz
解壓並安裝到/usr目錄下:
tar -zxvf beecrypt-4.1.2.tar.gz
./configure -prefix=/usr
#預設是安裝在/usr/local,我們需要安裝在/usr目錄下。如果沒有加這個引數需要做連線
ln -s /usr/local/lib/libbeecrypt.la /usr/lib/libbeecrypt.la
編譯並安裝beecrypt庫,先執行make編譯原始碼包檔案編譯成功後執行安裝命令make install,其命令如下:
#make
#make install
好,beecrypt安裝完成後,我們繼續NET-SNMP的編譯,結果又報錯如下:


/usr/bin/ld: cannot find -lelf
collect2: ld returned 1 exit status
make[1]: *** [snmpd] 錯誤 1
make[1]: Leaving directory `/usr/local/src/net-snmp-5.4.2.1/agent'
make: *** [subdirs] 錯誤 1


解決方法:

說明缺少libelf.so,如果系統已經安裝,只需使用西面命令就好了:

ln -s /usr/lib/libelf.so.1   /usr/lib/libelf.so


如果在/usr/lib下面找不到libelf.so.1檔案的話,需下載安裝-libelf包。(第二張光盤裡面有)

直接執行命令:rpm -ivh    elfutils-libelf-0.76-3.i386.rpm

ok !在去執行net-snmp的make,沒有報錯了,哈哈!!

繼續:make install

#cp EXAMPLE.conf /usr/local/net-snmp/share/snmp/snmpd.conf

#/usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmpd.conf   //啟動snmp服務

netstat -an |grep 161 //檢視snmp是否啟動


在/etc/rc.local裡面新增
/usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmpd.conf
snmp服務就會開機啟動。


測試:#snmpwalk -v 2c -c zjhcsoft 127.0.0.1 if

如果有資料返回沒問題

如果顯示超時,那就需要重啟伺服器

-----------------------------------------------------------------------------------------------

如果伺服器利用rpm包安裝,配置net-snmp如下:

1#vi /etc/snmp/snmpd.conf

更改

com2sec notConfigUser default public

改為

com2sec notConfigUser 127.0.0.1 zjhcsoft(團體名為zjhcsoft)

2、更改

access notConfigGroup "" any noauth exact systemview none none

改為

access notConfigGroup "" any noauth exact all none none

3 #view all included .1 80

將前面的 # 註釋去掉。儲存退出

上面這幾個地方很重要,注意了,不然得不到資料

然後重啟服務

#service snmpd restart

#service snmptrapd start

同時執行setup,把這兩個伺服器加入自啟動。

#snmpwalk -c zjhcsoft -v 2c 127.0.0.1