我刚创建了一个包含两个实例的mongo复制设置。日志显示每秒开始和结束的许多连接。日志如下。当我没有任何服务器与数据库通信时,知道为什么有这么多连接?我也很困惑为什么连接的端口不断增加。
主要Mongo实例
$ tail /log/mongod.log
2015-02-08T21:46:40.679+0000 [initandlisten] connection accepted from <local machine private IP from EC2>:43833 #58 (6 connections now open)
2015-02-08T21:46:40.680+0000 [conn58] authenticate db: local { authenticate: 1, nonce: "xxx", user: "__system", key: "xxx" }
2015-02-08T21:47:05.416+0000 [conn10] end connection <local machine private IP from EC2>:43719 (5 connections now open)
2015-02-08T21:47:05.416+0000 [conn13] end connection <local machine private IP from EC2>:43724 (4 connections now open)
2015-02-08T21:47:10.699+0000 [conn58] end connection <local machine private IP from EC2>:43833 (3 connections now open)
2015-02-08T21:47:10.700+0000 [initandlisten] connection accepted from <local machine private IP from EC2>:43835 #59 (4 connections now open)
2015-02-08T21:47:10.702+0000 [conn59] authenticate db: local { authenticate: 1, nonce: "xxx", user: "__system", key: "xxx" }
2015-02-08T21:47:40.720+0000 [conn59] end connection <local machine private IP from EC2>:43835 (3 connections now open)
2015-02-08T21:47:40.723+0000 [initandlisten] connection accepted from <local machine private IP from EC2>:43836 #60 (4 connections now open)
2015-02-08T21:47:40.724+0000 [conn60] authenticate db: local { authenticate: 1, nonce: "xxx", user: "__system", key: "xxx" }
辅助Mongo实例
$ tail /log/mongod.log
2015-02-08T21:46:39.732+0000 [conn285] authenticate db: local { authenticate: 1, nonce: "xxx", user: "__system", key: "xxx" }
2015-02-08T21:46:59.877+0000 [initandlisten] connection accepted from <local machine elastic IP from EC2>:42568 #286 (4 connections now open)
2015-02-08T21:46:59.881+0000 [conn286] end connection <local machine elastic IP from EC2>:42568 (3 connections now open)
2015-02-08T21:47:05.424+0000 [conn191] end connection <local machine private IP from EC2>:44756 (2 connections now open)
2015-02-08T21:47:09.750+0000 [conn285] end connection <local machine private IP from EC2>:43873 (1 connection now open)
2015-02-08T21:47:09.752+0000 [initandlisten] connection accepted from <local machine private IP from EC2>:43874 #287 (2 connections now open)
2015-02-08T21:47:09.753+0000 [conn287] authenticate db: local { authenticate: 1, nonce: "xxx", user: "__system", key: "xxx" }
2015-02-08T21:47:39.772+0000 [conn287] end connection <local machine private IP from EC2>:43874 (1 connection now open)
2015-02-08T21:47:39.774+0000 [initandlisten] connection accepted from <local machine private IP from EC2>:43875 #288 (2 connections now open)
2015-02-08T21:47:39.775+0000 [conn288] authenticate db: local { authenticate: 1, nonce: "xxx", user: "__system", key: "xxx" }
我也有点困惑为什么在某些情况下使用弹性IP(参见辅助日志)。我假设使用公共IP会让我被AWS收费吗?
答案 0 :(得分:2)
每隔30秒发生一次的连接是心跳线程,来自另一个副本集成员,以确保该成员仍然活着并且健康。它们使用副本集配置中的任何IP。
使用公共IP的连接似乎很快就结束了它的连接。提高您的日志级别并弄清楚它在做什么?