远程连接到MongoDB的HTTP接口EC2服务器上 [英] Remotely connecting to MongoDB http interface on EC2 server
问题描述
我无法远程到我的MongoDB的HTTP接口我的AWS EC2服务器上的连接。
我检查日志并验证它的端口28017.听我用netstat -a TCP端口28017是开放的验证。我在安全组启用28017。
我得到我的IP使用ifconfig,并尝试获取到IP HTTP接口:28017。什么都没发生。没有错误,没有什么。
我已经把其余部分为真实的在我的mongod.conf文件,我开始的mongod与'须藤服务的mongod重启
服务我甚至试图用须藤的mongod --rest开始的mongod无济于事。
这是什么尾-f /log/mongod.conf显示:
周六2月2日2时06分54秒[initandlisten] MongoDB的起点:PID = 3919端口= 27017 DBPATH = /数据64位主机=的domU-12-31-39-12 -3A-A2
周六2月2日2点06分54秒[initandlisten] DB版本V2.2.2,pdfile 4.5版
周六2月2日2点06分54秒[initandlisten]的Git版本:d1b43b61a5308c4ad0679d34b262c5af9d664267
周六2月2日2点06分54秒[initandlisten]打造信息:Linux的IP-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen#1 SMP周五11月20日17点48分28秒美国东部时间2009年x86_64的BOOST_LIB_VERSION = 1_49
周六2月2日2点06分54秒[initandlisten]选项:{配置:/etc/mongod.conf,DBPATH:/数据,叉:真,logappend:真,日志路径:/日志/ mongod.log,pidfilepath:/var/run/mongodb/mongod.pid,其余的:真正的}
周六2月2日2点06分54秒[initandlisten]期刊DIR = /数据/杂志
周六2月2日2点06分54秒[initandlisten]恢复:没有日志文件present,没有恢复需要
周六2月2日2点06分54秒[initandlisten]等待端口27017的连接
周六2月2日2点06分54秒[websvr] Web管理控制台等待端口28017的连接
这是什么netstat -a可显示:
活动的互联网连接(服务器,并建立)
原始的recv-Q发送-Q本地地址外国地址状态
TCP 0 0本地主机: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池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本地主机:NTP *:*
UDP 0 0 *:NTP *:*
主动UNIX域套接字(服务器,并建立)
原RefCnt旗型国家的i-node路径
UNIX 2 [ACC] STREAM LISTENING 5402 @ / COM / Ubuntu的/新贵
UNIX 2 [ACC] STREAM聆听40948 /var/lib/mysql/mysql.sock
UNIX 2 [ACC] SEQPACKET LISTENING 5468 @ /组织/内核/的udev / udevd会
UNIX 2 [ACC] STREAM LISTENING 6332的/ var /运行/ DBUS / system_bus_socket
UNIX 9] DGRAM 6278的/ dev /日志
UNIX 2 [ACC] STREAM聆听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 /运行/ 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
有关您的EC2实例,添加两个站自定义TCP规则,以允许端口27017和28017的入站流量。
请确保注释掉bind_ip = 127.0.0.1在/etc/mongod.conf文件
重启的mongod服务器: $ sudo的服务mongod的启动
I cannot connect remotely to my mongodb http interface on my AWS ec2 server.
I've checked the log and verified that it's listening on port 28017. I've verified with netstat -a that tcp port 28017 is open. I've enabled 28017 in the security group.
I get my IP with ifconfig, and try to get to the http interface with IP:28017. Nothing happens. No error, nothing.
I've put rest = true in my mongod.conf file and I start mongod as a service with 'sudo service mongod restart'
I even tried to start mongod with 'sudo mongod --rest' to no avail.
This is what tail -f /log/mongod.conf shows:
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
This is what netstat -a shows:
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
For you EC2 instance, add two inbound custom TCP rules to allow inbound traffic on ports 27017 and 28017.
Make sure to comment out the "bind_ip = 127.0.0.1" in the /etc/mongod.conf file
restart mongod server: $sudo service mongod restart
这篇关于远程连接到MongoDB的HTTP接口EC2服务器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!