首页 > 其他分享 >使用br工具备份到local的一些操作

使用br工具备份到local的一些操作

时间:2023-11-13 12:31:35浏览次数:23  
标签:pingcap local 备份 pkg br tidb go com

作者: hellogitee


背景

最近业务有一个需求,为防止机房级别的故障,想要在异地机房新搭建一套TiDB集群做备用,以便能随时进行机房级别的切换。这种需求当然是要用TiCDC来同步啦,第一要步就是通过br工具进行备份,然后再来同步。



官方文档&FAQ

备份存储的选择

官方文档建议使用S3或者NFS,如果使用local的话,因为br备份是将tikv的各个节点数据保存到本地目录,在恢复的时候需要将所有的tikv节点备份数据合并到一起后才能使用,这样比较麻烦,被官方不推荐使用。

但咱不是没那条件么,合并麻烦是麻烦,但总归是条路子。

https://docs.pingcap.com/zh/tidb/dev/br-use-overview#如何管理备份数据

备份用户的权限和注意项

看FAQ,要求备份的目录要具有读写权限,如果 br 工具和 TiKV 位于不同的机器,则需要用户的 UID 相同。

权限可以理解,但为啥uid也要完全一致?

https://docs.pingcap.com/zh/tidb/stable/backup-and-restore-faq#遇到-permission-denied-或者-no-such-file-or-directory-错误即使用-root-运行-br-命令行工具也无法解决该如何处理

以下为具体测试步骤。



实验步骤



环境准备

使用三台测试机

dbpnew129v    10.10.10.1
dbpnew130v    10.10.10.2
dbpnew131v    10.10.10.3

查看三台备份用户的uid(为啥用kibana用户,因为我也在测试es。。)

[kibana@dbpnew129v backup]$ id
uid=49480(kibana) gid=49479(kibana) groups=49479(kibana)

[kibana@dbpnew130v ~]$ id 
uid=49479(kibana) gid=49479(kibana) groups=49479(kibana)

[kibana@dbpnew131v ~]$ id
uid=49478(kibana) gid=49479(kibana) groups=49479(kibana)

测试tidb版本

[kibana@dbpnew129v backup]$ tiup cluster display test2
tiup is checking updates for component cluster ...
Starting component `cluster`: /home/kibana/.tiup/components/cluster/v1.13.0/tiup-cluster display test2
Cluster type:       tidb
Cluster name:       test2
Cluster version:    v6.5.2
Deploy user:        kibana
SSH type:           builtin
Dashboard URL:      http://10.10.10.1:2379/dashboard
Grafana URL:        http://10.10.10.1:3000
ID                   Role          Host           Ports        OS/Arch       Status   Data Dir                            Deploy Dir
--                   ----          ----           -----        -------       ------   --------                            ----------
10.10.10.1:9093    alertmanager  10.10.10.1   9093/9094    linux/x86_64  Up       /data1/tidb-data/alertmanager-9093  /data1/tidb-deploy/alertmanager-9093
10.10.10.1:3000    grafana       10.10.10.1   3000         linux/x86_64  Up       -                                   /data1/tidb-deploy/grafana-3000
10.10.10.2:2379   pd            10.10.10.2  2379/2380    linux/x86_64  Up       /data1/tidb-data/pd-2379            /data1/tidb-deploy/pd-2379
10.10.10.1:2379    pd            10.10.10.1   2379/2380    linux/x86_64  Up|L|UI  /data1/tidb-data/pd-2379            /data1/tidb-deploy/pd-2379
10.10.10.3:2379    pd            10.10.10.3   2379/2380    linux/x86_64  Up       /data1/tidb-data/pd-2379            /data1/tidb-deploy/pd-2379
10.10.10.1:9090    prometheus    10.10.10.1   9090/12020   linux/x86_64  Up       /data1/tidb-data/prometheus-9090    /data1/tidb-deploy/prometheus-9090
10.10.10.2:4000   tidb          10.10.10.2  4000/10080   linux/x86_64  Up       -                                   /data1/tidb-deploy/tidb-4000
10.10.10.1:4000    tidb          10.10.10.1   4000/10080   linux/x86_64  Up       -                                   /data1/tidb-deploy/tidb-4000
10.10.10.3:4000    tidb          10.10.10.3   4000/10080   linux/x86_64  Up       -                                   /data1/tidb-deploy/tidb-4000
10.10.10.2:20160  tikv          10.10.10.2  20160/20180  linux/x86_64  Up       /data1/tidb-data/tikv-20160         /data1/tidb-deploy/tikv-20160
10.10.10.1:20160   tikv          10.10.10.1   20160/20180  linux/x86_64  Up       /data1/tidb-data/tikv-20160         /data1/tidb-deploy/tikv-20160
10.10.10.3:20160   tikv          10.10.10.3   20160/20180  linux/x86_64  Up       /data1/tidb-data/tikv-20160         /data1/tidb-deploy/tikv-20160

开始备份

[kibana@dbpnew129v data1]$ tiup br backup full --pd 10.10.10.2:2379 --storage "local:///data1/backup"

因为/data1是777权限,而指定的/data1/backup子目录并没有提前创建,于是备份吐出一大堆的错误信息,感受到了满屏的伤害。。。

## 截取部分日志
[2023/09/11 10:55:24.686 +08:00] [INFO] [collector.go:77] ["Full Backup failed summary"] [total-ranges=80] [ranges-succeed=0] [ranges-failed=80] [backup-total-ranges=80] [backup-total-regions=82] [unit-name="range start:7480000000000000485f720000000000000000 end:7480000000000000485f72ffffffffffffffff00"] [error="rpc error: code = Canceled desc = context canceled"] [errorVerbose="rpc error: code = Canceled desc = context canceled\ngithub.com/tikv/pd/client.(*client).respForErr\n\t/go/pkg/mod/github.com/tikv/pd/[email protected]/client.go:1582\ngithub.com/tikv/pd/client.(*client).GetAllStores\n\t/go/pkg/mod/github.com/tikv/pd/[email protected]/client.go:1189\ngithub.com/pingcap/tidb/br/pkg/conn/util.GetAllTiKVStores\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/util/util.go:39\ngithub.com/pingcap/tidb/br/pkg/conn.GetAllTiKVStoresWithRetry.func1\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/conn.go:83\ngithub.com/pingcap/tidb/br/pkg/utils.WithRetry\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/utils/retry.go:56\ngithub.com/pingcap/tidb/br/pkg/conn.GetAllTiKVStoresWithRetry\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/conn.go:80\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).BackupRange\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:893\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).BackupRanges.func2\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:852\ngithub.com/pingcap/tidb/br/pkg/utils.(*WorkerPool).ApplyOnErrorGroup.func1\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/utils/worker.go:76\ngolang.org/x/sync/errgroup.(*Group).Go.func1\n\t/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1598"] [unit-name="range start:7480000000000000185f720000000000000000 end:7480000000000000185f72ffffffffffffffff00"] [error="rpc error: code = Canceled desc = context canceled"] [errorVerbose="rpc error: code = Canceled desc = context canceled\ngithub.com/tikv/pd/client.(*client).respForErr\n\t/go/pkg/mod/github.com/tikv/pd/[email protected]/client.go:1582\ngithub.com/tikv/pd/client.(*client).GetAllStores\n\t/go/pkg/mod/github.com/tikv/pd/[email protected]/client.go:1189\ngithub.com/pingcap/tidb/br/pkg/conn/util.GetAllTiKVStores\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/util/util.go:39\ngithub.com/pingcap/tidb/br/pkg/conn.GetAllTiKVStoresWithRetry.func1\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/conn.go:83\ngithub.com/pingcap/tidb/br/pkg/utils.WithRetry\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/utils/retry.go:56\ngithub.com/pingcap/tidb/br/pkg/conn.GetAllTiKVStoresWithRetry\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/conn.go:80\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).BackupRange\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:893\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).BackupRanges.func2\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:852\ngithub.com/pingcap/tidb/br/pkg/utils.(*WorkerPool).ApplyOnErrorGroup.func1\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/utils/worker.go:76\ngolang.org/x/sync/errgroup.(*Group).Go.func1\n\t/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1598"] [unit-name="range start:748000fffffffffffd5f720000000000000000 end:748000fffffffffffd5f72ffffffffffffffff00"] [error="rpc error: code = Canceled desc = context canceled"] [errorVerbose="rpc error: code = Canceled desc = context canceled\ngithub.com/tikv/pd/client.(*client).respForErr\n\t/go/pkg/mod/github.com/tikv/pd/[email protected]/client.go:1582\ngithub.com/tikv/pd/client.(*client).GetAllStores\n\t/go/pkg/mod/github.com/tikv/pd/[email protected]/client.go:1189\ngithub.com/pingcap/tidb/br/pkg/conn/util.GetAllTiKVStores\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/util/util.go:39\ngithub.com/pingcap/tidb/br/pkg/conn.GetAllTiKVStoresWithRetry.func1\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/conn.go:83\ngithub.com/pingcap/tidb/br/pkg/utils.WithRetry\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/utils/retry.go:56\ngithub.com/pingcap/tidb/br/pkg/conn.GetAllTiKVStoresWithRetry\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/conn.go:80\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).BackupRange\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:893\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).BackupRanges.func2\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:852\ngithub.com/pingcap/tidb/br/pkg/utils.(*WorkerPool).ApplyOnErrorGroup.func1\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/utils/worker.go:76\ngolang.org/x/sync/errgroup.(*Group).Go.func1\n\t/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1598"] [unit-name="range start:7480000000000000205f720000000000000000 end:7480000000000000205f72ffffffffffffffff00"] [error="rpc error: code = Canceled desc = context canceled"] [errorVerbose="rpc error: code = Canceled desc = context canceled\ngithub.com/tikv/pd/client.(*client).respForErr\n\t/go/pkg/mod/github.com/tikv/pd/[email protected]/client.go:1582\ngithub.com/tikv/pd/client.(*client).GetAllStores\n\t/go/pkg/mod/github.com/tikv/pd/[email protected]/client.go:1189\ngithub.com/pingcap/tidb/br/pkg/conn/util.GetAllTiKVStores\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/util/util.go:39\ngithub.com/pingcap/tidb/br/pkg/conn.GetAllTiKVStoresWithRetry.func1\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/conn.go:83\ngithub.com/pingcap/tidb/br/pkg/utils.WithRetry\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/utils/retry.go:56\ngithub.com/pingcap/tidb/br/pkg/conn.GetAllTiKVStoresWithRetry\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/conn.go:80\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).BackupRange\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:893\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).BackupRanges.func2\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:852\ngithub.com/pingcap/tidb/br/pkg/utils.(*WorkerPool).ApplyOnErrorGroup.func1\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/utils/worker.go:76\ngolang.org/x/sync/errgroup.(*Group).Go.func1\n\t/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1598"] [unit-name="range start:74800000000000002e5f69800000000000000300 end:74800000000000002e5f698000000000000003fb"] [error="rpc error: code = Canceled desc = context canceled"] [errorVerbose="rpc error: code = Canceled desc = context canceled\ngithub.com/tikv/pd/client.(*client).respForErr\n\t/go/pkg/mod/github.com/tikv/pd/[email protected]/client.go:1582\ngithub.com/tikv/pd/client.(*client).GetAllStores\n\t/go/pkg/mod/github.com/tikv/pd/[email protected]/client.go:1189\ngithub.com/pingcap/tidb/br/pkg/conn/util.GetAllTiKVStores\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/util/util.go:39\ngithub.com/pingcap/tidb/br/pkg/conn.GetAllTiKVStoresWithRetry.func1\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/conn.go:83\ngithub.com/pingcap/tidb/br/pkg/utils.WithRetry\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/utils/retry.go:56\ngithub.com/pingcap/tidb/br/pkg/conn.GetAllTiKVStoresWithRetry\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/conn.go:80\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).BackupRange\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:893\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).BackupRanges.func2\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:852\ngithub.com/pingcap/tidb/br/pkg/utils.(*WorkerPool).ApplyOnErrorGroup.func1\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/utils/worker.go:76\ngolang.org/x/sync/errgroup.(*Group).Go.func1\n\t/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1598"] [unit-name="range start:7480000000000000345f720000000000000000 end:7480000000000000345f72ffffffffffffffff00"] [error="rpc error: code = Canceled desc = context canceled"] [errorVerbose="rpc error: code = Canceled desc = context canceled\ngithub.com/tikv/pd/client.(*client).respForErr\n\t/go/pkg/mod/github.com/tikv/pd/[email protected]/client.go:1582\ngithub.com/tikv/pd/client.(*client).GetAllStores\n\t/go/pkg/mod/github.com/tikv/pd/[email protected]/client.go:1189\ngithub.com/pingcap/tidb/br/pkg/conn/util.GetAllTiKVStores\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/util/util.go:39\ngithub.com/pingcap/tidb/br/pkg/conn.GetAllTiKVStoresWithRetry.func1\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/conn.go:83\ngithub.com/pingcap/tidb/br/pkg/utils.WithRetry\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/utils/retry.go:56\ngithub.com/pingcap/tidb/br/pkg/conn.GetAllTiKVStoresWithRetry\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/conn.go:80\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).BackupRange\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:893\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).BackupRanges.func2\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:852\ngithub.com/pingcap/tidb/br/pkg/utils.(*WorkerPool).ApplyOnErrorGroup.func1\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/utils/worker.go:76\ngolang.org/x/sync/errgroup.(*Group).Go.func1\n\t/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1598"] [unit-name="range start:7480000000000000365f720000000000000000 end:7480000000000000365f72ffffffffffffffff00"] [error="rpc error: code = Canceled desc = context canceled"] [errorVerbose="rpc error: code = Canceled desc = context canceled\ngithub.com/tikv/pd/client.(*client).respForErr\n\t/go/pkg/mod/github.com/tikv/pd/[email protected]/client.go:1582\ngithub.com/tikv/pd/client.(*client).GetAllStores\n\t/go/pkg/mod/github.com/tikv/pd/[email protected]/client.go:1189\ngithub.com/pingcap/tidb/br/pkg/conn/util.GetAllTiKVStores\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/util/util.go:39\ngithub.com/pingcap/tidb/br/pkg/conn.GetAllTiKVStoresWithRetry.func1\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/conn.go:83\ngithub.com/pingcap/tidb/br/pkg/utils.WithRetry\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/utils/retry.go:56\ngithub.com/pingcap/tidb/br/pkg/conn.GetAllTiKVStoresWithRetry\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/conn.go:80\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).BackupRange\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:893\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).BackupRanges.func2\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:852\ngithub.com/pingcap/tidb/br/pkg/utils.(*WorkerPool).ApplyOnErrorGroup.func1\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/utils/worker.go:76\ngolang.org/x/sync/errgroup.(*Group).Go.func1\n\t/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1598"] [unit-name="range start:7480000000000000105f69800000000000000100 end:7480000000000000105f698000000000000001fb"] [error="rpc error: code = Canceled desc = context canceled"] [errorVerbose="rpc error: code = Canceled desc = context canceled\ngithub.com/tikv/pd/client.(*client).respForErr\n\t/go/pkg/mod/github.com/tikv/pd/[email protected]/client.go:1582\ngithub.com/tikv/pd/client.(*client).GetAllStores\n\t/go/pkg/mod/github.com/tikv/pd/[email protected]/client.go:1189\ngithub.com/pingcap/tidb/br/pkg/conn/util.GetAllTiKVStores\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/util/util.go:39\ngithub.com/pingcap/tidb/br/pkg/conn.GetAllTiKVStoresWithRetry.func1\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/conn.go:83\ngithub.com/pingcap/tidb/br/pkg/utils.WithRetry\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/utils/retry.go:56\ngithub.com/pingcap/tidb/br/pkg/conn.GetAllTiKVStoresWithRetry\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/conn/conn.go:80\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).BackupRange\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:893\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).BackupRanges.func2\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:852\ngithub.com/pingcap/tidb/br/pkg/utils.(*WorkerPool).ApplyOnErrorGroup.func1\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/utils/worker.go:76\ngolang.org/x/sync/errgroup.(*Group).Go.func1\n\t/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1598"] [unit-name="range start:7480000000000000165f720000000000000000 end:7480000000000000165f72ffffffffffffffff00"] [error="rpc error: code = Canceled desc = context canceled"] [errorVerbose="rpc error: code = Canceled desc = context canceled\ngithub.com/tikv/pd/client.(*client).respForErr\n\t/go/pkg/mod/github.com/tikv/pd/[email protected]/client.go:1582\ngithub.com/tikv/pd/client.(*client).GetAllStores\n\t/go/pkg/mod/github.com/tikv/pd/[email protected]/client.go:1
Error: error happen in store 5 at 10.10.10.2:20160: File or directory not found on TiKV Node (store id: 5; Address: 10.10.10.2:20160). work around:please ensure br and tikv nodes share a same storage and the user of br and tikv has same uid.: [BR:KV:ErrKVStorage]tikv storage occur I/O error

通过最后一条输出看到提示文件或目录在tikv节点不存在。

再查看/tmp/br下产生的备份日志:

[2023/09/11 10:55:24.680 +08:00] [ERROR] [push.go:206] [range-sn=0] [error="[BR:KV:ErrKVStorage]tikv storage occur I/O error: File or directory not found on TiKV Node (store id: 5; Address: 10.10.10.2:20160). work around:please ensure br and tikv nodes share a same storage and the user of br and tikv has same uid."] [stack="github.com/pingcap/tidb/br/pkg/backup.(*pushDown).pushBackup\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/push.go:206\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).BackupRange\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:938\ngithub.com/pingcap/tidb/br/pkg/backup.(*Client).BackupRanges.func2\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/backup/client.go:852\ngithub.com/pingcap/tidb/br/pkg/utils.(*WorkerPool).ApplyOnErrorGroup.func1\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/br/br/pkg/utils/worker.go:76\ngolang.org/x/sync/errgroup.(*Group).Go.func1\n\t/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75"]

看提示错误是:必须共享相同的存储,且使用br工具备份的用户和运行tikv节点的用户,必须具有相同的uid。



问题解决

看到这种报错的意思,只能搞S3或者NFS共享文件存储了,既然提示没有文件或目录,那我提前创建下呢?

## 三个tikv节点使用br备份用户提前创建/data1/backup目录
[kibana@dbpnew131v data1]$ mkdir /data1/backup

## 再次使用br工具进行备份
[kibana@dbpnew129v data1]$ tiup br backup full --pd 10.10.10.2:2379 --storage "local:///data1/backup" 
tiup is checking updates for component br ...
Starting component `br`: /home/kibana/.tiup/components/br/v7.3.0/br backup full --pd 10.10.10.2:2379 --storage local:///data1/backup
Detail BR log in /tmp/br.log.2023-09-11T11.40.17+0800 
Full Backup <------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
Checksum <---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
[2023/09/11 11:40:24.602 +08:00] [INFO] [collector.go:77] ["Full Backup success summary"] [total-ranges=27] [ranges-succeed=27] [ranges-failed=0] [backup-checksum=569.677625ms] [backup-fast-checksum=9.318469ms] [backup-total-ranges=80] [backup-total-regions=82] [total-take=6.64338341s] [total-kv-size=86.32MB] [average-speed=12.99MB/s] [backup-data-size(after-compressed)=5.027MB] [Size=5026872] [BackupTS=444177742312505345] [total-kv=2098905]
[kibana@dbpnew129v data1]$

竟然成功了!!



问题总结

  • 在使用br工具做备份时,如果使用local的方式时,不能只确保备份的目录对启动各个tikv节点用户具有读写权限,还要确保备份指定的目录要实际存在(br节点会自己创建一个777的备份目录);
  • 备份日志提示有误导,提示【please ensure br and tikv nodes share a same storage and the user of br and tikv has same uid】与实际表现不对,实际上只是因为备份指定的实际目录没创建而已;
  • 文档FAQ中,对使用本地磁盘备份要求【如果 br 工具和 TiKV 位于不同的机器,则需要用户的 UID 相同】,这一点并不是必须的,因为实际我uid不同也是能正常备份的;
  • 后面测试即使启动tikv的用户和备份的br用户不通,只要保证目录存在且具有读写权限,也是能正常备份成功的;

一句话,保证备份命令中指定的目录实际存在并使其对tikv具有读写权限(不能只确保父目录,因为备份时并不会实际替咱们创建),不管你用啥用户,不管uid是否一致,都能备份成功!!

标签:pingcap,local,备份,pkg,br,tidb,go,com
From: https://blog.51cto.com/tidb/8341489

相关文章

  • HyperLedger Fabric 1.2 区块链技术形成(1.2)
    在比特币诞生之时,没有区块链技术概念,当人们看到比特币在无中心干预的前提下,还能安全、可靠的运行,比特币网络打开了人们的想象空间;技术专家们开始研究比特币的底层技术,并抽象提取出来,形成区块链技术,或者称分布式账本技术。   区块链技术:简称BT(Blockchaintechnology),也称为分......
  • HyperLedger Fabric 1.2 区块链技术定义(2.1)
    区块链技术指使用点对点传输、共识机制、加密算法等技术,保证分布式数据库区块写入链中数据的一致性,达到去中心化和不可篡改的目的。    区块链就是一种特殊的分布式数据库,使用现有的各种成熟的技术,把各种技术集成在一起,实现多方共识、去中心化、分布式和不可篡改等技术特点......
  • HyperLedger Fabric 1.2 区块链工作过程(2.3)
    区块链的工作过程分交易产生、交易广播、节点计算、获取记账权、记账权广播、接收区块、验证区块和完成记账七个过程。1)交易产生:用户向区块链发了一笔交易信息,将产生交易;2)交易广播:当一笔新交易产生时,区块链网络会广播出去,网络中的其它节点都会收到该交易信息;3)节点计算:收到......
  • HyperLedger Fabric 1.2 区块链技术原理(2.2)
    区块链从字面上理解:数据记录在区块中,通过一定的算法把区块连成一个链。    区块链通过哈希(Hash)算法,生成一串字符串,保存在区块的头部中,一个的区块通过指向上一个Hash值,加入到区块链中;Hash算法是一种加密算法,指对原始信息进行特定的转换运算,换算成对应的加密值(称为Hash值);是一......
  • HyperLedger Fabric 1.2 区块链应用场景(3.1)
    比特币是区块链应用最早的场景,随着比特币安全稳定运行多年以后,数字货币的场景应用遍地开花,各种山寨币泛滥,通过ICO(InitialCoinOffering首次币发行)就能融到大量资金,上市后的数字货币就像股票一样可以进自由交易,这类应用主流称为区块链1.0。    技术人员通过对比特币等数......
  • HyperLedger Fabric 1.2 区块链开发平台(4.1)
    目前区块链开发平台分“公有链平台”和“联盟链系统”两类,“公有链平台”主要以以太坊为主的平台,可以在该类平台上进行代币的发行和根据各种模块搭建应用;“联盟链系统”主要以超级账本为主的开源系统,该类开源系统提供完善的区块链底层技术,开发者只要在其框架下进行二次开发,根据自......
  • HyperLedger Fabric 1.2 超级账本起源(5.1)
    至比特币开源以来,无数技术人员对其进行研究,并且对该系统经过了无数次改进,超级账本项目(Hyperledger)最初也是用来改善比特币的底层技术,最终由Linux基金会组织发展起来。    开放式账本项目(OpenLedgerProject)是超级账本(Hyperledger)前身,由Linux基金会于2023年11月13日发起的......
  • library cache lock/pin等待事件
    概念描述Librarycachelock控制对于LibraryCacheObject的并发访问,通过获取ObjectHandle上的锁定持有。通常在定位LibraryCache对象时,就需要持有librarycachelock。对包,存储过程,函数,视图进行编译的时候,Oracle就会在这些对象的handle上面首先获得一个LibraryCacheLock;然后在......
  • Brew安装的MySQL8.0忘记密码修改密码
    #查看my.ini位置$mysqld--help--verbose|more#找到这一行,挨个试试,看存不存在#/etc/my.cnf/etc/mysql/my.cnf/usr/local/etc/my.cnf~/.my.cnf$ls/etc/my.cnfls:/etc/my.cnf:Nosuchfileordirectory$ls/etc/mysql/my.cnfls:/etc/mysql/my.cnf:Nos......
  • 面试10000次依然会问的【ThreadLocal】,你还不会?
    ThreadLocal简介与基本概念ThreadLocal,即线程局部变量,是Java语言中用于实现线程数据隔离的一个重要类。这种机制允许在多线程环境中,每个线程都有自己的变量副本,从而使得每个线程都可以独立地改变自己的副本,而不会影响其他线程的副本。这种特性对于保证线程安全至关重要,尤其是在处......