瀚高数据库V9.0.5数据脱敏完整配置步骤

文章目录

环境

系统平台:N/A

版本:9.0.5

文档用途

本文旨在介绍瀚高数据库V9.0.5数据脱敏功能的完整配置步骤。更详尽的数据脱敏功能内容可以参考官方手册相关章节。

详细信息

相关用户和表demo创建步骤如下:

创建相关测试用户

sql 复制代码
highgo=> \c highgo highgo
用户 highgo 的口令:
hgdb-client-V9.0.5
您现在已经连接到数据库 "highgo",用户 "highgo".
highgo=# create user u1 password 'highgo';
CREATE ROLE
highgo=# create user u2 password 'highgo';
CREATE ROLE
highgo=# create user u3 password 'highgo';

在用户u3下创建测试表,并赋予u1和u2用户select权限

sql 复制代码
highgo=# \c highgo u3
用户 u3 的口令:
hgdb-client-V9.0.5
您现在已经连接到数据库 "highgo",用户 "u3".
highgo=> create table test(id int, col1 varchar,info text);
CREATE TABLE
highgo=> insert into test values(1,'highgo','database');
INSERT 0 1
highgo=> insert into test values(2,'postgres','opensource');
INSERT 0 1
highgo=> grant select on test to u1,u2;
GRANT

一、启用数据脱敏功能

1.修改配置文件postgresql.conf,给shared_preload_libraries参数追加hg_redaction,并设置hg_redaction.enable=on。随后重新启动数据库。(重启涉及数据库服务中断,需要协调停机窗口进行)

修改前:

sql 复制代码
highgo=# show shared_preload_libraries ;
                                                     shared_preload_libraries                                                     
----------------------------------------------------------------------------------------------------------------------
 gb18030_2022, restricted_dba, pg_audit, credcheck, hg_sysmac, sqlite_fdw, ora_synonym, liboracle_parser, ivorysql_ora, pg_object
highgo=> show hg_redaction.enable;
 hg_redaction.enable 
---------------------
 off

修改后:

sql 复制代码
highgo=# show shared_preload_libraries ;
                                                            shared_preload_libraries                                                            
----------------------------------------------------------------------------------------------------------------------
 gb18030_2022, restricted_dba, pg_audit, credcheck, hg_sysmac, sqlite_fdw, ora_synonym, liboracle_parser, ivorysql_ora, pg_object, hg_redaction
highgo=> show hg_redaction.enable;
 hg_redaction.enable 
---------------------
 on

2.登录数据库管理员用户在待脱敏库创建扩展

sql 复制代码
[highgo@node1 bin]$ ./psql highgo highgo
用户 highgo 的口令:
psql (14.20)
hgdb-client-V9.0.5
输入 "help" 来获取帮助信息.
highgo=# create extension hg_redaction;
CREATE EXTENSION
highgo=# \dx hg_redaction
                     已安装扩展列表
     名称     | 版本 | 架构模式 |          描述          
--------------+------+----------+------------------------
 hg_redaction | 1.0  | public   | support data redaction
(1 行记录)

二、创建一个完整脱敏策略

登录超级管理员/安全员用户创建完整脱敏策略,仅对u1用户生效

sql 复制代码
highgo=> \c highgo highgo
hgdb-client-V9.0.5
您现在已经连接到数据库 "highgo",用户 "highgo".
highgo=> create redaction policy p1 on test for(user='u1') add column  col1 using hg_security.redact_all;
CREATE REDACTION POLICY

登录u1用户查看test表中col1列数据已完全脱敏

sql 复制代码
highgo=> \c highgo u1
用户 u1 的口令:
hgdb-client-V9.0.5
您现在已经连接到数据库 "highgo",用户 "u1".
highgo=> select * from test;
 id |   col1   |    info
----+----------+------------
  1 | xxxxxx   | database
  2 | xxxxxxxx | opensource
(2 行记录)

登录u2用户查看test表完整数据

sql 复制代码
highgo=> \c highgo u2
用户 u2 的口令:
hgdb-client-V9.0.5
您现在已经连接到数据库 "highgo",用户 "u2".
highgo=> select * from test;
 id |   col1   |    info
----+----------+------------
  1 | highgo   | database
  2 | postgres | opensource
(2 行记录)
相关推荐
Henry-SAP6 小时前
PP的生产调度员(Production Scheduler)的角色与配置
数据库
Flynn Liang8 小时前
HikariCP 连接池不是越大越好:I/O 密集型 Java 服务的数据库容量工程
java·数据库·mysql·高并发·连接池·hikaricp·sql 优化
小乖写代码10 小时前
消息、回执与媒体 · msgstore.db · Messages, Receipts, and Media
数据库·媒体·whatsapp·消息回执
GeW11 小时前
世界目光聚焦中国:底层技术、Linux、数据库的破局逻辑
linux·数据库
PingCAP11 小时前
平凯数据库 × 圣诺云数:让治理数据实时可用、跨域可信流通
数据库·tidb
利威尔xu11 小时前
PostgreSQL 索引失效 4 类:函数运算让查询全表扫描拖垮性能
开发语言·数据库·postgresql·性能优化·索引优化
PingCAP11 小时前
挚文集团(陌陌、探探)从 MySQL 分库分表到 TiDB 实时统一架构的实践
数据库·tidb
Decay__12 小时前
SQLServer 运维自动化平台 —— PowerShell + SQL Agent 作业:部署、监控、巡检、告警、工单闭环一体化
运维·数据库·sql·mysql·架构
杨凯凡12 小时前
Spring Framework 7 原生重试与并发限制实战:@Retryable、@ConcurrencyLimit 能替代 Resilience4j 吗?
数据库·spring·sqlserver
星恒随风12 小时前
MySQL 从零入门(十):MVCC、Undo Log 与 Read View 详解——InnoDB 如何实现事务隔离?
linux·数据库·笔记·sql·mysql