是否可以向MongoDB配置文件添加环境变量? [英] Is it possible to add environment variables to MongoDB config file?
问题描述
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屋!