是否可以向MongoDB配置文件添加环境变量? [英] Is it possible to add environment variables to MongoDB config file?

查看:272
本文介绍了是否可以向MongoDB配置文件添加环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用YAML语法配置MongoDB副本集。但是,我想使用MONGODB_HOME环境变量来指向数据库:

  storage:
dbPath: ENV ['MONGODB_HOME'] / data / db

我试过使用%,$等,但没有成功。是否可以这样做?



以防万一,我正在Windows 7 64位工作。



解决方案

MongoDB配置文件(如3.0)只允许静态配置值。



如果要传递动态值,您可以通过命令行或PowerShell脚本来调用,例如:

  mongod.exe --dbpath%HOME%\data\db 

如果您计划启动多个MongoDB服务器实例(例如,对于不同的用户),您还需要指定唯一的 - 端口号码来收听。 p>

I am configuring a MongoDB replica set using YAML syntax. However, I'd like to use MONGODB_HOME environment variable to point to the database:

storage:
  dbPath: "ENV['MONGODB_HOME']/data/db"

I've tried using %, $, etc, but without success. Is it possible to do so?

Just in case, I'm working under Windows 7 64 bit.

Best regards

解决方案

The MongoDB config file (as at 3.0) only allows for static configuration values.

If you want to pass dynamic values you could invoke via the command line or a PowerShell script instead, eg:

mongod.exe --dbpath %HOME%\data\db

If you're planning on starting up multiple MongoDB server instances (for example, for different users) you'll also want to specify unique --port numbers to listen to.

这篇关于是否可以向MongoDB配置文件添加环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆