tikv br 备份

tiup 部署tikv集群 使用br 备份

原来集群

tiup tikv-br backup raw --pd=“172.30.208.16:2379” --storage=“local:///backup/” --log-file=“/tmp/backup.log”


备份成功

想要在另一个配置相同的机器做恢复


执行成功
执行 tikv-ctl

没有结果

TiKV 什么版本?

/backup 是本地路径还是挂载的共享存储?

1 个赞

如果不是共享存储的话,需要每个 tikv node 的对应目录中放上集群全部的数据

版本是多少?生产环境建议使用共享存储,如果不是的话,每个tikv节点都需要完整的备份文件的

使用的是raw kv ?
TiKV | RawKV BR 使用手册

看恢复日志显示有928条kv恢复完成了

使用的是共享存储nfs, tikv版本6.1.0

rawkv

请分别发一下备份和恢复时候的日志 backup.log

先buckup
[2024/12/02 16:24:53.612 +08:00] [INFO] [info.go:37] [“Welcome to Backup & Restore (BR)”] [release-version=br-v1.1.0] [git-hash=fc7f9f9835abb50da0c9495f70ba6c80f6e670a4] [git-branch=HEAD] [go-version=go1.18.1] [utc-build-time=“2022-11-21 03:46:42”] [race-enabled=false]
[2024/12/02 16:24:53.612 +08:00] [INFO] [common.go:325] [arguments] [__command=“tikv-br backup raw”] [log-file=/tmp/backup.log] [pd=“[172.30.208.20:2379]”] [storage=local:///backup/]
[2024/12/02 16:24:53.612 +08:00] [INFO] [conn.go:244] [“new mgr”] [pdAddrs=172.30.208.20:2379]
[2024/12/02 16:24:53.613 +08:00] [INFO] [client.go:392] [“[pd] create pd client with endpoints”] [pd-address=“[http://172.30.208.20:2379]”]
[2024/12/02 16:24:53.615 +08:00] [INFO] [base_client.go:332] [“[pd] update member urls”] [old-urls=“[http://172.30.208.20:2379]”] [new-urls=“[http://172.30.208.20:2379,http://172.30.208.21:2379,http://172.30.208.23:2379]”]
[2024/12/02 16:24:53.615 +08:00] [INFO] [base_client.go:350] [“[pd] switch leader”] [new-leader=http://172.30.208.20:2379] [old-leader=]
[2024/12/02 16:24:53.615 +08:00] [INFO] [base_client.go:105] [“[pd] init cluster id”] [cluster-id=7443725052334244012]
[2024/12/02 16:24:53.616 +08:00] [INFO] [client.go:687] [“[pd] tso dispatcher created”] [dc-location=global]
[2024/12/02 16:24:53.616 +08:00] [WARN] [version.go:92] [“BR version is outdated, please consider use version 6.1.0 of BR”]
[2024/12/02 16:24:53.616 +08:00] [WARN] [version.go:92] [“BR version is outdated, please consider use version 6.1.0 of BR”]
[2024/12/02 16:24:53.616 +08:00] [WARN] [version.go:92] [“BR version is outdated, please consider use version 6.1.0 of BR”]
[2024/12/02 16:24:53.616 +08:00] [INFO] [conn.go:221] [“checked alive KV stores”] [aliveStores=3] [totalStores=3]
[2024/12/02 16:24:53.616 +08:00] [INFO] [client.go:392] [“[pd] create pd client with endpoints”] [pd-address=“[172.30.208.20:2379]”]
[2024/12/02 16:24:53.618 +08:00] [INFO] [base_client.go:332] [“[pd] update member urls”] [old-urls=“[http://172.30.208.20:2379]”] [new-urls=“[http://172.30.208.20:2379,http://172.30.208.21:2379,http://172.30.208.23:2379]”]
[2024/12/02 16:24:53.618 +08:00] [INFO] [base_client.go:350] [“[pd] switch leader”] [new-leader=http://172.30.208.20:2379] [old-leader=]
[2024/12/02 16:24:53.618 +08:00] [INFO] [base_client.go:105] [“[pd] init cluster id”] [cluster-id=7443725052334244012]
[2024/12/02 16:24:53.618 +08:00] [INFO] [client.go:687] [“[pd] tso dispatcher created”] [dc-location=global]
[2024/12/02 16:24:53.618 +08:00] [INFO] [client.go:80] [“new backup client”]
[2024/12/02 16:24:53.621 +08:00] [INFO] [client.go:294] [“backup started”] [startKey=] [endKey=] [rateLimit=0] [concurrency=0]
[2024/12/02 16:24:53.622 +08:00] [INFO] [client.go:711] [“try backup”] [store-id=1] [“retry time”=0]
[2024/12/02 16:24:53.623 +08:00] [INFO] [client.go:711] [“try backup”] [store-id=4] [“retry time”=0]
[2024/12/02 16:24:53.624 +08:00] [INFO] [client.go:711] [“try backup”] [store-id=5] [“retry time”=0]
[2024/12/02 16:24:53.626 +08:00] [INFO] [client.go:760] [“backup streaming finish”] [store-id=4] [retry-time=0]
[2024/12/02 16:24:53.627 +08:00] [INFO] [client.go:760] [“backup streaming finish”] [store-id=5] [retry-time=0]
[2024/12/02 16:24:53.648 +08:00] [INFO] [client.go:782] [“range backed up”] [store-id=1] [small-range-start-key=] [small-range-end-key=]
[2024/12/02 16:24:53.648 +08:00] [INFO] [client.go:760] [“backup streaming finish”] [store-id=1] [retry-time=0]
[2024/12/02 16:24:53.648 +08:00] [INFO] [client.go:316] [“finish backup push down”] [small-range-count=1]
[2024/12/02 16:24:53.648 +08:00] [INFO] [client.go:331] [“raw ranges backed up”] [startKey=] [endKey=] [cf=default]
[2024/12/02 16:24:53.648 +08:00] [INFO] [client.go:288] [“backup range finished”] [take=26.53638ms]
[2024/12/02 16:24:53.648 +08:00] [INFO] [metafile.go:329] [“write metas finished”] [type=datafile]
[2024/12/02 16:24:53.648 +08:00] [INFO] [metafile.go:369] [“finish the write metas”] [item=1] [type=datafile] [costs=26.705698ms]
[2024/12/02 16:24:53.648 +08:00] [INFO] [metafile.go:389] [“save backup meta”] [size=321]
[2024/12/02 16:24:53.652 +08:00] [INFO] [client.go:768] [“[pd] stop fetching the pending tso requests due to context canceled”] [dc-location=global]
[2024/12/02 16:24:53.652 +08:00] [INFO] [client.go:706] [“[pd] exit tso dispatcher”] [dc-location=global]
[2024/12/02 16:24:53.652 +08:00] [INFO] [collector.go:68] [“Raw backup success summary”] [total-ranges=1] [ranges-succeed=1] [ranges-failed=0] [backup-total-regions=1] [total-take=40.524237ms] [total-kv=930] [total-kv-size=280.5kB] [average-speed=6.921MB/s] [backup-data-size(after-compressed)=33.94kB]

之后 tiup cluster clean 集群名字 --all

restore
[2024/12/02 16:47:57.721 +08:00] [INFO] [info.go:37] [“Welcome to Backup & Restore (BR)”] [release-version=br-v1.1.0] [git-hash=fc7f9f9835abb50da0c9495f70ba6c80f6e670a4] [git-branch=HEAD] [go-version=go1.18.1] [utc-build-time=“2022-11-21 03:46:42”] [race-enabled=false]
[2024/12/02 16:47:57.721 +08:00] [INFO] [common.go:325] [arguments] [__command=“tikv-br restore raw”] [log-file=/tmp/restore.log] [pd=“[172.30.208.20:2379]”] [storage=local:///backup/]
[2024/12/02 16:47:57.721 +08:00] [INFO] [conn.go:244] [“new mgr”] [pdAddrs=172.30.208.20:2379]
[2024/12/02 16:47:57.723 +08:00] [INFO] [client.go:392] [“[pd] create pd client with endpoints”] [pd-address=“[http://172.30.208.20:2379]”]
[2024/12/02 16:47:57.725 +08:00] [INFO] [base_client.go:332] [“[pd] update member urls”] [old-urls=“[http://172.30.208.20:2379]”] [new-urls=“[http://172.30.208.20:2379,http://172.30.208.21:2379,http://172.30.208.23:2379]”]
[2024/12/02 16:47:57.725 +08:00] [INFO] [base_client.go:350] [“[pd] switch leader”] [new-leader=http://172.30.208.23:2379] [old-leader=]
[2024/12/02 16:47:57.725 +08:00] [INFO] [base_client.go:105] [“[pd] init cluster id”] [cluster-id=7443733303056498060]
[2024/12/02 16:47:57.725 +08:00] [INFO] [client.go:687] [“[pd] tso dispatcher created”] [dc-location=global]
[2024/12/02 16:47:57.726 +08:00] [WARN] [version.go:92] [“BR version is outdated, please consider use version 6.1.0 of BR”]
[2024/12/02 16:47:57.726 +08:00] [WARN] [version.go:92] [“BR version is outdated, please consider use version 6.1.0 of BR”]
[2024/12/02 16:47:57.726 +08:00] [WARN] [version.go:92] [“BR version is outdated, please consider use version 6.1.0 of BR”]
[2024/12/02 16:47:57.726 +08:00] [INFO] [conn.go:221] [“checked alive KV stores”] [aliveStores=3] [totalStores=3]
[2024/12/02 16:47:57.726 +08:00] [INFO] [client.go:392] [“[pd] create pd client with endpoints”] [pd-address=“[172.30.208.20:2379]”]
[2024/12/02 16:47:57.727 +08:00] [INFO] [base_client.go:332] [“[pd] update member urls”] [old-urls=“[http://172.30.208.20:2379]”] [new-urls=“[http://172.30.208.20:2379,http://172.30.208.21:2379,http://172.30.208.23:2379]”]
[2024/12/02 16:47:57.727 +08:00] [INFO] [base_client.go:350] [“[pd] switch leader”] [new-leader=http://172.30.208.23:2379] [old-leader=]
[2024/12/02 16:47:57.727 +08:00] [INFO] [base_client.go:105] [“[pd] init cluster id”] [cluster-id=7443733303056498060]
[2024/12/02 16:47:57.727 +08:00] [INFO] [client.go:687] [“[pd] tso dispatcher created”] [dc-location=global]
[2024/12/02 16:47:57.738 +08:00] [INFO] [import.go:248] [“multi ingest support”] [support=true]
[2024/12/02 16:47:57.739 +08:00] [INFO] [split.go:171] [“start to wait for scattering regions”] [regions=0] [take=284.096µs]
[2024/12/02 16:47:57.739 +08:00] [INFO] [split.go:183] [“waiting for scattering regions done”] [regions=0] [take=65ns]
[2024/12/02 16:47:57.739 +08:00] [INFO] [client.go:341] [“switch to import mode at beginning”]
[2024/12/02 16:47:57.743 +08:00] [INFO] [pd.go:418] [“pause scheduler successful at beginning”] [name=“[balance-region-scheduler,balance-leader-scheduler,balance-hot-region-scheduler]”]
[2024/12/02 16:47:57.745 +08:00] [INFO] [pd.go:426] [“pause configs successful at beginning”] [cfg=“{"enable-location-replacement":"false","leader-schedule-limit":12,"max-merge-region-keys":0,"max-merge-region-size":0,"max-pending-peer-count":2147483647,"max-snapshot-count":40,"region-schedule-limit":40}”]
[2024/12/02 16:47:57.746 +08:00] [INFO] [import.go:271] [“import file”] [files=“{total=1,files="[1_2_1_default.sst]",totalKVs=930,totalBytes=280477,totalSize=33937}”]
[2024/12/02 16:47:57.758 +08:00] [INFO] [import.go:366] [“download file done”] [file-sample=1_2_1_default.sst] [take=11.803586ms] [start=] [end=] [region=“{ID=2,startKey=endKey=epoch="conf_ver:5 version:1 ",peers="id:3 store_id:1 ,id:6 store_id:5 ,id:7 store_id:4 "}”]
[2024/12/02 16:47:57.766 +08:00] [INFO] [import.go:441] [“ingest file done”] [file-sample=1_2_1_default.sst] [take=20.257992ms]
[2024/12/02 16:47:57.766 +08:00] [INFO] [client.go:324] [“finish to restore raw range”] [startKey=] [endKey=]
[2024/12/02 16:47:57.767 +08:00] [INFO] [client.go:270] [“Restore Raw”] [startKey=] [endKey=] [take=21.678553ms]
[2024/12/02 16:47:57.795 +08:00] [INFO] [client.go:358] [“stop automatic switch to import mode”]
[2024/12/02 16:47:57.831 +08:00] [INFO] [pd.go:465] [“resume scheduler”] [schedulers=“[balance-region-scheduler,balance-leader-scheduler,balance-hot-region-scheduler]”]
[2024/12/02 16:47:57.831 +08:00] [INFO] [pd.go:451] [“exit pause scheduler and configs successful”]
[2024/12/02 16:47:57.832 +08:00] [INFO] [pd.go:485] [“resume scheduler successful”] [scheduler=balance-region-scheduler]
[2024/12/02 16:47:57.832 +08:00] [INFO] [pd.go:485] [“resume scheduler successful”] [scheduler=balance-leader-scheduler]
[2024/12/02 16:47:57.833 +08:00] [INFO] [pd.go:485] [“resume scheduler successful”] [scheduler=balance-hot-region-scheduler]
[2024/12/02 16:47:57.833 +08:00] [INFO] [pd.go:576] [“restoring config”] [config=“{"enable-location-replacement":"true","leader-schedule-limit":4,"max-merge-region-keys":200000,"max-merge-region-size":20,"max-pending-peer-count":64,"max-snapshot-count":64,"region-schedule-limit":2048}”]
[2024/12/02 16:47:57.836 +08:00] [INFO] [client.go:120] [“Restore client closed”]
[2024/12/02 16:47:57.836 +08:00] [INFO] [client.go:768] [“[pd] stop fetching the pending tso requests due to context canceled”] [dc-location=global]
[2024/12/02 16:47:57.836 +08:00] [INFO] [client.go:706] [“[pd] exit tso dispatcher”] [dc-location=global]
[2024/12/02 16:47:57.836 +08:00] [INFO] [collector.go:68] [“Raw restore success summary”] [total-ranges=1] [ranges-succeed=1] [ranges-failed=0] [restore-files=1] [total-take=115.283783ms] [restore-data-size(after-compressed)=33.94kB] [total-kv=930] [total-kv-size=280.5kB] [average-speed=2.433MB/s]

TiKV 里边是什么数据?

如果是 JuiceFS 写入,是 Transactional KV 数据。tikv-br 只支持备份和恢复 RawKV 数据。

对,是juicefs的数据,那juicfs的元数据会有丢失的风险,如何解决呢