2017-01-02 4 views
1

В настоящее время у меня возникают проблемы с удаленным подключением сервера mongodb на моей виртуальной машине Ubuntu. Я не могу связаться с клиентом Robomongo, который работает на моем ПК с Windows, который также запускает vm.Невозможно подключиться удаленно к mongodb

Вот IP-адресаты для обоих шт

Окна:

Ethernet adapter Ethernet: 
Connection-specific DNS Suffix . : 
IPv4 Address. . . . . . . . . . . : 192.168.1.137 
Subnet Mask . . . . . . . . . . . : 255.255.255.0 
Default Gateway . . . . . . . . . : 192.168.1.1 

Ubuntu:

enp0s3 Link encap:Ethernet HWaddr 08:00:27:6c:fc:9c 
     inet addr:192.168.1.134 Bcast:192.168.1.255 Mask:255.255.255.0 
     inet6 addr: fe80::9785:55d7:130:6618/64 Scope:Link 
     UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 
     RX packets:5021 errors:0 dropped:0 overruns:0 frame:0 
     TX packets:465 errors:0 dropped:0 overruns:0 carrier:0 
     collisions:0 txqueuelen:1000 
     RX bytes:1231057 (1.2 MB) TX bytes:45237 (45.2 KB) 

Ошибка, я получаю на окна, которые показывают его не может подключение: enter image description here

Netstat, который показывает Монго работает:

netstat -tulpn | grep 27017 
(Not all processes could be identified, non-owned process info 
will not be shown, you would have to be root to see it all.) 
tcp  0  0 127.0.0.1:27017   0.0.0.0:*    LISTEN  3611/mongod 

С этого момента я попытался подключиться локально на сервере, и он работает:

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

Затем я попытался добавить порт 27017 на UFW и по-прежнему не могут быть подключены:

sudo ufw status 
To       Action  From 
--       ------  ---- 
27017      ALLOW  Anywhere     
27017 (v6)     ALLOW  Anywhere (v6) 

Благодарим за помощь.

+0

Ну, '127.0.0.1' не может быть источником адреса для любого трафика вне хоста. Вы пытаетесь вывести сервер из loopback-адреса, а не адреса, который может использоваться вне хоста сервера. –

ответ

1

Обнаружена проблема. Это произошло из-за того, что флаг bind_ip в моем mongodb.conf установлен в 127.0.0.1. Вот почему я так же могу подключиться локально к серверу mongodb.

Резолюция должна была прокомментировать флаг bind_ip, чтобы не было белого списка IP-адресов.

Mongodb.conf

# mongodb.conf 



# Where to store the data. 

dbpath=/home/<username>/mongodb 



#where to log 

logpath=/home/<username>/mongodb/logs/mongodb.log 



logappend=true 



#bind_ip = 127.0.0.1 

port = 27017 



# Enable journaling, http://www.mongodb.org/display/DOCS/Journaling 

journal=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 

#oplog = 0 



# Diagnostic/debugging option 

#nocursors = true 



# Ignore query hints 

#nohints = true 



# Disable the HTTP interface (Defaults to localhost:27018). 

#nohttpinterface = 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> 



# Accout token for Mongo monitoring server. 

#mms-token = <token> 



# Server name for Mongo monitoring server. 

#mms-name = <server-name> 



# Ping interval for Mongo monitoring server. 

#mms-interval = <seconds> 



# Replication Options 



# in replicated mongo databases, specify here whether this is a slave or master 

#slave = true 

#source = master.example.com 

# Slave only: specify a single database to replicate 

#only = master.example.com 

# or 

#master = true 

#source = slave.example.com 



# Address of a server to pair with. 

#pairwith = <server:port> 

# Address of arbiter server. 

#arbiter = <server:port> 

# Automatically resync if slave data is stale 

#autoresync 

# Custom size for replication operation log. 

#oplogSize = <MB> 

# Size limit for in-memory storage of op ids. 

#opIdMem = <bytes> 



# SSL options 

# Enable SSL on normal ports 

#sslOnNormalPorts = true 

# SSL Key file and password 

#sslPEMKeyFile = /etc/ssl/mongodb.pem 

#sslPEMKeyPassword = pass 

 Смежные вопросы

  • Нет связанных вопросов^_^