是否有人成功地监控了MongoDB 3集群(或独立db)和StackDriver在GCE中?
我在GCE中设置了一个MongoDB 3.0.6集群(带有2个副本和1个仲裁器的副本集)
我正试图通过谷歌提供的StackDriver来监控它。
我遵循了安装监控代理和mongodb插件的所有说明:https://cloud.google.com/monitoring/agent/plugins/mongodb
当我在配置它的副本上启动代理时:
sudo /etc/init.d/stackdriver-agent restart我在/var/log/syslog中得到以下错误:
collectd[6013]: tcpconns plugin: Reading from netlink succeeded. Will use the netlink method from now on.
collectd[6013]: mongo plugin: Authenticating to localhost:27017 failed:
collectd[6013]: mongo plugin: Connecting to localhost:27017 failed:
collectd[6013]: read-function of plugin `mongodb' failed. Will suspend it for 120.000 seconds.我怀疑StackDriver代理与MongoDB 3不兼容,因为:
任何帮助都是非常感谢的。
配置细节:
Mongodb:
Stackdriver插件:
补充资料:
/etc/mongo.conf:
# Turn on/off security. Off is currently the default
#noauth = true
#auth = true/opt/stackdriver/collectd/etc/collectd.d/mongodb.conf:
LoadPlugin mongodb
<Plugin "mongodb">
Host "localhost"
Port "27017"
# If you restricted access to the database, you can
# set the username and password here
# User "user_name"
# Password "user_password"
# For performance/eventually consistent trade-offs you may add this line
# PreferSecondaryQuery true
</Plugin>时的身份验证错误
/etc/mongo.conf:
# Turn on/off security. Off is currently the default
#noauth = true
auth = true配置了3个用户
use admin
db.createUser(
{
user: "siteUserAdmin",
pwd: "xxx",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
}
)
db.auth("siteUserAdmin", "xxx");
db.createUser( {
user: "siteRootAdmin",
pwd: "xxx",
roles: [ { role: "root", db: "admin" } ]
});
db.createUser(
{
user: "monitoring",
pwd: "xxx",
roles: [
{ role: "dbAdminAnyDatabase", db: "admin" },
{ role: "clusterAdmin", db: "admin" },
{ role: "readAnyDatabase", db: "admin" } ]
}
)/opt/stackdriver/collectd/etc/collectd.d/mongodb.conf:
LoadPlugin mongodb
<Plugin "mongodb">
Host "localhost"
Port "27017"
# If you restricted access to the database, you can
# set the username and password here
User "monitoring"
Password "xxx"
# For performance/eventually consistent trade-offs you may add this line
# PreferSecondaryQuery true
</Plugin>在插件配置中使用siteRootAdmin时也会出现相同的错误。
罪魁祸首实际上是StackDriver代理使用的auth模式。
我采用了亚当C提出的解决方案,因为我已经有了用SCRAM-SHA-1模式创建的用户。
事实上,我只需要监控用户使用MONGODB。
为此:
重新启动MongoDB 3.0,禁用auth
连接到实例
暂时将auth模式更改为MONGODB。
use admin
var schema = db.system.version.findOne({"_id" : "authSchema"});
schema.currentVersion = 3;
db.system.version.save(schema);为StackDriver插件创建用户
db.createUser(
{
user: "monitoring",
pwd: "xxx",
roles: [
{ role: "dbAdminAnyDatabase", db: "admin" },
{ role: "clusterAdmin", db: "admin" },
{ role: "readAnyDatabase", db: "admin" } ]
}
)检查它有正确的auth模式:MONGODB
> db.system.users.find({"user":"monitoring"})
{ "_id" : "admin.monitoring", "user" : "monitoring", "db" : "admin", "credentials" : { "MONGODB-CR" ...将auth模式设置为SCRAM-SHA-1。
var schema = db.system.version.findOne({"_id" : "authSchema"});
schema.currentVersion = 5;
db.system.version.save(schema);启用auth重新启动MongoDB 3.0
重新启动StackDriver代理
当StackDriver将支持SCRAM-SHA-1时,升级该用户的auth架构将非常有用。
db.adminCommand({authSchemaUpgrade: 1});发布于 2015-09-21 18:34:22
我怀疑堆栈驱动程序不支持新的SCRAM-SHA-1身份验证机制。这个新机制是加入3.0来取代MONGODB-CR,是3.0+中的默认机制,但是它要求驱动程序支持新机制。
要使MongoDB 3.0使用旧的机制,可以从2.6开始,然后在那里创建用户,然后升级,也可以执行以下操作(基于这句话):
var schema = db.system.version.findOne({"_id" : "authSchema"}); schema.currentVersion = 3; db.system.version.save(schema);现在应该用MONGODB-CR创建这些用途。StackDriver使用的是libmongoc,它支持SCRAM-SHA-1和1.1版一样,但是他们的版本看起来要老得多。一旦他们更新了他们的驱动程序,这个问题就会消失--现在你必须解决这个问题。
发布于 2016-06-24 21:09:47
我在谷歌工作在Stackdriver代理公司。亚当C的答案是正确的。我最近一直在做这个,现在我们有了一个测试版,它在我们自己的测试中运行得很好。这个新版本不仅解决了SCRAM-SHA-1问题,而且还具有一些性能改进。在更广泛地发布之前,我们希望有机会在几个客户环境中测试它。
如果有人愿意成为我们代理的新版本的测试员,我可以安排向您提供一个适合您平台的.deb或.rpm文件。和往常一样,事情可能出错的风险很小,所以我认为只有当你有一个非生产环境时,你才能尝试它。
编辑:截至2016年7月12日,此更改现已投入生产!
https://serverfault.com/questions/723361
复制相似问题