DEBUG.WIKI
IPPeak:从目标地区访问网页,住宅代理、SEO 监测、广告验证
阿里云;从建站到云上业务;云服务器 · 数据库 · 对象存储;查看产品 →
搬瓦工;先看线路,再选 VPS;CN2 GIA · 对应线路套餐;查看线路 →

解决 Grafana Loki 报错 boltdb-shipper read dir failed 索引同步失败修复

排查 Loki 索引同步组件报 boltdb-shipper: failed to read dir /data/loki/index: no such file or directory,分析 共享目录权限与 TSDB 索引迁移。

问题现象

Loki 启动自检阶段崩溃并循环重启:

level=error caller=shipper.go:210 msg="failed to sync index files from storage" err="boltdb-shipper: failed to read dir /data/loki/index: open /data/loki/index: permission denied"

触发根因

  1. Loki 容器运行用户(UID 10001)缺少对挂载的宿主机持久卷 /data/loki 的读写权限;
  2. 老旧的 boltdb-shipper 在新版 Loki 中已被官方弃用,全面推行基于对象存储的纯原生 tsdb 索引格式。

解决步骤

修正宿主机数据目录权限

在节点执行属组赋予:

sudo chown -R 10001:10001 /data/loki
sudo chmod -R 770 /data/loki

演进至 Loki 官方推荐的 TSDB 索引架构

在 loki.yaml 的 schema_config 中配置新世代 TSDB 索引引擎:

schema_config:
  configs:
    - from: 2026-01-01
      store: tsdb
      object_store: s3
      schema: v13
      index:
        prefix: index_
        period: 24h

验证确认

重新拉起 Loki:

索引直接作为原生 Parquet/TSDB 块推送到对象存储,完全免除本地 boltdb 同步锁死问题。