6

I use docker-compose under Windows 10 like so:

version: '3'

services:
  mongo:
    image: mongo:4.2
    ports:
      - "27017:27017"
    restart: always
    volumes:
      - type: bind
        source: ${PWD}/mongod.conf
        target: /etc/mongod.conf
    entrypoint: ["mongod", "--bind_ip_all", "--config", "/etc/mongod.conf"]

My mongod.conf:

storage:
  wiredTiger:
    collectionConfig:
      blockCompressor: zstd
      configString: "allocation_size=64KB,internal_page_max=64KB,leaf_page_max=64KB"

Still I get the same disk size use when I docker exec docker_mongo_1 df both with and without zstd. With zstd:

Filesystem     1K-blocks      Used Available Use% Mounted on
/dev/sda1       65792556  49263808  13156972  79% /data/db

Without:

Filesystem     1K-blocks      Used Available Use% Mounted on
/dev/sda1       65792556  47991952  14428828  77% /data/db

(The slight variation is due to randomness of inserted data, but the number of documents and their sizes is within a few percent of each other.) I used mongodump from snappy and mongorestore into zstd to ensure most documents are untouched before running some tests.

Is a zstandard installation required on the Mongo docker image? Or am I lacking some mongodb/docker configuration? Or is it really not effective for my data? If so: why is that and can I make it effective? Or is the docker platform the problem? Or is it Docker on Windows?

PS The reason I'm not posting on a dba forum is that the question is multi-disciplinary.

4

1 回答 1

6

您通过 mongodb 测量磁盘使用情况的方法不是一个好方法。docker不会使用自己的虚拟磁盘模拟虚拟机,因此df实际上会显示主机的磁盘使用统计信息(因此您的数字包括在 docker 之外发生的所有磁盘活动)。最好du -sh在 mongodb 存储数据的目录上运行。

于 2021-04-16T17:36:29.147 回答