返回首页

gbase数据、南大通用产品文档:GBase8s备份逻辑日志文件

更新日期:2024年09月11日

逻辑日志包含已执行的事务的历史记录。逻辑日志文件复制到介质的过程称为备份逻辑日
志文件。备份逻辑日志文件实现以下两个目标:

它将逻辑日志记录存储在介质上,以便在需要数据复原时可以前滚这些记录。

它使逻辑日志文件空间可用于新的逻辑日志记录。
如果您忽略了备份日志文件,那么可能会耗尽日志空间。
您可以启动手动逻辑日志备份或设置连续逻辑日志备份。在复原存储空间后,您必须复原
逻辑日志以使数据处于一致状态。有关日志备份的更多信息,请参阅《GBase 8s 备份与
复原指南》。

GBase 8s 管理员指南
南大通用数据技术股份有限公司
- 292 -
备份 BLOB 空间
先备份逻辑日志还是先备份 BLOB 空间,这一点无关紧要。
要备份 BLOB 空间,请执行以下操作:
1. 在当前的逻辑日志包含有关 BLOB 空间中简单大对象的事务时关闭该日志。
2. 在更新简单大对象数据后尽快执行对逻辑日志和 BLOB 空间的备份。
警告: 如果您不备份这些 BLOB 空间和逻辑日志,就可能无法复原 BLOB 空间数据。如果您等到
BLOB 空间不可用时才执行日志备份,数据库服务器将无法访问 BLOB 空间以将更改过的数据复制到
逻辑日志中。
备份智能大对象空间
当为智能大对象打开日志记录时,必须执行该智能大对象空间的 0 级备份。
下图显示在未备份的智能大对象空间中打开日志记录时会发生的情况。尽管已记录的更改
是可恢复的,但在故障期间会丢失未记录的对智能大对象 LO1 的更改。您将无法完全复
原 LO1。
在快速恢复期间,数据库服务器前滚 LO1 的所有已落实事务。如果未记录 LO1,那么
数据库服务器将无法回滚未落实的事务。而那时 LO1 内容将是不正确的。有关更多信
息,请参阅快速恢复。
图: 打开智能大对象空间中的日志记录



GBase 8a MPP Cluster 产品手册
4 管理员指南
文档版本953(2022-09-15)
南大通用数据技术股份有限公司
134

为便于理解以上概念,下表举例说明每种典型场景下查询和结果集,用例使用的建

GBase 8a MPP Cluster 产品手册
4 管理员指南
文档版本953(2022-04-10)
南大通用数据技术股份有限公司
463
表语句和数据为:
create table t (i1 int,
vc1 varchar(10) masked with (function='partial(2,"*****",0)'),
vc2 varchar(10) masked with (function='partial(2,"*****",0)'));
insert into t values (1, 'nblknabpa', 'pombkaia');
insert into t values (2, '.mapkna', '0jbadflk');
insert into t values ();

示例1:第i 类函数case when 脱敏列规则;
gbase>select case i1 when 1 then vc1 when 2 then '12345' else '67890' end as res from t;
+---------+
| res
|
+---------+
| nb***** |
| 12***** |
| 67***** |
+---------+

示例2:第i 类函数coalesce 脱敏列规则;
gbase>select coalesce(vc1,'12345') as res from t;
+---------+
| res
|
+---------+
| nb***** |
| .m***** |
| 12***** |
+---------+

示例3:第i 类函数case when 多脱敏列默认脱敏;
gbase> select case i1 when 1 then vc1 when 2 then vc2 else '67890' end as res from t;
+------+
| res
|
+------+
| xxxx |
| xxxx |
| xxxx |
+------+

示例4:第ii 类函数substring 默认脱敏;

GBase 8a MPP Cluster 产品手册
4 管理员指南
文档版本953(2022-04-10)
南大通用数据技术股份有限公司
464
gbase> select substring(vc1, 1, 2) as res from t;
+------+
| res
|
+------+
| xx
|
| xx
|
| NULL |
+------+

示例5:第ii 类函数concat 默认脱敏;
gbase> select concat(vc1,'123') as res from t;
+------+
| res
|
+------+
| xxxx |
| xxxx |
| NULL |
+------+

示例6:第i 类函数嵌套使用;
gbase> select case when i1 > 1 then coalesce(vc1, '12345') else '67890' end as res from t;
+---------+
| res
|
+---------+
| 67***** |
| .m***** |
| 67***** |
+---------+

示例7:第ii 类函数嵌套使用;
gbase> select concat(substring(vc1,1,2),'123') as res from t;
+------+
| res
|
+------+
| xxxx |
| xxxx |
| NULL |
+------+

示例8:第i 类和ii 类函数混合嵌套调用;

GBase 8a MPP Cluster 产品手册
4 管理员指南
文档版本953(2022-04-10)
南大通用数据技术股份有限公司
465
gbase> select coalesce(substring(vc1,1,2),'12345') as res from t;
(或者select substring(coalesce (vc1, '12345'), 1, 2) as res from t;)
+------+
| res
|
+------+
| xxxx |
| xxxx |
| xxxx |
+------+

示例9:子查询内或外调用i 类;
gbase> select res from (select coalesce(vc1,'12345')as res from t) as tmp;
(或者select coalesce(vc1, '12345') as res from (select vc1 from t) as tmp;)
+---------+
| res
|
+---------+
| nb***** |
| .m***** |
| 12***** |
+---------+

示例10:子查询内或外调用ii 类;
gbase> select res from (select concat(vc1,'123') as res from t) as tmp;
(或者select concat (vc1, '123') as res from (select vc1 from t) as tmp;)
+------+
| res
|
+------+
| xxxx |
| xxxx |
| NULL |
+------+

示例11:子查询内外调用i 类;
gbase> select case when i1 > 1 then res1 else '67890' end as res from (select i1,coalesce(vc1,
'12345') as res1 from t) as tmp;
+---------+
| res
|
+---------+
| 67***** |
| .m***** |
| 67***** |
+---------+

示例12:子查询内外调用ii 类;

GBase 8a MPP Cluster 产品手册
4 管理员指南
文档版本953(2022-04-10)
南大通用数据技术股份有限公司
466
gbase> select concat(res1,'123') as res from (select substring(vc1,1,2) as res1 from t) as tmp;
+------+
| res
|
+------+
| xxxx |
| xxxx |
| NULL |
+------+

示例13:子查询内外混合调用i 类和ii 类。
gbase> select substring(res1,1,4) as res from (select coalesce(vc1, '12345') as res1 from t) as
tmp;
(或者
gbase> select coalesce(res1, '12345') as res from (select substring(vc1,1,2) as res1 from
t) as tmp; )
+------+
| res
|
+------+
| xxxx |
| xxxx |
| xxxx |
+------+
说明
脱敏列脱敏后如果超过脱敏列的最大长度,则自动截断为脱敏列的最大长度。
比如脱敏列定义为:
mask_col varchar(5) masked with (function ='partial(2,"xxxx",2)')
则值“abcde”理论上应脱敏为“abxxxxde”,脱敏后的长度超过了最大长度5,自动截断为
“abxxx”。
脱敏列脱敏后对于一些可设置长度的函数脱敏时也会被截断,比如:
select left(mask_col, 2) from t;
left 函数将使用默认脱敏,理论上应脱敏为“xxxx”,但超过了left 函数设置的最大长度,所
以自动截断为“xx”。
Union、Intersect 和Minus 运算时,对应列的脱敏规则与控制流函数的脱敏规则一致。
比如:
select mask_int_col from t union select mask_int_col as col from t;
将使用mask_int_col 的脱敏规则,而:
select mask_int_col from t union select mask_int_col+1 from t;

GBase 8a MPP Cluster 产品手册
4 管理员指南
文档版本953(2022-04-10)
南大通用数据技术股份有限公司
467
将使用默认脱敏。