You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Cuckoo连接MongoDB失败:不支持OP_QUERY命令listCollections求助

问题描述

在Ubuntu 22.04系统中连接Cuckoo与MongoDB 6.0.3时,启动Cuckoo出现以下错误:

2023-01-09 04:21:22,515 [cuckoo] CRITICAL: CuckooCriticalError: Unable to connect to MongoDB: command SON([('listCollections', 1), ('cursor', {})]) on namespace cuckoo.$cmd failed: Unsupported OP_QUERY command: listCollections. The client driver may require an upgrade. For more details see https://dochub.mongodb.org/core/legacy-opcode-removal. In order to operate Cuckoo as per your configuration, a running MongoDB server is required.

使用的MongoDB版本信息:

mongod --version
db version v6.0.3 Build Info: { "version": "6.0.3", "gitVersion": "f803681c3ae19817d31958965850193de067c516", "openSSLVersion": "OpenSSL 3.0.2 15 Mar 2022", "modules": [], "allocator": "tcmalloc", "environment": { "distmod": "ubuntu2204", "distarch": "x86_64", "target_arch": "x86_64" } }

已尝试重新安装MongoDB、执行chown命令,问题未解决。

原因分析

MongoDB 6.0及以上版本彻底移除了对旧版OP_QUERY协议的支持,而Cuckoo默认依赖的PyMongo(MongoDB官方Python驱动)版本过低,仍在使用该旧协议发送listCollections命令,导致连接失败。

解决方案
  1. 升级PyMongo到兼容版本
    激活Cuckoo使用的Python虚拟环境(如果有),执行以下命令升级PyMongo至支持MongoDB 6.0的版本:

    pip install --upgrade pymongo>=4.0
    
  2. 验证驱动版本
    执行以下命令确认PyMongo版本已升级成功:

    pip show pymongo
    

    确保输出中的Version字段值≥4.0。

  3. 重启Cuckoo服务
    停止当前运行的Cuckoo进程,重新启动服务,检查是否能正常连接MongoDB。

  4. 额外检查(可选)
    若升级后仍有问题,打开Cuckoo的配置文件(通常为cuckoo.conf),确认MongoDB连接配置项未指定旧协议相关参数,例如:

    [database]
    connection = mongodb://localhost:27017/cuckoo
    

内容的提问来源于stack exchange,提问作者idonotwanttolive

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 07:31:05