mongo - ruby connection problem

后端 未结 6 1186
无人及你
无人及你 2020-12-24 03:17

I have installed mongo and bson_ext now I have created a .rb file with the following contents ::

require \'rubygems\'
require \'mongo\'

db = Mongo::Connecti         


        
相关标签:
6条回答
  • 2020-12-24 03:33

    I just encountered this due to my /etc/hosts file not containing an entry for "localhost" - consequently Ruby couldn't resolve "localhost". I suppose you can hardcode 127.0.0.1 into your code rather than "localhost" - or fix /etc/hosts to contain:

    127.0.0.1 localhost

    0 讨论(0)
  • 2020-12-24 03:33

    Sometimes there is simply not enough space.

    exception in initAndListen: 15926 Insufficient free space for journals, terminating

    0 讨论(0)
  • 2020-12-24 03:44

    If you're on a Mac and used Brew, restarting the service solved it for me:

    launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
    

    You can find this info by running brew info mongodb.

    0 讨论(0)
  • 2020-12-24 03:51

    This is definitely due to your mongo server not running. Since you're on Ubuntu, try doing a sudo /etc/init.d/mongodb start and then see if your code works.

    0 讨论(0)
  • 2020-12-24 03:52

    On a mac, using brew I found that brew info mongodb and then using then

    ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents or mongod --config /usr/local/etc/mongod.conf worked!

    0 讨论(0)
  • 2020-12-24 03:57

    had this happen several times now, and here is the solution that works for me:

    sudo rm /var/lib/mongodb/mongod.lock
    sudo -u mongodb mongod -f /etc/mongodb.conf --repair
    sudo start mongodb
    sudo status mongodb
    
    0 讨论(0)
提交回复
热议问题