我无法远程连接到 AWS ec2 服务器上的 mongodb http 接口。
我检查了日志并确认它正在侦听端口 28017。我已经使用 netstat -a 验证了 tcp 端口 28017 已打开。我在安全组中启用了 28017。
我使用 ifconfig 获取我的 IP,并尝试使用 IP:28017 访问 http 接口。什么都没发生。没有错误,什么都没有。
我已经在我的 mongod.conf 文件中添加了 rest = true 并且我使用 'sudo service mongod restart' 将 mongod 作为服务启动
我什至尝试使用 'sudo mongod --rest' 启动 mongod,但无济于事。
这是 tail -f /log/mongod.conf 显示的内容:
Sat Feb 2 02:06:54 [initandlisten] MongoDB starting : pid=3919 port=27017 dbpath=/data 64-bit host=domU-12-31-39-12-3A-A2
Sat Feb 2 02:06:54 [initandlisten] db version v2.2.2, pdfile version 4.5
Sat Feb 2 02:06:54 [initandlisten] git version: d1b43b61a5308c4ad0679d34b262c5af9d664267
Sat Feb 2 02:06:54 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Sat Feb 2 02:06:54 [initandlisten] options: { config: "/etc/mongod.conf", dbpath: "/data", fork: "true", logappend: "true", logpath: "/log/mongod.log", pidfilepath: "/var/run/mongodb/mongod.pid", rest: "true" }
Sat Feb 2 02:06:54 [initandlisten] journal dir=/data/journal
Sat Feb 2 02:06:54 [initandlisten] recover : no journal files present, no recovery needed
Sat Feb 2 02:06:54 [initandlisten] waiting for connections on port 27017
Sat Feb 2 02:06:54 [websvr] admin web console waiting for connections on port 28017
这就是 netstat -a 显示的内容:
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:smtp *:* LISTEN
tcp 0 0 *:27017 *:* LISTEN
tcp 0 0 *:mysql *:* LISTEN
tcp 0 0 *:28017 *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 272 domU-12-31-39-12-3A-A2.:ssh pool-108-54-50-116.ny:50722 ESTABLISHED
tcp 0 0 *:ssh *:* LISTEN
udp 0 0 *:bootpc *:*
udp 0 0 domU-12-31-39-12-3A-A2.c:ntp *:*
udp 0 0 localhost:ntp *:*
udp 0 0 *:ntp *:*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ACC ] STREAM LISTENING 5402 @/com/ubuntu/upstart
unix 2 [ ACC ] STREAM LISTENING 40948 /var/lib/mysql/mysql.sock
unix 2 [ ACC ] SEQPACKET LISTENING 5468 @/org/kernel/udev/udevd
unix 2 [ ACC ] STREAM LISTENING 6332 /var/run/dbus/system_bus_socket
unix 9 [ ] DGRAM 6278 /dev/log
unix 2 [ ACC ] STREAM LISTENING 182622 /tmp/mongodb-27017.sock
unix 3 [ ] STREAM CONNECTED 182434
unix 3 [ ] STREAM CONNECTED 182433
unix 2 [ ] DGRAM 182429
unix 2 [ ] DGRAM 131031
unix 2 [ ] DGRAM 40170
unix 2 [ ] DGRAM 19247
unix 2 [ ] DGRAM 7231
unix 2 [ ] DGRAM 7212
unix 2 [ ] DGRAM 7194
unix 3 [ ] STREAM CONNECTED 6341 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 6340
unix 3 [ ] STREAM CONNECTED 6336
unix 3 [ ] STREAM CONNECTED 6335
unix 3 [ ] DGRAM 5484
unix 3 [ ] DGRAM 5483