mongodb分片集群报错261

报错信息为:
root@jpvsmgmaster4:/# mongo --port 27017
MongoDB shell version v4.2.3
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("14ebc864-e221-48df-8f3f-d2a0dd05f3de") }
MongoDB server version: 4.2.3
Server has startup warnings:
2020-04-02T09:58:39.176+0000 I  CONTROL  [main]
2020-04-02T09:58:39.176+0000 I  CONTROL  [main] ** WARNING: Access control is not enabled for the database.
2020-04-02T09:58:39.176+0000 I  CONTROL  [main] **          Read and write access to data and configuration is unrestricted.
2020-04-02T09:58:39.176+0000 I  CONTROL  [main]
mongos> sh.status()
2020-04-02T10:00:29.355+0000 E  QUERY    [js] uncaught exception: Error: error: {
        "ok" : 0,
        "errmsg" : "Encountered non-retryable error during query :: caused by :: Unable to add session into the cache because the number of active sessions is too high",
        "code" : 261,
        "codeName" : "TooManyLogicalSessions",
        "operationTime" : Timestamp(1585821629, 5),
        "$clusterTime" : {
                "clusterTime" : Timestamp(1585821629, 5),
                "signature" : {
                        "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                        "keyId" : NumberLong(0)
                }
        }
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DBCommandCursor@src/mongo/shell/query.js:696:15
DBQuery.prototype._exec@src/mongo/shell/query.js:111:28
DBQuery.prototype.hasNext@src/mongo/shell/query.js:282:5
DBCollection.prototype.findOne@src/mongo/shell/collection.js:255:10
printShardingStatus@src/mongo/shell/utils_sh.js:551:19
sh.status@src/mongo/shell/utils_sh.js:98:5
@(shell):1:1

从上面信息可以看出报错是因为config的session太多没有回收导致

解决方法:

1、临时解决

将配置服务器为多节点副本集(config)
  1. 重新启动副本集中的任何节点。
  2. 将重新启动的节点转换为主节点。
  3. 下次刷新时,将重新创建会话集合。    

简单来说,就是依次重启config节点,注意要先重启从节点,在重启主节点

重启后会释放session连接,但是一段时间同样的报错还会重复出现

2、永久解决办法

经过查询发现出现此问题的mongo版本是4.2.3,将其升级成4.2.8 最新版本,压测后没有出现此问题,彻底解决

posted @ 2020-07-29 18:31  巴黎斜塔  阅读(1825)  评论(0编辑  收藏  举报