跳到主要内容

juicefs

不提供实际存储
  • 将对象存储暴露为 FS 存储协议
  • 维护 FS 元数据
  • 本身不存储数据
限制
limitfor
目录深度不限
文件名长度255
soft link 长度4096 bytes
hard link2^31
目录文件数2^31
volume 文件数unlimited
单文件大小2^(26+31) = 2^57 = 128 TiB
总文件大小4EiB
brew install juicefs # macOS

# 手动安装 Linux, Darwin
VER=$(curl -s https://api.github.com/repos/juicedata/juicefs/releases/latest | grep 'tag_name' | cut -d '"' -f 4 | tr -d 'v')
curl -L -o juicefs.tar.gz "https://github.com/juicedata/juicefs/releases/download/v${VER}/juicefs-${VER}-$(uname -s | tr '[:upper:]' '[:lower:]')-amd64.tar.gz"
tar zxvf juicefs.tar.gz juicefs
./juicefs version
sudo mv juicefs /usr/local/bin/

# META-URL MOUNTPOINT
# --storage file --bucket $HOME/.juicefs/local 为默认值
juicefs format \
--storage file --bucket $HOME/.juicefs/local \
sqlite3://jfs.db jfs

ls $HOME/.juicefs/local/jfs/
sqlite3 jfs.db "select * from jfs_setting"

# macOS 需要安装 macFUSE
brew install macfuse

# 100GB 缓存到 $HOME/.juicefs/cache
# 1h 元数据备份
# http://localhost:9567/metrics
juicefs mount \
--cache-dir $HOME/.juicefs/cache --cache-size 102400 \
--backup-meta 1h \
-o allow_other -o allow_root \
sqlite3://jfs.db $PWD/mnt

cd mnt
juicefs bench .

touch test.txt
touch $(cat /dev/urandom | tr -dc '0' | head -c 255) # 成功
touch $(cat /dev/urandom | tr -dc '0' | head -c 256) # 失败

cd -

juicefs info mnt/test.txt # 文件信息
juicefs info mnt # 目录信息
juicefs config sqlite3://jfs.db # 配置信息
juicefs status sqlite3://jfs.db # session 状态
juicefs gc sqlite3://jfs.db # 数据扫描
juicefs gc sqlite3://jfs.db --delete # 数据清理
juicefs fsck sqlite3://jfs.db # 数据校验
juicefs profile mnt # 操作监控
juicefs stats mnt # io 统计

juicefs gateway sqlite3://jfs.db 0.0.0.0:9090 # S3 网关

# 元数据备份
# --subdir 只备份指定目录
juicefs dump sqlite3://jfs.db meta.dump.json
# 元数据恢复 - 确保没有写入
juicefs load redis://127.0.0.1:6379/1 meta.dump.json

# 数据清空
UUID=$(juicefs status sqlite3://jfs.db | jq .Setting.UUID -r)
# 所有 session 断开后才可以操作
juicefs destroy sqlite3://jfs.db $UUID
du -sh $HOME/.juicefs/local/jfs/
  • ~/.juicefs/local/jfs/
    • juicefs_uuid
    • chunks/
    • testing/
    • meta/
      • dump-2023-03-16-174211.json.gz
  • /mnt/
    • .accesslog
    • .config
    • .stats - 统计
    • .trash/
      • YYYY-mm-dd-hh/
        • {父目录 inode}-{文件 inode}-{原始文件名} - 查询 inode juicefs info -i 3
    • meta/ - 元数据备份
  • backup-meta
    • ⚠️ 超过 100 万 则不在每 1h 自动备份,需要手动配置更大间隔
    • Redis 100 万 1 分钟 1GB 内存
    • 清理规则
      • 保留 2 天完整
      • < 2 周, 每天保留 1 份
      • < 2 月, 每周保留 1 份
      • 2 月, 每月保留 1 份

  • file
    • $HOME/.juicefs/local
    • /var/jfs
    • C:/jfs/local
  • fuse 选项
  • pjd/pjdfstest
    • POSIX test suite
  • linux-test-project/ltp

Docker

docker plugin install juicedata/juicefs --alias juicefs

docker volume create -d juicefs \
-o name=VOLUME_NAME \
-o metaurl=META_URL \
-o storage=STORAGE_TYPE \
-o bucket=BUCKET_NAME \
-o access-key=ACCESS_KEY \
-o secret-key=SECRET_KEY \
jfsvolume

# 已有 volume
docker volume create -d juicefs \
-o name=VOLUME_NAME \
-o metaurl=META_URL \
jfsvolume

docker run -it -v jfsvolume:/opt wener/base ls /opt

docker volume rm jfsvolume

# disable,upgrade,enable,rm
docker plugin disable juicefs

SQL

  • storage
    • jfs_blob
  • metadata
    • jfs_chunk
    • jfs_chunk_ref
    • jfs_counter
    • jfs_delfile
    • jfs_delslices
    • jfs_detached_node
    • jfs_dir_quota
    • jfs_dir_stats
    • jfs_edge
    • jfs_flock
    • jfs_node
    • jfs_plock
    • jfs_session2
    • jfs_setting
    • jfs_sustained
    • jfs_symlink
    • jfs_xattr