在 Linux 上获取 MongoDB 以侦听远程连接 [英] Getting MongoDB on Linux to listen to remote connections
问题描述
我已经在 Windows(在本地机器上)成功安装了 MongoDB 作为服务,但现在我想将 MongoDb 移动到一个单独的服务器.因此,我将 tarball 解压缩到网络上的虚拟服务器(运行 linux).
I've successfully installed MongoDB on Windows (on a local machine) as a service, but now I want to move MongoDb to a separate server. So I extracted the tarball to a virtual server on network (running linux).
当我从本地机器使用 PuTTY 连接到服务器(testmongoserver")时,我启动了 mongod 服务器,它告诉我它正在侦听默认的 28017 端口.mongo 控制台也在工作,并允许我创建一个新数据库 (testdb) 并向其中添加用户.
When I connected to the server ("testmongoserver") using PuTTY from my local machine, I started the mongod server and it told me that it was listening to the default 28017 port. The mongo console is also working and allowed me to create a new database (testdb) and add users to it.
但是,我无法从远程访问服务器.当我输入 testmongoserver:28017
时,它不会像我本地机器上的 localhost:28017
那样打开 HTTP 控制台.我也无法使用官方驱动程序并提供连接字符串进行连接.
However, I could not access the server from remote. When I type testmongoserver:28017
it doesn't open the HTTP console as localhost:28017
on my local machine does. I also can't connect using official drivers and providing a connectionstring.
在 Linux 上安装 MongoDB 的必要步骤是什么,以便我可以从带有连接字符串的远程机器访问它并通过 testmongoserver:28017
What are the neccesarry steps to install MongoDB on Linux, so that I could access it from a remote machine with a connectionstring and use its HTTP console via testmongoserver:28017
谢谢!
推荐答案
- 在 mongo 服务器上运行 netstat -a 并检查端口.
- 检查 DNS 设置并检查 linux 服务器是否允许外部连接.
- 检查 mongodb 是否可以接受外部/远程连接.
mongo 的默认端口是 27017.28017 - webstats 的端口.
Default port for mongo is 27017. 28017 - port for webstats.
参见 http://www.mongodb.org/display/DOCS/Security+and+Authentication#SecurityandAuthentication-Ports
这篇关于在 Linux 上获取 MongoDB 以侦听远程连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!