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 │
   └──────────────────────────────────────┴────────────────┘
相关推荐
s:1031 小时前
【框架】参考 Spring Security 安全框架设计出,轻量化高可扩展的身份认证与授权架构
java·开发语言
夜泉_ly2 小时前
MySQL -安装与初识
数据库·mysql
qq_529835353 小时前
对计算机中缓存的理解和使用Redis作为缓存
数据库·redis·缓存
南山十一少4 小时前
Spring Security+JWT+Redis实现项目级前后端分离认证授权
java·spring·bootstrap
月光水岸New5 小时前
Ubuntu 中建的mysql数据库使用Navicat for MySQL连接不上
数据库·mysql·ubuntu
狄加山6755 小时前
数据库基础1
数据库
我爱松子鱼5 小时前
mysql之规则优化器RBO
数据库·mysql
427724005 小时前
IDEA使用git不提示账号密码登录,而是输入token问题解决
java·git·intellij-idea
chengooooooo6 小时前
苍穹外卖day8 地址上传 用户下单 订单支付
java·服务器·数据库
李长渊哦6 小时前
常用的 JVM 参数:配置与优化指南
java·jvm