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 最新版本,壓測后沒有出現此問題,徹底解決


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM