多个springboot应用无法使用同一个mongo数据库,连接被强制中断

我在阿里云上部署了两个springboot应用,访问的是同一个mongo数据库(跟应用部署在同一台server上)。当只启动一个应用的时候没有任何问题,但是如果同时启动另一个springboot应用,会导致原来的应用直接关闭,没有日志信息,查询mongo日志显示如下:

2018-02-10T18:51:26.040+0800 I -        [conn32323] end connection x.x.x.x:52898 (36 connections now open)
2018-02-10T18:51:26.040+0800 I -        [conn32324] end connection x.x.x.x:52901 (36 connections now open)

数据库连接强制关闭了。
此时如果启动这个应用被强制关闭的应用,数据库又会反复提示如下信息:

2018-02-10T18:40:21.493+0800 I COMMAND  [ftdc] serverStatus was very slow: { after basic: 111, after asserts: 303, after backgroundFlushing: 323, after connections: 414, after dur: 414, after extra_info: 514, after globalLock: 605, after locks: 817, after network: 908, after opLatencies: 1099, after opcounters: 1099, after opcountersRepl: 1099, after repl: 1109, after security: 1109, after storageEngine: 1422, after tcmalloc: 2107, after wiredTiger: 3932, at end: 6099 }
2018-02-10T18:40:25.875+0800 I COMMAND  [conn32260] command storyLines.$cmd command: ping { ping: 1.0 } numYields:0 reslen:22 locks:{} protocol:op_command 597ms
2018-02-10T18:40:25.875+0800 I COMMAND  [conn32275] command flight.$cmd command: ping { ping: 1.0 } numYields:0 reslen:22 locks:{} protocol:op_command 598ms
2018-02-10T18:40:25.875+0800 I COMMAND  [conn32274] command test.$cmd command: ping { ping: 1.0 } numYields:0 reslen:22 locks:{} protocol:op_command 598ms
2018-02-10T18:40:25.875+0800 I COMMAND  [conn32282] command admin.$cmd command: ping { ping: 1 } numYields:0 reslen:22 locks:{} protocol:op_command 111ms
2018-02-10T18:40:25.875+0800 I COMMAND  [conn32251] command admin.$cmd command: ping { ping: 1 } numYields:0 reslen:22 locks:{} protocol:op_command 598ms
2018-02-10T18:40:26.686+0800 I COMMAND  [conn32250] command admin.$cmd command: ping { ping: 1 } numYields:0 reslen:22 locks:{} protocol:op_command 186ms
2018-02-10T18:40:26.685+0800 I COMMAND  [conn32276] command admin.$cmd command: ping { ping: 1 } numYields:0 reslen:22 locks:{} protocol:op_command 186ms
2018-02-10T18:40:29.781+0800 I COMMAND  [PeriodicTaskRunner] task: UnusedLockCleaner took: 407ms
2018-02-10T18:40:29.781+0800 I COMMAND  [ftdc] serverStatus was very slow: { after basic: 181, after asserts: 786, after backgroundFlushing: 807, after connections: 998, after dur: 1109, after extra_info: 1885, after globalLock: 1895, after locks: 2097, after network: 2208, after opLatencies: 2409, after opcounters: 2409, after opcountersRepl: 2409, after repl: 2409, after security: 2480, after storageEngine: 2601, after tcmalloc: 2994, after wiredTiger: 3700, at end: 5000 }
2018-02-10T18:40:30.081+0800 I COMMAND  [conn32261] command flight.$cmd command: ping { ping: 1.0 } numYields:0 reslen:22 locks:{} protocol:op_command 587ms
2018-02-10T18:40:30.081+0800 I COMMAND  [conn32265] command flight.$cmd command: ping { ping: 1.0 } numYields:0 reslen:22 locks:{} protocol:op_command 587ms
2018-02-10T18:40:30.081+0800 I COMMAND  [conn32283] command storyLines.$cmd command: ping { ping: 1.0 } numYields:0 reslen:22 locks:{} protocol:op_command 587ms
2018-02-10T18:40:30.081+0800 I COMMAND  [conn32277] command storyLines.$cmd command: ping { ping: 1.0 } numYields:0 reslen:22 locks:{} protocol:op_command 587ms
2018-02-10T18:40:36.989+0800 I COMMAND  [conn32318] command admin.$cmd command: isMaster { ismaster: 1 } numYields:0 reslen:189 locks:{} protocol:op_query 1605ms
2018-02-10T18:40:37.893+0800 I COMMAND  [ftdc] serverStatus was very slow: { after basic: 393, after asserts: 988, after backgroundFlushing: 1008, after connections: 1089, after dur: 1099, after extra_info: 1392, after globalLock: 1402, after locks: 1684, after network: 1785, after opLatencies: 1986, after opcounters: 1997, after opcountersRepl: 1997, after repl: 2007, after security: 2077, after storageEngine: 2289, after tcmalloc: 2692, after wiredTiger: 3398, at end: 4396 }
2018-02-10T18:40:41.493+0800 I COMMAND  [conn32321] command admin.$cmd command: isMaster { ismaster: 1 } numYields:0 reslen:189 locks:{} protocol:op_query 694ms

导致始终无法启动,此时关闭另一个已经启动的应用,这个就可以正常启动了。请问是什么原因导致的呢?

阅读 2.9k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题