doris支持通过腾讯云bos、阿里云oss、hdfs实现备份与恢复,但是我们公司doris部署在线下机房,如采用oss/bos, 大数据备份与恢复比较慢,会占用一定的带宽,如采用hdfs,担心小文件太多影响现有的hadoop集群。为了保险起见,而且能够达到快速的备份恢复,我们实现自主搭建一套minio对象存储。
1.当FE元数据发生损坏无法恢复时,我们能快速的从minio恢复,内网带宽拉满
2.当需要升级doris时,我们可以搭建一个测试集群,从minio快速copy数据测试
wget https://dl.minio.io/server/minio/release/linux-amd64/minio
mkdir /data01/minio;
mkdir /data02/minio;
mkdir /data03/minio;
mkdir /data04/minio;
mkdir /data05/minio;
#!/bin/bash
export MINIO_ACCESS_KEY=minio
export MINIO_SECRET_KEY=minioadmin
nohup /opt/minio/minio server --address=0.0.0.0:9898 /data01/minio /data02/minio /data03/minio /data04/minio /data05/minio>> /opt/minio/nohup.log 2>&1 &
端口自定义为9898
CREATE REPOSITORY `minio`
WITH S3
ON LOCATION "s3://doris"
PROPERTIES
(
"AWS_ENDPOINT" = "http://10.254.3.xx:9898",
"AWS_ACCESS_KEY" = "minio",
"AWS_SECRET_KEY"="minioadmin",
"AWS_REGION" = "us-east-1",
"use_path_style" = "true"
);
show repositories
BACKUP SNAPSHOT dal.snapshot_dal
TO minio
ON (example_tbl)
BACKUP SNAPSHOT dal.snapshot_dal
TO minio
use dal;
show backup;
SHOW SNAPSHOT ON minio;
RESTORE SNAPSHOT dal.snapshot_dal
FROM `minio`
PROPERTIES
(
"backup_timestamp"="2023-05-15-12-06-44",
"replication_num" = "3"
);
RESTORE SNAPSHOT dal.snapshot_dal
FROM `minio`
ON ( `backup_tbl` )
PROPERTIES
(
"backup_timestamp"="2023-05-15-12-06-44",
"replication_num" = "3"
);
当要快速恢复应用时,可以先暂时设置副本为1,后续再动态增加副本数
如果该表是动态分区表,备份之后会自动禁用动态分区属性,在做恢复的时候需要手动将该表的动态分区属性启用,命令如下:
ALTER TABLE tbl1 SET ("dynamic_partition.enable"="true")
但是官方并没有提供批量更改所有分区表的方法,以下为脚本:
#!/bin/bash
DORIS_HOST=xxxxxx
DORIS_PORT=xxxx
DORIS_USER=xxx
DORIS_PASSWORD=xxxx
databases=`mysql -h $DORIS_HOST -P $DORIS_PORT -u$DORIS_USER -p$DORIS_PASSWORD -e "show databases;"`
for db in ${databases};do
if [[ $db != 'Database' ]] && [[ $db != 'information_schema' ]];then
tables=`mysql -h $DORIS_HOST -P $DORIS_PORT -u$DORIS_USER -p$DORIS_PASSWORD -e "use $db;show tables;"`
for table in ${tables};do
if [[ $table =~ "Tables_in" ]];then
echo ""
else
echo $table
num=`mysql -h $DORIS_HOST -P $DORIS_PORT -u$DORIS_USER -p$DORIS_PASSWORD -e "show create table $db.$table\G" | grep "dynamic_partition.time_unit" | wc -l`
if [[ $num == 1 ]];then
sql="alter table $db.$table set ('dynamic_partition.enable'='true');"
echo $sql
mysql -h $DORIS_HOST -P $DORIS_PORT -u$DORIS_USER -p$DORIS_PASSWORD -e "$sql"
fi
fi
done
fi
done
外链:
minio: 基于AWS S3协议搭建个人云存储服务 - 简书
doris: RESTORE - Apache Doris