我在Ubuntu14.04服務器上安裝MongoDB的MongoDB的失敗:錯誤連接到數據庫服務器:沒有可以訪問的服務器
我無法連接通過「mongoimport」,「mongodump」,「mongostat」等方面的MongoDB它總是顯示「無可達服務器」
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
不知怎的,我能夠連接與蒙戈外殼
mongo --port 27017
MongoDB shell version: 3.0.6
connecting to: 127.0.0.1:27017/test
起初,我如果被我的iptables引起懷疑,所以我刷新所有iptables規則和創建規則都接受,但它仍然同樣
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
我搜索計算器和谷歌有人告訴劃分出 bind_ip或設置bind_ip爲0.0.0.0,我嘗試了所有,但還是失敗了。
下面是我的mangodb配置,有人可以幫我檢查嗎? 感謝您的幫助
[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
您的'mongod'進程顯然沒有運行。查看日誌'/ var/log/mongodb/mongod.log'是爲什麼。還要確保你遵循了[在Ubuntu上安裝MongoDB]的所有說明(http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/)。嘗試啓動該服務,或重新啓動機器。如有必要,請安裝。 –
將此作爲答案提交,因爲我無權發表評論。我有一個3成員副本集(版本3.4),並面臨與下面的命令相同的問題。 mongoimport --db test --drop rides.json與[whythecode](https://stackoverflow.com/users/5000167/whythecode),
mongoimport --host = 127.0.0.1建議的以下命令有相同的錯誤 - -db test rides.json以下命令能夠導入mongoimport --host = 127.0.0.1:27018 --db test rides.json請注意,主節點正在27018上運行。此外,沒有必要重置副本設置或運行它作爲獨立。 –