On this page本页内容
SNMP is only available in MongoDB Enterprise.SNMP仅在MongoDB Enterprise中可用。
MongoDB Enterprise can provide database metrics via SNMP, in support of centralized data collection and aggregation. MongoDB Enterprise可以通过SNMP提供数据库指标,以支持集中的数据集合和聚合。This procedure explains the setup and configuration of a 本过程解释了作为SNMP子代理的mongod
instance as an SNMP subagent, as well as initializing and testing of SNMP support with MongoDB Enterprise.mongod
实例的设置和配置,以及使用MongoDB Enterprise初始化和测试SNMP支持。
Troubleshoot SNMP and Monitor MongoDB Windows with SNMP for complete instructions on using MongoDB with SNMP on Windows systems.对SNMP进行故障排除并使用SNMP监控MongoDB Windows,以获取有关在Windows系统上使用MongoDB with SNMP的完整说明。
MongoDB Enterprise includes the following SNMP configuration files:MongoDB Enterprise包括以下SNMP配置文件:
MONGOD-MIB.txt
:
The management information base (MIB) file that defines MongoDB's SNMP output. 定义MongoDB的SNMP输出的管理信息库(MIB)文件。On Ubuntu and Debian platforms, this file is shipped compressed as 在Ubuntu和Debian平台上,该文件以MONGOD-MIB.txt.gz
and must be decompressed with gunzip
.MONGOD-MIB.txt.gz
的形式压缩,必须使用gunzip
解压。
mongod.conf.subagent
:
The configuration file to run 要作为SNMP子代理运行mongod
as the SNMP subagent. mongod
的配置文件。This file sets SNMP run-time configuration options, including the 此文件设置SNMP运行时配置选项,包括用于连接到SNMP主机的agentXSocket
to connect to the SNMP master.agentXSocket
。
mongod.conf.master
:
The configuration file to run 将mongod
as the SNMP master. mongod
作为SNMP主机运行的配置文件。This file sets SNMP run-time configuration options, including the 此文件设置SNMP运行时配置选项,包括要运行的agentaddress
to run on.agentaddress
。
The MongoDB SNMP configuration files are provided with your MongoDB Enterprise installation, as follows:MongoDB SNMP配置文件随MongoDB Enterprise安装一起提供,如下所示:
If you installed MongoDB Enterprise via a package manager, these files are installed to the following directory as part of the package installation process:如果您通过软件包管理器安装了MongoDB Enterprise,这些文件将作为软件包安装过程的一部分安装到以下目录:
Platform | Path |
---|---|
RHEL / CentOS | /usr/share/doc/mongodb-enterprise-server-5.0.6 |
Ubuntu / Debian | /usr/share/doc/mongodb-enterprise-server |
SUSE | /usr/share/doc/packages/mongodb-enterprise-server |
.tgz
tarball, these files were included in the tarball..tgz
tarball安装MongoDB Enterprise,这些文件都包含在tarball中。Copy the MongoDB SNMP configuration files from their installation location to their target directories, according to your platform:根据您的平台,将MongoDB SNMP配置文件从安装位置复制到目标目录:
Navigate to the location where the SNMP files were installed. For example, if you installed the latest version of MongoDB via the yum
package manager:
cd /usr/share/doc/mongodb-enterprise-server-5.0.6
Copy the two MongoDB SNMP files to their target directories:
sudo cp MONGOD-MIB.txt /usr/share/snmp/mibs/ sudo cp mongod.conf.subagent /etc/snmp/mongod.conf
Navigate to the location where the SNMP files were installed. For example, if you installed MongoDB via the apt
package manager:
cd /usr/share/doc/mongodb-enterprise-server
Copy the MONGOD-MIB.txt.gz
file to its target directory, and unzip it:
sudo cp MONGOD-MIB.txt.gz /usr/share/snmp/mibs/
sudo gunzip /usr/share/snmp/mibs/MONGOD-MIB.txt.gz
Copy the mongod.conf.subagent
file to its target directory:
sudo cp mongod.conf.subagent /etc/snmp/mongod.conf
Navigate to the location where the SNMP files were installed. For example, if you installed the latest version of MongoDB via the zypper
package manager:
cd /usr/share/doc/packages/mongodb-enterprise-server
Copy the two MongoDB SNMP files to their target directories:
sudo cp MONGOD-MIB.txt /usr/share/snmp/mibs/ sudo cp mongod.conf.subagent /etc/snmp/mongod.conf
Edit the /etc/snmp/snmpd.conf
file, and add the following:
# sec.name source community com2sec local localhost mongodb # group.name sec.model sec.name group MyRWGroup any local # incl/excl subtree mask view all included .1 80 # context sec.model sec.level prefix read write notif access MyRWGroup "" any noauth 0 all all all master agentx AgentXSocket /tmp/agentx/master AgentXPerms 0777 0777 mongod mongod
Install snmpd
if it is not already installed:
sudo apt-get install snmpd
Edit the /etc/snmp/snmpd.conf
file, and add the following:
# sec.name source community com2sec local localhost mongodb # group.name sec.model sec.name group MyRWGroup any local # incl/excl subtree mask view all included .1 80 # context sec.model sec.level prefix read write notif access MyRWGroup "" any noauth 0 all all all AgentXSocket /tmp/agentx/master AgentXPerms 0777 0777 mongodb mongodb
Edit the /etc/snmp/snmpd.conf
file, and add the following:
# sec.name source community com2sec local localhost mongodb # group.name sec.model sec.name group MyRWGroup any local # incl/excl subtree mask view all included .1 80 # context sec.model sec.level prefix read write notif access MyRWGroup "" any noauth 0 all all all master agentx AgentXSocket /tmp/agentx/master AgentXPerms 0777 0777 mongod mongod
This configuration defines a UNIX domain socket for communication between the master (此配置定义了用于主代理(snmpd
) and sub-agent (MongoDB), and defines basic SNMP permissions for access to the relevant MongoDB SNMP fields.snmpd
)和子代理(MongoDB)之间通信的UNIX域套接字,并定义了访问相关MongoDB SNMP字段的基本SNMP权限。
To bind your master to a non-localhost IP address, add that IP address to the 要将主机绑定到非本地主机IP地址,请将该IP地址添加到agentaddress
field in the /etc/snmp/snmpd.conf
file, and update the appropriate network security ACLs to permit a valid address range. /etc/snmp/snmpd.conf
文件中的agentaddress
字段,并更新相应的网络安全ACL以允许有效的地址范围。An address range of 10.0.0.0/8 with a security name of "mynetwork" has been provided in the 例如,mongod.conf.master
configuration file as an example.mongod.conf.master
配置文件中提供了10.0.0.0/8的地址范围,安全名称为“mynetwork”。
The above configuration is given as an example only; you may wish to customize permissions based on your site security requirements. 以上配置仅作为示例给出;您可能希望根据站点安全要求自定义权限。While MongoDB support can provide guidance on configuring MongoDB for SNMP, configuring SNMP on operating systems is out of scope.虽然MongoDB支持可以为配置MongoDB for SNMP提供指导,但在操作系统上配置SNMP超出了范围。
Start SNMP on your system using the initialization system appropriate for your version of Linux:使用适合您的Linux版本的初始化系统在系统上启动SNMP:
For Linux systems using systemd (对于使用systemd(systemctl
command):systemctl
命令)的Linux系统:
sudo systemctl start snmpd
For Linux systems using System V init (对于使用System V init(service
command):service
命令)的Linux系统:
sudo service snmpd start
Start 使用mongod
with the snmp-subagent
to send data to the SNMP master.snmp-subagent
启动mongod
,将数据发送到snmp主机。
mongod --snmp-subagent
Verify that MongoDB is accessible for SNMP queries with the 使用snmpwalk
testing command.snmpwalk
测试命令验证MongoDB是否可用于SNMP查询。
Install snmpwalk
on your system:
sudo yum install net-snmp-utils
Run snmpwalk
with the following parameters to verify the ability to collect data from mongod
:
snmpwalk -m /usr/share/snmp/mibs/MONGOD-MIB.txt -v 2c -c mongodb 127.0.0.1:161 1.3.6.1.4.1.34601
DEBIAN ONLY: If necessary, add the non-free
repository to your /etc/apt/sources.list
file to access the snmp-mibs-downloader
package. For example, on Debian 9 "Stretch", the primary repo entries might look like this:
deb http://deb.debian.org/debian stretch main non-free deb-src http://deb.debian.org/debian stretch main non-free
DEBIAN / UBUNTU: Install the snmp-mibs-downloader
package to supply necessary MIB files, then restart the snmpd
service to reload the new MIB files:
sudo apt-get update sudo apt-get -y install snmp-mibs-downloader sudo service snmpd restart
DEBIAN / UBUNTU: Run snmpwalk
with the following parameters to verify the ability to collect data from mongod
:
snmpwalk -m /usr/share/snmp/mibs/MONGOD-MIB.txt -v 2c -c mongodb 127.0.0.1:161 1.3.6.1.4.1.34601
snmpwalk -m /usr/share/snmp/mibs/MONGOD-MIB.txt -v 2c -c mongodb 127.0.0.1:161 1.3.6.1.4.1.34601
The snmpwalk
command should display current values for SNMP fields such as sysUpTime
, and memoryResident
, among others.snmpwalk
命令应该显示SNMP字段的当前值,例如sysUpTime
和memoryResident
等。
The port used in the above 上述snmpwalk
testing command, port 161, is the default port for the snmpd
service, not the primary port
for the mongod
. snmpwalk
测试命令中使用的端口端口161是snmpd
服务的默认端口,而不是mongod
的主端口。If you have configured a different port for your 如果您为snmpd
service, supply that here instead.snmpd
服务配置了不同的端口,请在此处提供。
You can run 出于测试目的,可以使用mongod
with the snmp-master
option for testing purposes. snmp-master
选项运行mongod
。To do this, use the SNMP master configuration file instead of the subagent configuration file. 为此,请使用SNMP主配置文件而不是子代理配置文件。From the directory containing the unpacked MongoDB installation files:从包含未打包MongoDB安装文件的目录:
cp mongod.conf.master /etc/snmp/mongod.conf
To bind your master to a non-localhost IP address, add that IP address to the 要将主机绑定到非本地主机IP地址,请将该IP地址添加到agentaddress
field in the /etc/snmp/mongod.conf
file, and update the appropriate network security ACLs to permit a valid address range. /etc/snmp/mongod.conf
文件中的agentaddress
字段,并更新相应的网络安全ACL以允许有效的地址范围。An address range of 10.0.0.0/8 with a security name of "mynetwork" has been provided in the master configuration file as an example.主配置文件中提供了一个地址范围为10.0.0.0/8、安全名称为“mynetwork”的示例。
Then, start 然后,使用mongod
with the snmp-master
option:snmp-master
选项启动mongod
:
mongod --snmp-master