红联Linux门户
Linux帮助

解决ubuntu16.04中mongodb远程连接不上

发布时间:2017-08-22 09:24:19来源:linux网站作者:farYang
系统版本:
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial
MongoDB版本:
> db.version()
2.6.10
ps:使用yum安装的mongodb
 
1、查看网络端口情况,发现mongodb服务绑定中本地ip上
netstat -tunlp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
解决ubuntu16.04中mongodb远程连接不上
 
2、修改/etc/mongodb.con文件中mongodb绑定端口的ip,绑定到任何ip上:
bind_ip = 0.0.0.0
 
3、查看系统网络端口情况,mongodb服务监听的端口绑定中所有ip上,这样能够被内网的主机能够访问到
netstat -tunlp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
解决ubuntu16.04中mongodb远程连接不上
 
4、使用内网的另外一台ubuntu系统机子:
输入 curl 192.168.31.172:27017 ,返回It looks like you are trying to access MongoDB over HTTP on the native driver port.
说明连接成功
或者中浏览器地址栏中输入http://192.168.31.172:27017/,enter后,恢复上面相同的内容。
 
本文永久更新地址:http://www.linuxdiyf.com/linux/32378.html