本文主要是介绍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、备份目录配置及备份状况
[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、备份目录配置及备份状况
[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、备份目录配置及备份状况
[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、备份目录配置及备份状况
[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、备份目录配置及备份状况
[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、备份目录配置及备份状况
[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 │└──────────────────────────────────────┴────────────────┘
这篇关于Clickhouse备份恢复_clickhouse-client方式backup命令之备份目录的设置的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!