How to Create a configuration File For MongoDB

后端 未结 4 1302
隐瞒了意图╮
隐瞒了意图╮ 2020-12-13 06:52

I have installed mongodb for mac os through 10gen and I have gone through the documentation to do so. Everything seems fine apart from the configuration file. I can not see

相关标签:
4条回答
  • 2020-12-13 07:25

    Unless you have installed a packaged version of MongoDB (for example, using Homebrew or Mac Ports) you will have to create a config file manually, or just pass the appropriate command line parameters when starting up MongoDB.

    If you want a commented example of a config file to start with, the mongodb.conf in the Debian/Ubuntu package should be a good starting point. Important options to check are the dbpath and logpath which will likely be different for you.

    It would also be worth looking at the Homebrew mongodb formula which includes setting up a LaunchAgent script to manage the mongod service.

    0 讨论(0)
  • 2020-12-13 07:34

    The default path for brew installed mongodb on Mac OS X is /usr/local/etc/mongod.conf

    0 讨论(0)
  • 2020-12-13 07:38

    In the case you installed MongoDB without Homebrew, i.e. downloaded the TGZ package directly from MongoDB Download Center, you will can add the configuration file:

    sudo nano /etc/mongod.conf
    

    Please use only spaces (no tabs) in the file and leave a space after the key. For example:

    security:
      authorization: enabled
    net:
      port: 27017
      bindIp: 0.0.0.0
    

    And then run the instance with the configuration flag:

    mongod -f /etc/mongod.conf
    

    I wrote a post about installing MongoDB Community Edition directly from the TGZ archive.

    0 讨论(0)
  • 2020-12-13 07:43

    Yes, unless you install via a package manager (like apt or yum on Linux) you have to create this manually. Then, When you start mongod you simply need to specify where the config file is, for example:

    ./mongod -f /path/to/mongod.conf
    

    For how that file should look, just take a look here:

    http://docs.mongodb.org/manual/reference/configuration-options/

    You can also see the aforementioned Linux config files from the packages on github:

    https://github.com/mongodb/mongo/blob/master/rpm/mongod.conf

    https://github.com/mongodb/mongo/blob/master/debian/mongodb.conf

    0 讨论(0)
提交回复
热议问题