Clickhouse备份恢复_clickhouse-client方式backup命令之备份目录的设置

https://clickhouse.com/docs/en/operations/backup#command-summary

想要backup database dbname to Disk('diskname','backupfilename.zip')成功的话,需要符合3点

1、diskname需要在/etc/clickhouse-server/config.d/backup_disk.xml在<storage_configuration></storage_configuration>中存在

2、diskname需要在/etc/clickhouse-server/config.d/backup_disk.xml在<allowed_disk></allowed_disk>中存在

3、diskname需要在select name,path,type from system.disks结果集中存在

案例1、备份目录配置及备份状况

sql 复制代码
[root@CHDBDEV ~]# cat /etc/clickhouse-server/config.d/backup_disk.xml
<clickhouse>
    <storage_configuration>
        <disks>
            <backups>
                <type>local</type>
                <path>/backups/123/</path>
            </backups>
        </disks>
    </storage_configuration>
    <backups>
        <allowed_disk>baks</allowed_disk>
        <allowed_path>/backups/345/</allowed_path>
    </backups>
</clickhouse>


CHDBDEV :) select name,path,type,is_read_only,is_write_once,is_remote,is_broken from system.disks;
   ┌─name────┬─path─────────────────────┬─type──┬─is_read_only─┬─is_write_once─┬─is_remote─┬─is_broken─┐
1. │ backups │ /backups/123/            │ Local │            0 │             0 │         0 │         0 │
2. │ default │ /chdata/clickhouse/data/ │ Local │            0 │             0 │         0 │         0 │
   └─────────┴──────────────────────────┴───────┴──────────────┴───────────────┴───────────┴───────────┘

CHDBDEV :) backup database lukestest1 to Disk('backups','lukestest1_2024.zip');
Received exception from server (version 24.4.1):
Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: Disk ''backups'' is not allowed for backups, see the 'backups.allowed_disk' configuration parameter. (BAD_ARGUMENTS)

CHDBDEV :) backup database lukestest1 to Disk('default','lukestest1_2024.zip');
Received exception from server (version 24.4.1):
Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: Disk ''default'' is not allowed for backups, see the 'backups.allowed_disk' configuration parameter. (BAD_ARGUMENTS)

案例2、备份目录配置及备份状况

sql 复制代码
[root@CHDBDEV ~]# cat /etc/clickhouse-server/config.d/backup_disk.xml
<clickhouse>
    <storage_configuration>
        <disks>
            <backups>
                <type>local</type>
                <path>/backups/123/</path>
            </backups>
        </disks>
    </storage_configuration>
    <backups>
        <allowed_disk>backups</allowed_disk>
        <allowed_path>/backups/123/</allowed_path>
    </backups>
</clickhouse>

CHDBDEV :) select name,path,type,is_read_only,is_write_once,is_remote,is_broken from system.disks;
   ┌─name────┬─path─────────────────────┬─type──┬─is_read_only─┬─is_write_once─┬─is_remote─┬─is_broken─┐
1. │ backups │ /backups/123/            │ Local │            0 │             0 │         0 │         0 │
2. │ default │ /chdata/clickhouse/data/ │ Local │            0 │             0 │         0 │         0 │
   └─────────┴──────────────────────────┴───────┴──────────────┴───────────────┴───────────┴───────────┘

CHDBDEV :) backup database lukestest1 to Disk('backups','lukestest1_2024.zip');
   ┌─id───────────────────────────────────┬─status─────────┐
1. │ 803d8178-49fe-4f82-bf82-b70881496f0e │ BACKUP_CREATED │
   └──────────────────────────────────────┴────────────────┘

CHDBDEV :) backup database lukestest1 to Disk('default','lukestest1_2024.zip');
Received exception from server (version 24.4.1):
Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: Disk ''default'' is not allowed for backups, see the 'backups.allowed_disk' configuration parameter. (BAD_ARGUMENTS)

案例3、备份目录配置及备份状况

sql 复制代码
[root@CHDBDEV ~]# cat /etc/clickhouse-server/config.d/backup_disk.xml
<clickhouse>
    <storage_configuration>
        <disks>
            <backups>
                <type>local</type>
                <path>/backups/123/</path>
            </backups>
        </disks>
    </storage_configuration>
    <backups>
        <allowed_disk>backups</allowed_disk>
        <allowed_path>/backups/123/</allowed_path>
    </backups>
   <backups>
        <allowed_disk>default</allowed_disk>
        <allowed_path>/chdata/clickhouse/data/</allowed_path>
    </backups>
</clickhouse>

CHDBDEV :) select name,path,type,is_read_only,is_write_once,is_remote,is_broken from system.disks;
   ┌─name────┬─path─────────────────────┬─type──┬─is_read_only─┬─is_write_once─┬─is_remote─┬─is_broken─┐
1. │ backups │ /backups/123/            │ Local │            0 │             0 │         0 │         0 │
2. │ default │ /chdata/clickhouse/data/ │ Local │            0 │             0 │         0 │         0 │
   └─────────┴──────────────────────────┴───────┴──────────────┴───────────────┴───────────┴───────────┘

CHDBDEV :) backup database lukestest1 to Disk('backups','lukestest1_2024_02.zip');
   ┌─id───────────────────────────────────┬─status─────────┐
1. │ 739aa691-5e94-4853-8f39-3bb422a749d6 │ BACKUP_CREATED │
   └──────────────────────────────────────┴────────────────┘

CHDBDEV :) backup database lukestest1 to Disk('default','lukestest1_2024.zip');
Received exception from server (version 24.4.1):
Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: Disk ''default'' is not allowed for backups, see the 'backups.allowed_disk' configuration parameter. (BAD_ARGUMENTS)

案例4、备份目录配置及备份状况

sql 复制代码
[root@CHDBDEV ~]# cat /etc/clickhouse-server/config.d/backup_disk.xml
<clickhouse>
    <storage_configuration>
        <disks>
            <backups>
                <type>local</type>
                <path>/backups/123/</path>
            </backups>
        </disks>
        <disks>
            <default>
                <type>local</type>
                <path>/chdata/clickhouse/data/</path>
            </default>
        </disks>
    </storage_configuration>
    <backups>
        <allowed_disk>backups</allowed_disk>
        <allowed_path>/backups/123/</allowed_path>
    </backups>
   <backups>
        <allowed_disk>default</allowed_disk>
        <allowed_path>/chdata/clickhouse/data/</allowed_path>
    </backups>
</clickhouse>
CHDBDEV :) select name,path,type,is_read_only,is_write_once,is_remote,is_broken from system.disks;
   ┌─name────┬─path─────────────────────┬─type──┬─is_read_only─┬─is_write_once─┬─is_remote─┬─is_broken─┐
1. │ backups │ /backups/123/            │ Local │            0 │             0 │         0 │         0 │
2. │ default │ /chdata/clickhouse/data/ │ Local │            0 │             0 │         0 │         0 │
   └─────────┴──────────────────────────┴───────┴──────────────┴───────────────┴───────────┴───────────┘

CHDBDEV :) backup database lukestest1 to Disk('backups','lukestest1_2024_03.zip');
   ┌─id───────────────────────────────────┬─status─────────┐
1. │ e5c9fe04-c24b-4760-b98e-dd5c366088a9 │ BACKUP_CREATED │
   └──────────────────────────────────────┴────────────────┘

CHDBDEV :) backup database lukestest1 to Disk('default','lukestest1_2024.zip');
Received exception from server (version 24.4.1):
Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: Disk ''default'' is not allowed for backups, see the 'backups.allowed_disk' configuration parameter. (BAD_ARGUMENTS)

案例5、备份目录配置及备份状况

sql 复制代码
[root@CHDBDEV ~]# cat /etc/clickhouse-server/config.d/backup_disk.xml
<clickhouse>
    <storage_configuration>
        <disks>
            <backups>
                <type>local</type>
                <path>/backups/123/</path>
            </backups>
        </disks>
        <disks>
            <default2>
                <type>local</type>
                <path>/backups/345/</path>
            </default2>
        </disks>
    </storage_configuration>
    <backups>
        <allowed_disk>backups</allowed_disk>
        <allowed_path>/backups/123/</allowed_path>
    </backups>
   <backups>
        <allowed_disk>default2</allowed_disk>
        <allowed_path>/backups/345/</allowed_path>
    </backups>
</clickhouse>

CHDBDEV :) select name,path,type,is_read_only,is_write_once,is_remote,is_broken from system.disks;
   ┌─name────┬─path─────────────────────┬─type──┬─is_read_only─┬─is_write_once─┬─is_remote─┬─is_broken─┐
1. │ backups │ /backups/123/            │ Local │            0 │             0 │         0 │         0 │
2. │ default │ /chdata/clickhouse/data/ │ Local │            0 │             0 │         0 │         0 │
   └─────────┴──────────────────────────┴───────┴──────────────┴───────────────┴───────────┴───────────┘

CHDBDEV :) backup database lukestest1 to Disk('backups','lukestest1_2024_04.zip');
   ┌─id───────────────────────────────────┬─status─────────┐
1. │ 72d58abc-c82d-4705-952f-c0e493662fd1 │ BACKUP_CREATED │
   └──────────────────────────────────────┴────────────────┘


CHDBDEV :) backup database lukestest1 to Disk('default2','lukestest1_2024.zip');
Received exception from server (version 24.4.1):
Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: Disk ''default2'' is not allowed for backups, see the 'backups.allowed_disk' configuration parameter. (BAD_ARGUMENTS)

案例6、备份目录配置及备份状况

sql 复制代码
[root@CHDBDEV ~]# cat /etc/clickhouse-server/config.d/backup_disk.xml
<clickhouse>
    <storage_configuration>
        <disks>
            <backups>
                <type>local</type>
                <path>/backups/123/</path>
            </backups>
        </disks>
    </storage_configuration>
    <backups>
        <allowed_disk>backups</allowed_disk>
        <allowed_path>/backups/123/</allowed_path>
    </backups>
    <storage_configuration>
        <disks>
            <default2>
                <type>local</type>
                <path>/backups/345/</path>
            </default2>
        </disks>
    </storage_configuration>
   <backups>
        <allowed_disk>default2</allowed_disk>
        <allowed_path>/backups/345/</allowed_path>
    </backups>
</clickhouse>

CHDBDEV :) select name,path,type,is_read_only,is_write_once,is_remote,is_broken from system.disks;
   ┌─name────┬─path─────────────────────┬─type──┬─is_read_only─┬─is_write_once─┬─is_remote─┬─is_broken─┐
1. │ backups │ /backups/123/            │ Local │            0 │             0 │         0 │         0 │
2. │ default │ /chdata/clickhouse/data/ │ Local │            0 │             0 │         0 │         0 │
   └─────────┴──────────────────────────┴───────┴──────────────┴───────────────┴───────────┴───────────┘

CHDBDEV :) backup database lukestest1 to Disk('default2','lukestest1_2024.zip');
Received exception from server (version 24.4.1):
Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: Disk ''default2'' is not allowed for backups, see the 'backups.allowed_disk' configuration parameter. (BAD_ARGUMENTS)

CHDBDEV :) backup database lukestest1 to Disk('backups','lukestest1_2024_05.zip');
   ┌─id───────────────────────────────────┬─status─────────┐
1. │ b76f47d4-b6c9-4ff4-bff9-dcced56aa0b5 │ BACKUP_CREATED │
   └──────────────────────────────────────┴────────────────┘
相关推荐
FrankYoou22 分钟前
Jenkins 与 GitLab CI/CD 的核心对比
java·docker
计算机毕设定制辅导-无忧学长42 分钟前
西门子 PLC 与 Modbus 集成:S7-1500 RTU/TCP 配置指南(一)
服务器·数据库·tcp/ip
麦兜*1 小时前
Spring Boot启动优化7板斧(延迟初始化、组件扫描精准打击、JVM参数调优):砍掉70%启动时间的魔鬼实践
java·jvm·spring boot·后端·spring·spring cloud·系统架构
KK溜了溜了1 小时前
JAVA-springboot 整合Redis
java·spring boot·redis
天河归来1 小时前
使用idea创建springboot单体项目
java·spring boot·intellij-idea
程序员柳1 小时前
基于微信小程序的校园二手交易平台、微信小程序校园二手商城源代码+数据库+使用说明,layui+微信小程序+Spring Boot
数据库·微信小程序·layui
weixin_478689762 小时前
十大排序算法汇总
java·算法·排序算法
码荼2 小时前
学习开发之hashmap
java·python·学习·哈希算法·个人开发·小白学开发·不花钱不花时间crud
梦在深巷、2 小时前
MySQL/MariaDB数据库主从复制之基于二进制日志的方式
linux·数据库·mysql·mariadb
IT乌鸦坐飞机2 小时前
ansible部署数据库服务随机启动并创建用户和设置用户有完全权限
数据库·ansible·centos7