簡體   English   中英

Rocks DB WAL 文件具有高磁盤使用率

[英]Rocks DB WAL file has high disk usage

示例 rocksdb 消耗了約 75M 的磁盤空間,其中 WAL 文件 (*.log) 占用了約 71M 的磁盤空間。 但是 ls 命令顯示 WAL 文件的字節消耗實際上非常少。 我很想知道為什么一個內容非常少的 WAL 文件占用了如此多的磁盤空間,以及如何減少它。

du -h 的 Output *

4.0K 000004.sst 71M 000006.log 4.0K CURRENT 4.0K IDENTITY 0 LOCK 128K LOG 128K LOG.old.1669987718576391 4.0M MANIFEST-000005 8.0K OPTIONS-000005 8.0K OPTIONS8-00000

ls -lh -rw-r--r-- 的 Output。 1 北極星北極星 966 12 月 2 日 18:58 000004.sst -rw-r--r--。 1 北極星北極星 **40 **12 月 2 日 18:58 000006.log -rw-r--r--。 1 polaris polaris 16 Dec 2 18:58 CURRENT -rw-r--r--。 1 polaris polaris 37 Dec 2 18:57 IDENTITY -rw-r--r--。 1 北極星北極星 0 12 月 2 日 18:57 鎖定 -rw-rw-r--。 1 polaris polaris 16K Dec 2 18:58 LOG -rw-rw-r--。 1 polaris polaris 15K Dec 2 18:57 LOG.old.1669987718576391 -rw-r--r--。 1 北極星 polaris 166 Dec 2 18:58 MANIFEST-000005 -rw-r--r--。 1 北極星 polaris 4.5K Dec 2 18:57 OPTIONS-000005 -rw-r--r--。 1 北極星 polaris 4.5K Dec 2 18:58 OPTIONS-000008

示例程序

#include <cassert>
#include <string>
#include <rocksdb/db.h>
#include <iostream>

using namespace std;
int main(int argc, char** argv) {
    rocksdb::DB* db;
    rocksdb::Options options;
    options.create_if_missing = true;
    rocksdb::Status status =
    rocksdb::DB::Open(options, "/dev/shm/testdb", &db);
    assert(status.ok());
    // Insert value
    status = db->Put(rocksdb::WriteOptions(), "Test key", "Test value");
    assert(status.ok());
    // Read back value
    std::string value;
    status = db->Get(rocksdb::ReadOptions(), "Test key", &value);
    std::cout << value << '\n';
    assert(status.ok());
    assert(!status.IsNotFound());
    // Read key which does not exist
    status = db->Get(rocksdb::ReadOptions(), "This key does not exist", &value);
    assert(status.IsNotFound());
}

任何線索將不勝感激。 提前致謝

注意:如果我手動復制 WAL 文件,則復制的文件占用較少的磁盤空間(根據 du 命令為 4K)

有點像在std::vector上使用reserve() ,RocksDB 默認在其大部分fallocate文件上使用 fallocate 以最小化長期運行系統中的總體 I/O 成本。 請參閱allow_fallocate選項。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM