在linux4.7上安装net-snmp编译遇到的问题

来源:互联网 发布:pano2vr mac 破解方法 编辑:程序博客网 时间:2024/06/06 23:19

#wget http://nchc.dl.sourceforge.net/sourceforge/net-snmp/net-snmp-5.4.2.1.tar.gz
#cd net-snmp-5.4.2.1
#./configure --prefix=/usr/local/net-snmp --enable-developer
#make   这个时候报错如下:

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包。(第二张光盘里面有)

下载地址:ftp://ftp.wesmo.com/pub/contributed/RPMS/elfutils-libelf-0.76-3.i386.rpm

直接执行命令: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

原创粉丝点击