使用tikv当juicefs的元数据,使用使用tikv-br backup raw 备份数据后,备份的数据juicefs无法使用,数据量大小也明显不一样

【 TiDB 使用环境】测试
【 TiDB 版本】6.5.4
【复现路径】 备份恢复
【遇到的问题:问题现象及影响】

  1. 使用tikv当 juicefs 的元数据存储
  2. 备份tikv
sh backup.sh
Checking updates for component tikv-br... Timedout (after 2s)
Starting component tikv-br: /home/tidb/.tiup/components/tikv-br/v1.1.0/tikv-br backup raw --pd 10.21.9.28:2379 --storage s3://tidb-backup/juicefs-recovery-verify/juicefs-pro-backup-20240304-114051 --s3.endpoint http://10.21.9.31 --log-file log/backupraw-juicefs-pro-20240304114051.log --gcttl=2h --format=raw
Detail BR log in log/backupraw-juicefs-pro-20240304114051.log
Raw backup <------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
[2024/03/04 11:40:59.103 +08:00] [INFO] [collector.go:67] ["Raw backup success summary"] [total-ranges=344] [ranges-succeed=344] [ranges-failed=0] [backup-total-regions=372] [total-take=5.231582018s] [total-kv=2623767] [total-kv-size=7.289GB] [average-speed=1.393GB/s] [backup-data-size(after-compressed)=821.4MB]
  1. 恢复数据
Starting component tikv-br: /home/tidb/.tiup/components/tikv-br/v1.1.0/tikv-br restore raw --pd 10.21.8.33:2379 --s3.endpoint http://10.21.9.31 --storage s3://tidb-backup/juicefs-recovery-verify/juicefs-pro-backup-20240304-114051 --log-file restoreraw.log
Detail BR log in restoreraw.log
Raw Restore <-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
[2024/03/04 11:41:52.009 +08:00] [INFO] [collector.go:67] ["Raw restore success summary"] [total-ranges=344] [ranges-succeed=344] [ranges-failed=0] [restore-files=344] [total-take=5.044049245s] [restore-data-size(after-compressed)=821.4MB] [total-kv=2623767] [total-kv-size=7.289GB] [average-speed=1.445GB/s]
  1. juicefs连接恢复的数据
 juicefs status tikv://10.21.8.33:2379,10.21.8.34:2379,10.21.8.35:2379/juicefs_prd50
2024/03/04 11:49:22.755933 juicefs[720341] <INFO>: Meta address: tikv://10.21.8.33:2379,10.21.8.34:2379,10.21.8.35:2379/juicefs_prd50 [interface.go:497]
2024/03/04 11:49:22.756290 juicefs[720341] <INFO>: TiKV gc interval is set to 3h0m0s [tkv_tikv.go:84]
2024/03/04 11:49:22.772405 juicefs[720341] <FATAL>: load setting: database is not formatted, please run `juicefs format ...` first [status.go:96]
1 个赞

juicefs 用的是裸 kv,TiDB 官网好像没有提供裸 kv 备份工具 :thinking:

TiKV | RawKV BR 使用手册 这里有

1 个赞

太优秀了。

https://github.com/juicedata/juicefs/blob/main/pkg/meta/base.go#L427

是这里没有获取到数据。
往下翻,

https://github.com/juicedata/juicefs/blob/59659db8d67af0934836076a98e205f08fdf924d/pkg/meta/tkv.go#L480

key的名字就叫setting

https://github.com/juicedata/juicefs/blob/59659db8d67af0934836076a98e205f08fdf924d/pkg/meta/tkv.go#L362

get 一个key的实现就在这里,我觉得你可以用client-go包,自己写一段代码,看看在两个集群上,能否都get到setting这个key。

https://github.com/tikv/client-go

从tikv-br备份日志上,真的看不出任何问题,大小,key的数量都对的上。
整体感觉还是配置问题。大概率不是备份恢复的问题。

export AWS_ACCESS_KEY_ID=&{AWS_KEY_ID};
export AWS_SECRET_ACCESS_KEY=&{AWS_KEY};
tikv-br backup raw \
    --pd="&{PDIP}:2379" \
    --storage="s3://backup-data/2022-09-16/" \
    --dst-api-version v2 \
    --log-file="/tmp/backupraw.log \
    --gcttl=5m \
    --start="a" \
    --end="z" \
    --format="raw"

tikv-br backup raw --help

tikv-br backup raw --help