CentOS配置SNMP,centossnmp

來源:互聯網
上載者:User

CentOS配置SNMP,centossnmp

<span style="font-size:14px;">本文介紹如何在CentOS環境下配置一個簡單的SNMP服務</span>
軟體安裝

切換到系統管理員帳戶

安裝snmp
確認snmp代理已安裝
rpm -q net-snmp
如果未安裝,安裝snmp
yum install net-snmp


設定開機自動運行snmp
/sbin/chkconfig snmpd on配置snmp


修改設定檔

將原來的設定檔備份,編輯/etc/snmp/snmpd.conf,簡單配置如下

# First, map the community name "public" into a "security name"#       sec.name  source          communitycom2sec notConfigUser  default       public##### Second, map the security name into a group name:#       groupName      securityModel securityNamegroup   notConfigGroup v1           notConfigUsergroup   notConfigGroup v2c           notConfigUser##### Third, create a view for us to let the group have rights to:# Make at least  snmpwalk -v 1 localhost -c public system fast again.#       name           incl/excl     subtree         mask(optional)view    systemview    included   .1.3.6.1.2.1.1view    systemview    included   .1.3.6.1.2.1.25.1.1##### Finally, grant the group read-only access to the systemview view.#       group          context sec.model sec.level prefix read   write  notifaccess  notConfigGroup ""      any       noauth    exact  systemview none none

啟動snmp

/etc/init.d/snmpd start
如果已啟動則重啟snmp服務
/etc/init.d/snmpd restart

測試snmp

查看連接埠是否開啟
netstat -ln | grep 161

安裝snmp測試載入器
yum install net-snmp-utils

本機測試snmp資料(修改monit為配置的團體名)
snmpwalk -v 2c -c public localhost system

snmpwalk -v3 -u username -l auth -a MD5 -A password localhost

建立SNMP(v3)使用者

net-snmp-config --create-snmpv3-user -ro -a MD5 lyceemsnmp lyceem.com

遠程測試snmp資料(修改ip為伺服器ip,snmpwalk命令需要安裝net-snmp)
snmpwalk -v 2c -c public ip system


故常處理
錯誤排除如果本地測試snmp有資料,遠程測試snmp無資料則由於伺服器防火牆禁止了外部存取伺服器udp 161連接埠,則:
修改 /etc/sysconfig/iptables (或者:/etc/sysconfig/iptables-config ) ,增加如下規則:
-A RH-Firewall-1-INPUT -p udp -m state Cstate NEW -m udp Cdport 161 -j ACCEPT
重啟iptables
/etc/init.d/iptables restart
CentOS下,已經安裝了SNMP服務,但是不可以用service 命令來顯示狀態,問怎更改

是不是在執行service snmp status 提示不是提示snmp不是系統服務命令?如果是那是因為你沒把snmp作為系統命令,把snmp加入init.d裡面就可以了
 
CentOS下,已經安裝了SNMP服務,但是不可以用service 命令來顯示狀態,問怎更改

是用rpm封裝的嗎,是用的
service snmpd status
查看的狀態嗎
 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.