Mongodump failed error connecting to db server no reachable servers

mongoimport error — Failed: error connecting to db server: no reachable servers I am currently trying to learn mongodb and I am having trouble finding a solution for this problem. When I run a mongoimport command it I get the following error: I have a mongodb server by running mongod in the command line. […]

Содержание

  1. mongoimport error — Failed: error connecting to db server: no reachable servers
  2. 6 Answers 6
  3. mongorestore Failed: no reachable servers
  4. Update
  5. 13 Answers 13
  6. mongodb Failed: error connecting to db server: no reachable servers
  7. 13 Answers 13
  8. Failed error connecting to db server no reachable servers
  9. Asked by:
  10. Question
  11. Mongodump from secure Mongo database

mongoimport error — Failed: error connecting to db server: no reachable servers

I am currently trying to learn mongodb and I am having trouble finding a solution for this problem. When I run a mongoimport command it I get the following error:

I have a mongodb server by running mongod in the command line.

My MongoDB shell version is 3.0.6.

6 Answers 6

You need to use —host 127.0.0.1:27017

Try changing —host localhost to —host 127.0.0.1

The -h 127.0.0.1 parameter is a quick workaround, but upgrading to MongoDB 3.0.7 fixes this problem.

For me, mongo cluster is ssl enabled so I had a problem to connect mongo servers. I just add —ssl it works fine. It might be helpful for someone.

Old but since this doesn’t have an answer yet:

I had the same issue and looked at all the questions and none contained the solution to my specific problem. I had created my user in the «admin» database, which I had to specify when calling mongoimport with the —authenticationDatabase argument. Can check all the arguments here.

Adding the an answer for those who are struggling with the same issue while using MongoDB Atlas.

I tried to follow the offical guides like Seed with mongorestore and Load File with mongoimport but received the same no reachable servers error.

I tried to change the command arguments over and over — nothing changed.

But then I navigated inside my cluster to the «Command Line Tools» tab and saw the exact command I should run for mongorestore , mongodump , mongoimport , mongoexport etc’:

Adding as inline the full command:

The mongorestore comand can be replaced with mongodump , mongoimport , mongoexport etc’.

(*) Prefer copying the command directly from dashboard because the DNS of the replica-sets might change.

Источник

mongorestore Failed: no reachable servers

I tried to restore mongo from dump but failed:

Although I can connect to it without any problem:

In a log file there is nothing special:

Update

Host 127.0.0.1 didn’t help

Although I can still connect using mongo command:

Host 0.0.0.0 didn’t help as well:

I have 3.2 version of MongoDb:

13 Answers 13

try adding host param

Do you run mongo in replica set, i.e., mongod —replSet rs0 ?

If yes, please remember to run in your mongo shell the command: rs.initiate()

Then you can use cmd mongorestore to restore your db.

The problem occured because —replSet was enabled in configuration. But the node wasn’t yet in any replica set.

After I removed —replSet from configuration, relaunched mongodb server, mongorestore started to work without any —host parameter.

I have MongoDB installed through Homebrew, and was having this issue. Here are the symptoms:

These failed:

mongorestore dump —host=localhost

The error I got: Failed: error connecting to db server: no reachable servers

These worked (as a workaround):

mongorestore dump —host=127.0.0.1

mongorestore dump —host=0.0.0.0

This fixed the problem for me:

brew update && brew upgrade

That updated MongoDB to 3.0.7 and now mongorestore dump works without the host flag.

I struggled with the same issue while using MongoDB Atlas for a few hours.

I tried to follow the offical guides like Seed with mongorestore and Load File with mongoimport but received the same no reachable servers error.

I tried to change the command arguments over and over — nothing changed.

But then I navigated inside my cluster to the «Command Line Tools» tab and saw the exact command I should run for mongorestore , mongodump , mongoimport , mongoexport etc’:

Adding as inline the full command:

The mongorestore comand can be replaced with mongodump , mongoimport , mongoexport etc’.

(*) Prefer copying the command directly from dashboard because the DNS of the replica-sets might change.

Источник

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

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 server»

Somehow, I was able to connect with mongo shell

At first, I doubt if it cause by my iptables, so I flush all iptables rules and create rules for ALL accept, but it still same

I search the stackOverflow and google and someone told marked off bind_ip or set bind_ip to 0.0.0.0, I tried all but still failed.

Below are my mangodb config, would any one can help me to check? Thanks for your help

13 Answers 13

A temporary workaround is to add the host param to your mongoimport call, letting mongo know that the host is your own machine ( 127.0.0.1 ):

The full command in your case is then:

Update:

Updating to Mongo >= 3.0.7 should solve the issue

Update 2:

There’s also an open JIRA issue here.

Update 3:

In some cases, this can be caused by Mongo running as a ReplicaSet. To solve this, as far as I’ve seen, one can either disable the ReplicaSet functionality or reset it. See:

To provide the options host and port

You need to provide host option try the following command :

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

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

Adding another answer for those who are struggling with the same issue while using MongoDB Atlas.

I tried to follow the offical guides like Seed with mongorestore and Load File with mongoimport but received the same no reachable servers error.

I tried to change the command arguments over and over — nothing changed.

But then I navigated inside my cluster to the «Command Line Tools» tab and saw the exact command I should run for mongorestore , mongodump , mongoimport , mongoexport etc’:

Adding as inline the full command:

The mongorestore comand can be replaced with mongodump , mongoimport , mongoexport etc’.

(*) Prefer copying the command directly from dashboard because the DNS of the replica-sets might change.

Источник

Failed error connecting to db server no reachable servers

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Asked by:

Question

I have a mongodb database on mlab and im trying to migrate data into documentdb(managed by microsoft). I was able to download my data from mlab using mongodump command but mongoexport/mongoimport always fails with below error

error connecting to db server: no reachable servers

> ./mongodb/bin/mongoimport —host flicksurfapp.documents.azure.com:10250 -u flicksurfapp -p xxxxx —file flicksurfappm/artists.metadata.json —collection artists —db flicksurfapp

2016-06-11T22:46:48.288-0500 [. ] flicksurfapp.artists 0.0 B/307.0 B (0.0%)

2016-06-11T22:46:50.313-0500 [. ] flicksurfapp.artists 0.0 B/307.0 B (0.0%)

2016-06-11T22:46:50.313-0500 Failed: error connecting to db server: no reachable servers

2016-06-11T22:46:50.313-0500 imported 0 documents

> ./mongodb/bin/mongorestore -h flicksurfapp.documents.azure.com:10250 -u flicksurfapp -p xxxxx flicksurfappm/

2016-06-11T22:12:28.743-0500 Failed: error connecting to db server: no reachable servers

Источник

Mongodump from secure Mongo database

In order for me to connect to this [secure] Mongo instance I have to run the following command:

mongo —ssl —host sampleHostname —sslPEMKeyFile /path/to/user.pem —sslCAFile /path/to/mongoca.cer —authenticationDatabase ‘$external’ —authenticationMechanism=MONGODB-X509

I am trying to do a mongodump command to get the data but I keep running into the following errors:

Attempt 1

mongodump -d mydb

Failed: error connecting to db server: no reachable servers

mongodump -d mydb —authenticationDatabse ‘$external’

Failed: error connecting to db server: no reachable servers

Attempt 3 Using the same command as how I connect.

mongodump -d mydb —ssl —host sampleHostname —sslPEMKeyFile /path/to/user.pem —sslCAFile /path/to/mongoca.cer —authenticationDatabase ‘$external’ —authenticationMechanism=MONGODB-X509

Failed: error getting collections for database ‘mydb’: error running ‘listCollections’. Database: ‘mydb’ Err: not authorized on ‘mydb’ to execute command >

I have tried the same command with sudo but it still returns the same error.

mongodump -d mydb —ssl —host sampleHostname —sslPEMKeyFile /path/to/user.pem —sslCAFile /path/to/mongoca.cer —authenticationDatabase ‘$external’ —authenticationMechanism=MONGODB-X509 —excludeCollection=system.indexes

Failed: error getting collections for database ‘mydb’: error running ‘listCollections’. Database: ‘mydb’ Err: not authorized on ‘mydb’ to execute command >

I am stuck and I am eventually going to run mongorestore but I do not want to run this without making sure I am able to backup first. I imagine the solution for mongodump will resolve any possible issues I may have with mongorestore (if any).

Источник

#mongodb #mongodump

#mongodb #mongodump

Вопрос:

Я пытаюсь разместить свою базу данных в Интернете, и, основываясь на том, что я нашел в Интернете, мне нужно сначала mongodump экспортировать свою базу данных.

Способ использования mongodump , если я не ошибаюсь, таков:

 mongodump -d <db-name> -o <directory>
 

когда я использую приведенную выше команду, я получаю следующую ошибку в терминале:

 Failed: error connecting to db server: no reachable servers
 

Я попытался добавить --host=127.0.0.1 после mongodump следующим образом:

 mongodump --host=127.0.0.1 -d <db-name> -o <directory>
 

Но я все равно получаю тот же результат. Что я здесь делаю не так?

Обновить:

Мне удалось устранить ошибку, запустив службу MongoDB с помощью следующей команды:

 brew services start mongodb
 

Теперь, когда я запускаю mongodump , кажется, что он работает, но я не могу его найти, когда я перехожу в каталог, где он должен быть расположен!

ПРИМЕЧАНИЕ: я использую технологию Meteor и получаю доступ к своей базе данных с meteor mongo помощью command

Комментарии:

1. Можете ли вы подключиться к оболочке mongo, запустив just mongo ?

2. @andresk нет, я не могу, он показывает мне «сбой подключения», я обычно запускаю свой mongo, используя «meteor mongo», потому что я использую Meteor JS для создания своего проекта

3. @andresk Мне удалось запустить mongo, но не mongodump, я обновлю свой вопрос,

4. и какую ошибку вы получаете сейчас?

5. @andresk, пожалуйста, проверьте вопрос еще раз, я отредактировал его снова 🙂 извините

Ответ №1:

Если вы выполняете mongodump с удаленного сервера, может случиться так, что версии несовместимы. Это приводит к тому, что никакие документы не сбрасываются без каких-либо предупреждений. (По крайней мере, из моих тестов mongodump 2.6.10 не сможет выполнить сброс из mongod 3.2.13)

Кроме того, убедитесь, что специальные символы bash не разбивают ваш запрос.

Пример:

 mongodump --db DB_name --collection colname --query "{$or: [something1, something]}"
 

Предыдущий запрос не будет работать, так как вам нужно экранировать $ with .

 mongodump --db DB_name --collection colname --query "{$or: [something1, something]}"
 

Ответ №2:

Вы могли бы попробовать:

Запустите mongodump --db <database> --port 3001 из каталога, в котором вы хотите создать выходные файлы (это создаст каталог дампа с файлами).

Порт равен 3001, поскольку, похоже, meteor не использует порт Mongodb по умолчанию

Кроме того, если ничего не появляется, попробуйте запустить с -v флагом для подробного режима, это поможет вам выяснить, почему ваши файлы не создаются. Кроме того, убедитесь, что имя вашей базы данных указано правильно.

Комментарии:

1. это не сработало, однако я считаю, что проблема не в вашем решении, потому что я получаю следующее сообщение об ошибке в консоли: «позиционные аргументы не разрешены: [meteor]», я полагаю, причина в том, что имя моей базы данных «meteor» — это команда, которую я использую для запуска своего проекта. поэтому я считаю, что проблема может быть связана с именем базы данных.

2. Сейчас я работаю над его изменением, я обновлю вас, как только закончу :). Спасибо

3. Вы можете попробовать использовать --db или просто использовать mongodump для сброса всех данных из вашего экземпляра mongo. Также помните, что никогда не используйте = sign . Например, это не --host=127.0.0.1 так, но --host 127.0.0.1

4. хорошо, большое спасибо за помощь, приму ответ, если он решит это для меня 🙂

5. я получил «сброс до 0 коллекций параллельно», когда я использовал «-v» с «mongodump -v —db meteor». на самом деле он не сбрасывает никаких данных! -_-

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 server»

mongoimport --db test --collection restaurants --drop --file dataset.json
2015-08-25T13:08:29.802+0800    [........................] test.restaurants 0.0 B/11.3 MB (0.0%)
2015-08-25T13:08:30.306+0800    Failed: error connecting to db server: no reachable servers
2015-08-25T13:08:30.306+0800    imported 0 documents

Somehow, I was able to connect with mongo shell

mongo --port 27017
MongoDB shell version: 3.0.6
connecting to: 127.0.0.1:27017/test

At first, I doubt if it cause by my iptables, so I flush all iptables rules and create rules for ALL accept, but it still same

 sudo iptables -S
    -P INPUT ACCEPT
    -P FORWARD ACCEPT
    -P OUTPUT ACCEPT
    -A INPUT -j ACCEPT
    -A INPUT -i lo -j ACCEPT
    -A FORWARD -j ACCEPT
    -A OUTPUT -j ACCEPT
    -A OUTPUT -o lo -j ACCEPT

I search the stackOverflow and google and someone told marked off
bind_ip or set bind_ip to 0.0.0.0, I tried all but still failed.

Below are my mangodb config, would any one can help me to check?
Thanks for your help

[email protected]:~$ cat /etc/mongod.conf 
# mongod.conf

# Where to store the data.

# Note: if you run mongodb as a non-root user (recommended) you may
# need to create and set permissions for this directory manually,
# e.g., if the parent directory isn't mutable by the mongodb user.
dbpath=/var/lib/mongodb

#where to log
logpath=/var/log/mongodb/mongod.log

logappend=true

port = 27017

# Listen to local interface only. Comment out to listen on all interfaces. 
#bind_ip = 127.0.0.1
# Disables write-ahead journaling
# nojournal = true

# Enables periodic logging of CPU utilization and I/O wait
#cpu = true

# Turn on/off security.  Off is currently the default
#noauth = true
#auth = true

# Verbose logging output.
verbose = true

# Inspect all client data for validity on receipt (useful for
# developing drivers)
#objcheck = true

# Enable db quota management
#quota = true

# Set oplogging level where n is
#   0=off (default)
#   1=W
#   2=R
#   3=both
#   7=W+some reads
#diaglog = 0

# Ignore query hints
#nohints = true

# Enable the HTTP interface (Defaults to port 28017).
#httpinterface = true

# Turns off server-side scripting.  This will result in greatly limited
# functionality
#noscripting = true

# Turns off table scans.  Any query that would do a table scan fails.
#notablescan = true

# Disable data file preallocation.
#noprealloc = true

# Specify .ns file size for new databases.
# nssize = <size>

# Replication Options

# in replicated mongo databases, specify the replica set name here
#replSet=setname
# maximum size in megabytes for replication operation log
#oplogSize=1024
# path to a key file storing authentication info for connections
# between replica set members
#keyFile=/path/to/keyfile

Понравилась статья? Поделить с друзьями:
  • Mongodb error logs
  • Mongo server selection error
  • Mongo server error bad auth authentication failed
  • Mongo network error
  • Mongo error code 11000