常见数据库【SNMP代理】配置_qu6zhi_百度空间
===================================================================================
===================================================================================
SQL Server 数据库监控 SNMP 代理配置
------------------------------------------------------------------------------------------------------------------------------------
SQL Server 采用【扩展代理】的方式来实现 SNMP 代理功能,需要对注册表作相应修改。使得 SNMP 服务启动时可以自动加载扩展代理。
------------------------------------------------------------------------------------------------------------------------------------
SQL Server 2000 以上的版本,安装时默认都自动注册扩展代理,无须手工配置。扩展代理 DLL 为sqlsnmp.dll。
目前发现只有 V1 才能xx支持 SQL Server 的所有 SNMP 参数。其中的部分参数不支持 Get Bulk 导致。
------------------------------------------------------------------------------------------------------------------------------------
对于 SQL Server 2000一下的版本,手工添加扩展代理方法如下,注意区分大小写的匹配:
① 添加扩展代理注册信息
找到 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameter\ExtensionAgents
新增如下字符串值:格式为:名称、类型、数值
1 : REG_SZ : SOFTWARE\Microsoft\MSSQLServer\SNMP\CurrentVersion

② 配置扩展代理DLL对于的路径
转到HKEY_LOCAL_MACHINE\SOFTWARE
创建主键:Microsoft\MSSQLServer\SNMP\CurrentVersion
新增字符串值:Pathname:REG_EXPAND_SZ:d:\Program Files\Microsoft SQL Server\MSSQL\BINN\sqlsnmp.dll
===================================================================================
===================================================================================
Sybase ASE 数据库监控 SNMP 代理配置
------------------------------------------------------------------------------------------------------------------------------------
在“第三方程序 \sybase”目录下带了一个 Sybase ASE12.5 的 SNMP 子代理,它是 Net-snmp 的 AgentX 扩展代理。
首先需要安装和配置 Net-snmp 代理,并且配置 Net-snmp 支持 agentx,简单来说就是 snmpd.conf 文件中有一行是“master agentx”,具体参考第3章。
2.1. Linux
将“第三方程序\sybase”目录下的 SNMP-1_0.tar 通过 FTP 方式拷贝到目标 Linux 机器上,放在下面的目录中/opt/Sybase-12.5下。
注意:Sybase安装时,标准的做法是自动创建一个用户 sybase,因此 Sybase 的安装目录的权限属于sybase 用户,建议使用 sybase 用户登录后来安装这个包。
运行下面的命令解压:
tar xvf SNMP-1_0.tar
进入/opt/Sybase-12.5/SNMP-1_0目录,用vi打开文件snmpagent.cfg,修改其中的配置:
#
# Sybase SNMP Sub-Agent example configuration file
# This file defines the behavior of the Sybase sub-agent.
#
# Global values affecting the behavior of the sub-agent
#
#   logFile=logfile
#       Full path to the agent's logfile
#
#   masterAgentLocation=host:port
#       The host and port number that the master agent is listening on for
#       agentX connections.  When using the net-snmp agent, this is the
#       "-x" value.
#
#   rpcPort=port
#       The port to listen on for remote procedure calls.  Used by ASE or
#       other servers to call sp_errornotify.  You would use this same value when you
#       create an interfaces file entry for the Sybase Agent so that an ASE can send it
#       an RPC.
#
#
#
# Server sections
# Some configuration values are specific to the server that is being monitored.
# A section is defined with the server name in brackets, followed by the configuration
# values for that server.
#
#   login=loginname
#       The login name the SNMP agent will connect with.
#
#   password=pwd
#       The password value the SNMP agent will connect with.
#
#   serverLocation=host:port
#       The network location of a Sybase server to monitor.
#
#   fastPollTime=seconds
#       The number of seconds in between collection of frequently
#       changing data such as performance counters.
#
#   slowPollTime=seconds
#       The number of seconds in between collection of slowly changing
#       data such as configuration values.
#
#   description=line of text
#       Value to return as a description of the server.
#
#   applUrl=line of text
#       Value to return in applUrl field of ApplTabl in the Network Services MIB.  It will default
#       to blank.
#
#   serverType=ase or openserver
#       Indicates whether this is an ASE or an Open Server based application such as backup server.
#


#
# Global Values
#
masterAgentLocation=localhost:705
rpcPort=5210
logFile=/opt/sybase-12.5/SNMP-1_0/SybaseAgent.log


#
# Server definitions
#
#[locahost_BACKUP]
[linux_back]
fastPollTime=60
slowPollTime=3600

# sybase backupserver 服务启动的端口,具体可以看 /opt/sybase-12.5/interfaces 文件配置
# 将下面的“linux”修改成本机的 IP 地址
serverLocation=linux:4200
description=Example backup server
serverType=openserver


# [localhost_ASE]
[linux]
login=sa
password=xxxxx #这里输入连接数据库的密码
fastPollTime=60
slowPollTime=3600

# sybase dataserver 服务启动的端口,具体可以看 /opt/sybase-12.5/interfaces文件配置
# 将下面的“linux”修改成本机的 IP 地址
serverLocation=linux:4100
description=Example Sybase ASE
serverType=ase

配置完成后,运行下面命令可以启动 sybase 子代理
java -jar /opt/sybase-12.5/SNMP-1_0/lib/SybaseAgent.jar –c  /opt/sybase-12.5/SNMP-1_0/snmpagent.cfg &
为了在系统重启后能够自动启动子代理,需要在 /etc/rc.d/rc.local 文件中增加启动子代理的命令,要注意的是rc.local中的java命令必须写全路径,如下所示:
/opt/sybase-12.5/shared-1_0/jre-1.2.2/bin/java -jar /opt/sybase-12.5/SNMP-1_0/lib/SybaseAgent.jar  -c /opt/sybase-12.5/SNMP-1_0/snmpagent.cfg &
注意:snmpd 和 Sybase 的子代理必须按照顺序启动,并且一旦其中一个退出则必须全部重启 snmpd 和Sybase 子代理,否则子代理的工作不正常(无法返回相应的查询结果)
===================================================================================
===================================================================================
Oracle 数据库监控 SNMP 代理配置
------------------------------------------------------------------------------------------------------------------------------------
Oracle 以OracleIntelligent Agent(智能代理,AGNTSVC.EXE)作为操作系统SNMP主代理的方式来工作,将所有的标准SNMP参数请求转发给“操作系统自身的SNMP代理(如NET-SNMP或者是WINDOWS标准SNMP代理)”,并且通过SNMPPeerEncapsulator(协议转换服务,ENCSVC.EXE)与标准SNMP进行通讯。
3.1. 部署案例
3.1.1        Windows
Oracle8i:8.1.3.6
Oracle9i:2.2.4
3.1.2        Unix
Oracle8i:
Oracle9i:
3.2. 验证方法
用OID查询工具看看能否获得如下参数值:
Oracle参数:oraDbTablespaceSizeUsed  1.3.6.1.4.1.311.1.4.1.1.6.1.8,如果不能获取表示Oracle的SNMP参数不能获取;
3.3. Windows配置
SNMP版本支持,目前发现只支持SNMP V1。
3.3.1        修改Windows标准SNMP服务端口
需要将Windows标准SNMP服务端口修改为1161(snmp)、1162(snmptrap)。具体操作参见8.1Windows标准SNMP服务端口修改。
3.3.2        修改Oracle配置文件
主代理服务配置文件master.cfg(OracleOraHome90SNMPPeerMasterAgent,在ORACLE_HOME\Network\admin目录下):
TRANSPORT       ordinary        SNMP
OVER UDP SOCKET
AT PORT 161  (Oracle Master Agent的服务端口)

COMMUNITY       public
ALLOW ALL OPERATIONS
USE NO ENCRYPTION

MANAGER         localhost    (Trap目标地址)
SEND ALL TRAPS
WITH COMMUNITY public     
子代理兼容协议转换服务配置文件encaps.cfg(在ORACLE_HOME\Network\admin目录下):
AGENT AT PORT 1161 WITH COMMUNITY public   (表示子代理(Windows标准SNMP服务)使用1161端口)
SUBTREES        1.3.6.1.2.1.1,   
1.3.6.1.2.1.2,
1.3.6.1.2.1.3,
1.3.6.1.2.1.4,
1.3.6.1.2.1.5,
1.3.6.1.2.1.6,
1.3.6.1.2.1.7,
1.3.6.1.2.1.8,
1.3.6.1.2.1.25,  (HOSTRESOURCE-MIB,必须加入,否则不支持主机监控)
1.3.6.1.4.1.77,
1.3.6.1.2.1   
FORWARD ALL TRAPS;

注意:不支持子节点。如设置了1.3.6.1.2.1,如果需要访问1.3.6.1.2.1.25下的资源,还是需要单独设置。
3.3.3        启动
按照如下顺序启动服务,否则可能导致取值异常。
启动Oracle服务(OracleServiceORCL[ORACLE.EXE]),当已经启动时忽略此项

启动Oracle主代理(OracleOraHome90SNMPPeerMasterAgent[AGNTSVC.EXE])
启动 OEM代理服务(OracleOraHome90Agent [dbsnmp.exe])
启动Oracle协议转换服务(OracleOraHome90SNMPPeerEncapsulator[ENCSVC.EXE])
启动Windows SNMP标准服务

注意:如果需要自动启动Oracle及其SNMP服务,只需要将上面的服务全部设置为“自动”则可。
3.4. Linux配置
以AS4(Linux 2.6.9-5.EL,红帽企业 Linux 4)为例进行说明。
SNMP版本支持,目前发现只支持SNMP V1。
3.4.1        关闭SELinux
红帽企业 Linux 4 包括了一个 SELinux 的实现。SELinux 代表了用户,程序以及进程间相互交流的主要变化。在这个发行版本中,SELinux 被默认安装并被开启使用,需要关闭,否则无法正确采集主机监控信息。
正确配置如下:
# more /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=Disabled (不能设置为enforcing)

# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted
3.4.2        安装NET-SNMP
使用如下命令可以查出安装的NET-SNMP包,rpm -qa | grep snmp
AS4自带如下NET-SNMP包:
net-snmp-libs-5.1.2-11
net-snmp-5.1.2-11
net-snmp-utils-5.1.2-11
对于别的平台,参见3.2Linux平台上的安装配置。
3.4.3        修改Linux标准SNMP服务端口(此项需要验证修改的必要性?)
保证操作系统自身的SNMP不占用标准端口(161、162),以空出给作为主代理的ORACLE使用。
其中的配置文件为“/etc/services”,类似于Windows标准SNMP服务端口的修改。
此处设置如下:
snmp         1161/udp #SNMP (修改本地SNMP服务端口为1161,只要不是161则可)
snmptrap   1162/udp  snmp-trap #SNMP trap(修改本地SNMP TRAP服务端口为1162,只要不是162则可)
3.4.4        配置NET-SNMP
参见3.2.2配置Net-SNMP代理的设置。
其中必须确保已将NET-SNMP的端口设置为161以外的端口,系统缺省为161,可以在/etc/snmp/snmpd.conf中新增如下行来修改:
agentaddress  1161

注意:/usr/sbin/snmpd加载配置文件的搜索顺序是“/etc/snmp/snmpd.conf  /usr/share/snmp/snnpd.conf”
3.4.5        安装Oracle智能代理
3.4.5.1编译智能代理
(1)   stop all the instances of this ORACLE_HOME,stop listener
(2)   relink the agent
#relink oemagent
(3) you should find agentctl and dbsnmp in $ORACLE_HOME/bin, it's date show they are new files
3.4.5.2运行root.sh,修改dbsnmp的属性
成功安装智能代理后,必须运行root.sh脚本,以修改智能代理的权限,以更新或者是创建一份oratab文件,以保证dbsnmp能够
#cd $ORACLE_HOME/bin
#ls -al dbsnmp
-rwsr-s---   1 root     g651     1497980 Jun 12 21:04 dbsnmp
紫色部分表明已经成功执行了root.sh脚本。
3.4.5.3修改Oracle配置文件
与Windows下的Oracle配置基本相同。
主代理服务配置文件CONFIG.master:
TRANSPORT       ordinary        SNMP
OVER UDP SOCKET
AT PORT 161  (Oracle Master Agent的服务端口)

COMMUNITY       leagsoft
ALLOW ALL OPERATIONS
USE NO ENCRYPTION

MANAGER         localhost    (Trap目标地址)
SEND ALL TRAPS
WITH COMMUNITY leagsoft   
子代理兼容协议转换服务配置文件CONFIG.encaps:
AGENT AT PORT   1161 WITH COMMUNITY leagsoft  (表示子代理(Windows标准SNMP服务)使用1161端口)
SUBTREES            1.3.6.1.2.1.1,
1.3.6.1.2.1.2,
1.3.6.1.2.1.3,
1.3.6.1.2.1.4,
1.3.6.1.2.1.5,
1.3.6.1.2.1.6,
1.3.6.1.2.1.7,
1.3.6.1.2.1.8,
1.3.6.1.2.1.25  (HOSTRESOURCE-MIB,必须加入,否则不支持主机监控)
FORWARD ALL TRAPS;
3.4.6        启动Oracle智能代理
按照如下顺序启动服务,否则可能导致取值异常。
(1)    启动Oracle主代理以及操作相同标准代理
1.首先通过如下命令来确认相应代理没有启动
#ps –d | grep snmpd
#ps –d | grep peer
2. cd $ORACLE_HOME/network/snmp/peer
3. verify that a script start_peer exists.
将start_peer中启动语句修改为
4. su root
5. ./start_peer -a (starts the Master Peer agent, the encapsulator and the native SNMP daemon, 可以使用./start_peer –help 来获得帮助信息)
可以通过如下语句来检查是否启动成功
#ps –d | grep snmpd
#ps –d | grep peer
6. Exit from root.

如果 snmpd 启动失败,则检查是否不支持
/usr/sbin/snmpd –c snmpd.conf –p 1161的启动方式,如果不支持,需要修改root.sh脚本,找到{zh1}一行,去掉-p $SNMPD_PORT的命令行参数。
本AS4的应用环境就需要删除此项不支持的参数。
(2)    启动智能代理
$cd ORACLE_HOME/bin
$agentctl start
Then use ps -ef|grep dbsnmp
to check the agent started successful or not.
===================================================================================
===================================================================================
参考:


郑重声明:资讯 【常见数据库【SNMP代理】配置_qu6zhi_百度空间】由 发布,版权归原作者及其所在单位,其原创性以及文中陈述文字和内容未经(企业库qiyeku.com)证实,请读者仅作参考,并请自行核实相关内容。若本文有侵犯到您的版权, 请你提供相关证明及申请并与我们联系(qiyeku # qq.com)或【在线投诉】,我们审核后将会尽快处理。
—— 相关资讯 ——