AWS 主机 centos snmp安装配置

20 篇文章 0 订阅

CentOS上配置这个可比SUSE上浪费的时间多多了。
1.先安装snmp组件
[root@nfsnode1 ~]# yum install -y net-snmp
出现一大堆错误。
Error downloading packages:
  1:perl-Pod-Simple-3.28-4.el7.noarch: [Errno 256] No more mirrors to try.
  lm_sensors-libs-3.4.0-6.20160601gitf9185e5.el7.x86_64: [Errno 256] No more mirrors to try.
  perl-File-Path-2.09-2.el7.noarch: [Errno 256] No more mirrors to try.
  perl-Time-Local-1.2300-2.el7.noarch: [Errno 256] No more mirrors to try.
  perl-Encode-2.51-7.el7.x86_64: [Errno 256] No more mirrors to try.
  perl-Socket-2.010-4.el7.x86_64: [Errno 256] No more mirrors to try.
  perl-Text-ParseWords-3.29-4.el7.noarch: [Errno 256] No more mirrors to try.
  4:perl-libs-5.16.3-293.el7.x86_64: [Errno 256] No more mirrors to try.
原因是因为以前缓存的软件源无效,使用命令清理
[root@nfsnode2 ~]# yum clean all
清理后再安装snmp成功了。
Dependency Installed:
  lm_sensors-libs.x86_64 0:3.4.0-8.20160601gitf9185e5.el7        net-snmp-agent-libs.x86_64 1:5.7.2-48.el7_8.1        net-snmp-libs.x86_64 1:5.7.2-48.el7_8.1             perl.x86_64 4:5.16.3-295.el7                
  perl-Carp.noarch 0:1.26-244.el7                                perl-Data-Dumper.x86_64 0:2.145-3.el7                perl-Encode.x86_64 0:2.51-7.el7                     perl-Exporter.noarch 0:5.68-3.el7           
  perl-File-Path.noarch 0:2.09-2.el7                             perl-File-Temp.noarch 0:0.23.01-3.el7                perl-Filter.x86_64 0:1.49-3.el7                     perl-Getopt-Long.noarch 0:2.40-3.el7        
  perl-HTTP-Tiny.noarch 0:0.033-3.el7                            perl-PathTools.x86_64 0:3.40-5.el7                   perl-Pod-Escapes.noarch 1:1.04-295.el7              perl-Pod-Perldoc.noarch 0:3.20-4.el7        
  perl-Pod-Simple.noarch 1:3.28-4.el7                            perl-Pod-Usage.noarch 0:1.63-3.el7                   perl-Scalar-List-Utils.x86_64 0:1.27-248.el7        perl-Socket.x86_64 0:2.010-5.el7            
  perl-Storable.x86_64 0:2.45-3.el7                              perl-Text-ParseWords.noarch 0:3.29-4.el7             perl-Time-HiRes.x86_64 4:1.9725-3.el7               perl-Time-Local.noarch 0:1.2300-2.el7       
  perl-constant.noarch 0:1.27-2.el7                              perl-libs.x86_64 4:5.16.3-295.el7                    perl-macros.x86_64 4:5.16.3-295.el7                 perl-parent.noarch 1:0.225-244.el7          
  perl-podlators.noarch 0:2.5.1-3.el7                            perl-threads.x86_64 0:1.87-4.el7                     perl-threads-shared.x86_64 0:1.43-6.el7            

Complete!

2.查看安装的版本,检查是否成功
[root@nfsnode1 ~]# snmpd -v
NET-SNMP version:  5.7.2
Web:               http://www.net-snmp.org/
Email:             net-snmp-coders@lists.sourceforge.net

3.使用snmpconf配置
配置snmp
[root@nfsnode1 ~]# snmpconf -i

The following installed configuration files were found:

   1:  /etc/snmp/snmpd.conf
   2:  /etc/snmp/snmptrapd.conf

Would you like me to read them in?  Their content will be merged with the
output files created by this session.

Valid answer examples: "all", "none","3","1,2,5"

Read in which (default = all): all

I can create the following types of configuration files for you.
Select the file type you wish to create:
(you can create more than one as you run this program)

   1:  snmpd.conf
   2:  snmptrapd.conf
   3:  snmp.conf

Other options: quit

Select File: 1

The configuration information which can be put into snmpd.conf is divided
into sections.  Select a configuration section for snmpd.conf
that you wish to create:

   1:  Access Control Setup
   2:  Extending the Agent
   3:  Monitor Various Aspects of the Running Host
   4:  Agent Operating Mode
   5:  System Information Setup
   6:  Trap Destinations

Other options: finished

Select section: 1

Section: Access Control Setup
Description:
  This section defines who is allowed to talk to your running
  snmp agent.

Select from:

   1:  a SNMPv3 read-write user
   2:  a SNMPv3 read-only user
   3:  a SNMPv1/SNMPv2c read-only access community name
   4:  a SNMPv1/SNMPv2c read-write access community name

Other options: finished, list

Select section: 3

Configuring: rocommunity
Description:
  a SNMPv1/SNMPv2c read-only access community name
    arguments:  community [default|hostname|network/bits] [oid]

The community name to add read-only access for: mysnmp
The hostname or network address to accept this community name from [RETURN for all]: 
The OID that this community should be restricted to [RETURN for no-restriction]: 

Finished Output: rocommunity   mysnmp  

Section: Access Control Setup
Description:
  This section defines who is allowed to talk to your running
  snmp agent.

Select from:

   1:  a SNMPv3 read-write user
   2:  a SNMPv3 read-only user
   3:  a SNMPv1/SNMPv2c read-only access community name
   4:  a SNMPv1/SNMPv2c read-write access community name

Other options: finished, list

Select section: finished

The configuration information which can be put into snmpd.conf is divided
into sections.  Select a configuration section for snmpd.conf
that you wish to create:

   1:  Access Control Setup
   2:  Extending the Agent
   3:  Monitor Various Aspects of the Running Host
   4:  Agent Operating Mode
   5:  System Information Setup
   6:  Trap Destinations

Other options: finished

Select section: finished

I can create the following types of configuration files for you.
Select the file type you wish to create:
(you can create more than one as you run this program)

   1:  snmpd.conf
   2:  snmptrapd.conf
   3:  snmp.conf

Other options: quit

Select File: quit


The following files were created:

  snmpd.conf installed in /usr/share/snmp
[root@nfsnode2 ~]#  systemctl restart snmpd


Redirecting to /bin/systemctl restart snmpd.service

4.重启snmpd服务
[root@nfsnode2 ~]#  systemctl status snmpd

5.修改配置文件

虽然重新启动了服务,但是别的服务器还是无法通过snmp访问。
vi /etc/snmp/snmpd.conf  
进入配置文件一看,前面snmpconf -i配置的信息好像没有写到配置文件中,那就手动修改吧!

6.手动修改配置文件vi /etc/snmp/snmpd.conf 
[root@nfsnode1 ~]# vi /etc/snmp/snmpd.conf

#       sec.name  source          community
com2sec notConfigUser  192.168.0.1     mynmmp

7.重启snmpd服务
[root@nfsnode1 ~]#  systemctl status snmpd

8.成功
在另外一台机器上使用snmpwalk测试成功
[root@Cnyunwei ~]# snmpwalk -c mynmp -v 2c 10.10.10.10

这里还要注意一只拦路虎“在AWS VPC中配置的安全策略中没有把协议打开,很多时候我们只开了TCP协议

9.设置开机自动启动snmp服务
[root@nfsnode1 ~]# chkconfig --add snmpd
error reading information on service snmpd: No such file or directory

[root@nfsnode1 ~]# chkconfig snmpd on
Created symlink from /etc/systemd/system/multi-user.target.wants/snmpd.service to /usr/lib/systemd/system/snmpd.service.[root@nfsnode1 ~]# chkconfig --list
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值