加载导航时出错:尝试使用 Snappy 压缩,但未安装 Snappy

An error occurred while loading navigation: Attempted to use Snappy compression, but Snappy is not installed

我尝试通过 official tutorial 在我的 MacOS 上安装最新的 mongo 数据库。所以以下命令似乎对我有效:

brew services start mongodb-community@4.4
brew services list  

列出以下内容

mongodb-community started naman .../LaunchAgents/homebrew.mxcl.mongodb-community.plist

此外,当我尝试执行 mongo 时,我能够成功地为 shell

创建一个会话
MongoDB shell version v4.4.3 
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb 
Implicit session: session { "id" : UUID("57e62dd9-77f2-48c2-8fe8-8fe9fe79a1d2") }

并访问数据库、集合、执行查询等等。

但进一步尝试使用 MongoDB Compass 连接到此 URI 以利用其 visual tree for explain,我发现必须启用压缩:

并且在将压缩指定为 snappy 后,它将读取以下内容:

An error occurred while loading navigation: Attempted to use Snappy compression, but Snappy is not installed. Install or disable Snappy compression and try again.

正在使用的 MongoDB 版本是 v4.4.3 和指南针版本 Version 1.25.0,是否有解决此问题的方法,或者我是否需要从默认设置调整我的配置?

由于此处在 urioption.compressors 中描述:

Comma-delimited string of compressors to enable network compression for communication between this client and a mongod/mongos instance.

You can specify the following compressors:

  • snappy
  • zlib (Available in MongoDB 3.6 or greater)
  • zstd (Available in MongoDB 4.2 or greater)

为什么 compressors=disabled 在 mongo-shell(mongo) 而不是 mongo-compass 中工作?

Value for compressors must be at least one of: snappy, zlib

所以在这里,

  1. net.compression.compressors, cmdoption-mongod, cmdoption-mongos,

    • 他们指定了

To disable network compression, set the value to disabled.

  1. compression-options in Connection String URI Format and cmdoption-mongo,
    • 他们没有像第一点那样指定任何验证

根据以上几点,mongo-compass 可能需要它,而不是 mongo-shell!有关详细和具体的答案,您可以询问 MongoDB community Forum or post a bug in MongoDB Jira,


并且在将压缩指定为 snappy 后,它将读取以下内容:

An error occurred while loading navigation: Attempted to use Snappy compression, but Snappy is not installed. Install or disable Snappy compression and try again.

看这里term-snappy,

A compression/decompression library designed to balance efficient computation requirements with reasonable compression rates. Snappy is the default compression library for MongoDB’s use of WiredTiger. See Snappy and the WiredTiger compression documentation for more information.

如果要使用Snappy,需要单独安装。

结论:

您可以使用 zlib 而不是 Snappy,如果您不指定 compressors=disabledcompressors=zlib 则更好,因为默认情况下它将指定 compressors=snappy,zstd,zlib 所有 3未在 uri 中指定时的选项。