mongodb Failed: error connecting to db server: no reachable servers

前端 未结 12 2023
失恋的感觉
失恋的感觉 2020-12-13 11:59

I installed mongodb in Ubuntu14.04 server

I was not able to connect to mongodb via \"mongoimport\", \"mongodump\", \"mongostat\", etc. It always show \"no reachable

相关标签:
12条回答
  • 2020-12-13 12:52

    I find the answer by this links https://jira.mongodb.org/browse/TOOLS-620 It seem it is a mongodb tools bugs that doesn't resolved yet. Not sure if anyone know if the latest tools have fixed the issue?

    BTW, I uninstall the mongodb-tools 3.x and reinstall to 2.6.0 that resolved the problem

    sudo apt-get purge mongodb-org-tools
    echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
    sudo apt-get update
    sudo apt-get install -y mongodb-org-tools=2.6.0
    
    mongoimport --db test --collection restaurants --drop --file dataset.json
    connected to: 127.0.0.1
    2015-08-25T15:19:59.494+0800 dropping: test.restaurants
    2015-08-25T15:20:00.089+0800 check 9 25359
    2015-08-25T15:20:00.089+0800 imported 25359 objects
    
    0 讨论(0)
  • 2020-12-13 12:52

    If you have installed mongodb through homebrew then you can simply start mongodb through

    brew services start mongodb
    

    Then access the shell by

    mongo
    

    You can shut down your db by

    brew services stop mongodb
    

    For more options

    brew info mongodb
    
    0 讨论(0)
  • 2020-12-13 12:54

    I used mongo atlas to import CSV file to the cluster, I faced the same issue I tried many different solutions mentioned here but no one worked, I get back to the documentation this one worked for me, go to the dashbord and click on the name of your cluster, in the extreme right there is tab called command-line tools Data Import and Export Tools you will find how to import to your cluster

    mongoimport --uri mongodb+srv://admin:<PASSWORD>@<NAME>.mongodb.net/<DATABASE> --collection <COLLECTION> --type <FILETYPE> --file <FILENAME>

    if you are uploading csv file add --headerline after type

    0 讨论(0)
  • 2020-12-13 13:00
    mongorestore --db <thedb> --host=127.0.0.1 --port=<port> --drop path/db
    
    0 讨论(0)
  • 2020-12-13 13:02

    If TLS is enabled with authentication then use the below format from the dump location

    mongorestore --host=example.com --port=27017 --username=user_name  --authenticationDatabase=admin --ssl --sslCAFile /etc/ssl/rootCA.pem --sslPEMKeyFile /etc/ssl/mongodb.pem
    
    0 讨论(0)
  • 2020-12-13 13:03

    For people still facing this issue with MongoDB Atlas, just update your mongoDB version to more than 4.0.0. and it will work.

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