Mongodb linux 中的出口商即服务

Mongodb Exporter as a Service in linux

我正在尝试使用此 github link 安装 mongodb 导出器:https://github.com/percona/mongodb_exporter

我按照这个 link 进行指导 https://www.percona.com/blog/2020/04/17/how-to-configure-mongodb-exporter-with-ssl-tls/

到目前为止没有问题,我可以单独使用“mongodb_exporter”二进制文件执行并通过执行

成功连接到mongo
mongodb_exporter --mongodb.uri=mongodb://user:password@localhost:27017?ssl=true&sslclientcertificatekeyfile=/etc/ssl/mongo.pem&sslinsecure=true&sslcertificateauthorityfile=/etc/ssl/mongo.pem

但是为了 运行 这个二进制文件作为服务,我在 /etc/systemd/system 文件夹中创建了一个 mongodb_exporter.service。

这是服务文件的内容:

[Unit]
Description=Mongodb Exporter
After=network-online.target

[Service]
User=mongodb_exporter
Group=mongodb_exporter
Type=simple
EnvironmentFile=/etc/.mongodb_exporterconf
ExecStart=/usr/local/bin/mongodb_exporter $ARG1

[Install]
WantedBy=multi-user.target

如您所见,我之前创建了一个 .mongodb_exporterconf 文件,然后为 ARG1 变量分配了上面的标志“--mongodb.uri”

当我检查此服务的状态时,它抛出此错误 error msg="Can't create mongo session to mongodb://****:password@localhost:27017?&sslclientcertificatekeyfile=/etc/ssl/mongo.pem&sslinsecure=true&sslcertificateauthorityfile=/etc/ssl/mongo.pem" source="mongodb_collector.go:188"

目前我不知道我错过了什么,但我只找到了 1 个线索但我不太确定,错误消息没有显示或跳过了“ssl=true”选项。或者我只是错过了一些配置。任何想法或帮助表示赞赏!

原来我只需要--mongodb.uri=mongodb://user:password@localhost:27017?ssl=true,其他选项是可选的