linux - Mongodb 导出器即 Linux 中的服务
问题描述
我正在尝试使用此 github 链接安装 mongodb 导出器:https ://github.com/percona/mongodb_exporter
我按照此链接获取说明 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
,其他选项是可选的。
推荐阅读
- python - 如何可视化 Conv1D 层中的内核?
- java - 如何在 Mockito 中模拟类型转换实例
- php - 请求回调 url 的数据
- deno - deno 安装和 deno 编译之间有什么区别?
- ansible - 有没有办法从 Ansible 中的下载链接中获取文件的文件名
- react-native - 如何在世博会的一个上传按钮中实现图像和 pdf 选择器?
- ruby - Rubocop 安装(机器:linux-gnu,Ubuntu)
- python - 如何编写与此 MatLab For Loop 等效的 Python
- typescript - 类型缩小在通用约束下无法按预期工作
- java - 如何在java中找到矩阵的鞍点?