Linux snmp服务安装配置

1.安装net-snmp

将压缩包解压缩到linux服务器上

   //解压

tar –zxvf net-snmp-5.1.0.tar.gz 

 //进入源文件目录

cd net-snmp-5.1.0

//配置 安装目录

./configure --prefix=/usr/net-snmp           

配置中会出这样的提示:(第一个需要改成2,其他默认回车)
default version of-snmp-version: 2

Systemcontact information(配置该设备的联系人): VRS

System location (该设备的位置): China

Location to write logfile (日志文件位置): /var/log/snmpd.log

Location to Write persistent(数据存储目录): /var/net-snmp

 

//编译并且安装

make                                                        

//编译并且安装

make install                                                 

将准备好的snmpd.conf文件拷贝到这个目录下/usr/net-snmp/share/snmp/snmpd.conf

2.启动net-snmp

/usr/net-snmp/sbin/snmpd -c /usr/net-snmp/share/snmp/snmpd.conf &

//启动SNMP服务

vi /etc/rc.local       

进入启动配置文件,在文本末尾加上/usr/net-snmp/sbin/snmpd -c /usr/net-snmp/share/snmp/snmpd.conf &

//配置SNMP自启动

自动化配置脚本:

#/bin/bash

echo "--------------------------------------------------------------------------------" >>/tmp/install_snmp.log
echo "---------------------------------start install snmp-----------------------------" >>/tmp/install_snmp.log
echo "--------------------------------------------------------------------------------" >>/tmp/install_snmp.log

date=`date +%c`
echo $date >>/tmp/install_snmp.log
echo -e >>/tmp/install_snmp.log

yum install perl-ExtUtils-MakeMaker -y

cd /tmp/
[ -f net-snmp-5.4.3.tar.gz ] || wget  http://xxx/snmp/net-snmp-5.4.3.tar.gz

tar -zxvf net-snmp-5.4.3.tar.gz
cd /tmp/net-snmp-5.4.3/

echo "
2

China


"|./configure --prefix=/usr/net-snmp  >>/tmp/install_snmp.log

make && make install  >>/tmp/install_snmp.log

[ -f /usr/net-snmp/share/snmp/snmpd.conf ] || wget  -P /usr/net-snmp/share/snmp/  http://xxxx/soft/snmpd.conf

/usr/net-snmp/sbin/snmpd  -c /usr/net-snmp/share/snmp/snmpd.conf&

echo -e "/usr/net-snmp/sbin/snmpd  -c /usr/net-snmp/share/snmp/snmpd.conf& "  >> /etc/rc.local


 

你可能感兴趣的:(Linux,Shell)