Skip to content

Commit 09d2483

Browse files
TCeasonBohuTANG
andauthored
chore: add doc about system flush privilege (#3017)
* chore: add doc about system flush privilege * docs: refine chinese translation for roles and system tables --------- Co-authored-by: BohuTANG <[email protected]>
1 parent dabe7e6 commit 09d2483

File tree

8 files changed

+109
-24
lines changed

8 files changed

+109
-24
lines changed

docs/cn/guides/56-security/access-control/02-roles.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
title: 角色
33
---
44

5-
Databend 中的角色在简化权限管理方面起着关键作用。当多个用户需要相同的权限集时,单独授予权限可能很麻烦。角色提供了一种解决方案,允许将一组权限分配给一个角色,然后可以轻松地将该角色分配给多个用户
5+
角色在 Databend 的权限管理中起着关键作用。当多个用户需要相同的权限时,逐一授权会非常繁琐。通过角色,我们可以将一组权限打包,然后轻松地将其分配给多个用户
66

77
![Alt text](/img/guides/access-control-3.png)
88

99
## 继承角色 & 建立层级结构
1010

11-
角色授予使一个角色能够继承另一个角色的权限和职责。这有助于创建灵活的层级结构,类似于组织结构,其中存在两个 [内置角色](#built-in-roles)最高的是 `account-admin`,最低的是 `public`
11+
角色授予允许一个角色继承另一个角色的权限。这有助于构建灵活的层级结构(类似于组织架构)。Databend 主要包含两个[内置角色](#built-in-roles)最高层级的 `account-admin` 和最低层级的 `public`
1212

13-
考虑创建三个角色的场景_manager__engineer__intern_在此示例中,_intern_ 角色被授予给 _engineer_ 角色。因此,_engineer_ 不仅拥有自己的权限集,还继承了与 _intern_ 角色相关的权限。进一步扩展此层级结构,如果将 _engineer_ 角色授予给 _manager_ _manager_ 现在获得 _engineer__intern_ 角色的固有权限
13+
假设我们创建了三个角色_manager__engineer__intern_如果我们把 _intern_ 角色授予 _engineer_,那么 _engineer_ 不仅拥有自己的权限,还会继承 _intern_ 的权限。以此类推,如果把 _engineer_ 角色授予 _manager_那么 _manager_ 将同时获得 _engineer__intern_ 的所有权限
1414

1515
![Alt text](/img/guides/access-control-4.png)
1616

@@ -20,14 +20,14 @@ Databend 附带以下内置角色:
2020

2121
| 内置角色 | 描述 |
2222
| ------------- | -------------------------------------------------------------------------- |
23-
| account-admin | 拥有所有权限,充当所有其他角色的父角色,并能够无缝切换到租户中的任何角色|
24-
| public | 不继承任何权限,将所有角色视为其父角色,并允许任何角色切换到 public 角色。 |
23+
| account-admin | 拥有所有权限,是所有其他角色的父角色,可以无缝切换为租户内的任何角色|
24+
| public | 不继承任何权限,所有其他角色都是它的父角色。任何角色都可以切换为 public 角色。 |
2525

26-
要在 Databend Cloud 中将 `account-admin` 角色分配给用户,请在邀请用户时选择该角色。您也可以在用户加入后将该角色分配给用户。如果您使用的是 Databend Community Edition 或 Enterprise Edition,请首先在部署期间配置 `account-admin` 用户,然后根据需要将该角色分配给其他用户。有关配置管理员用户的更多信息,请参阅 [配置管理员用户](../../10-deploy/04-references/01-admin-users.md)
26+
Databend Cloud 中,您可以在邀请用户时直接分配 `account-admin` 角色,或者在用户加入后进行分配。如果您使用的是 Databend 社区版或企业版,请在部署时先配置好 `account-admin` 用户,然后再按需分配给其他用户。关于管理员用户的配置详情,请参阅[配置管理员用户](../../10-deploy/04-references/01-admin-users.md)
2727

2828
## 设置默认角色
2929

30-
当用户被授予多个角色时,您可以使用 [CREATE USER](/sql/sql-commands/ddl/user/user-create-user)[ALTER USER](/sql/sql-commands/ddl/user/user-alter-user) 命令为该用户设置默认角色。默认角色确定在会话开始时自动分配给用户的角色
30+
当用户拥有多个角色时,可以使用 [CREATE USER](/sql/sql-commands/ddl/user/user-create-user)[ALTER USER](/sql/sql-commands/ddl/user/user-alter-user) 命令设置默认角色。默认角色是用户登录会话时自动生效的角色
3131

3232
```sql title='Example:'
3333
-- 显示系统中现有的角色
@@ -51,33 +51,33 @@ GRANT ROLE account_admin TO eric;
5151
ALTER USER eric WITH DEFAULT_ROLE = 'account_admin';
5252
```
5353

54-
- 用户可以使用 [SET ROLE](/sql/sql-commands/ddl/user/user-set-role) 命令灵活地在会话中切换到其他角色
55-
- 用户可以使用 [SHOW ROLES](/sql/sql-commands/ddl/user/user-show-roles) 命令检查其当前角色并查看授予给他们的所有角色
56-
- 如果您没有为用户显式设置默认角色,Databend 将默认使用内置角色 `public` 作为默认角色
54+
- 用户可以在会话中使用 [SET ROLE](/sql/sql-commands/ddl/user/user-set-role) 命令灵活切换角色
55+
- 用户可以使用 [SHOW ROLES](/sql/sql-commands/ddl/user/user-show-roles) 命令查看当前的活跃角色以及所有被授予的角色
56+
- 如果未显式设置默认角色,Databend 将默认使用内置角色 `public`
5757

5858
## 激活角色 & 辅助角色
5959

60-
可以向用户授予 Databend 中的多个角色。这些角色分为激活角色和辅助角色
60+
Databend 中,用户可以被授予多个角色。这些角色分为激活角色(Active Role)和辅助角色(Secondary Roles)
6161

62-
- 激活角色是用户当前会话的激活主角色,可以使用 [SET ROLE](/sql/sql-commands/ddl/user/user-set-role) 命令进行设置
62+
- **激活角色**:用户当前会话中正在使用的主角色,可通过 [SET ROLE](/sql/sql-commands/ddl/user/user-set-role) 命令进行切换
6363

64-
- 辅助角色是提供额外权限的其他角色,默认情况下处于激活状态。用户可以使用 [SET SECONDARY ROLES](/sql/sql-commands/ddl/user/user-set-2nd-roles) 命令激活或停用辅助角色,以临时调整其权限范围
64+
- **辅助角色**:提供额外权限的角色,默认处于激活状态。用户可以使用 [SET SECONDARY ROLES](/sql/sql-commands/ddl/user/user-set-2nd-roles) 命令来启用或禁用这些角色,从而临时调整权限范围
6565

6666
## 账单角色
6767

68-
除了标准的内置角色之外,您还可以在 Databend Cloud 中创建一个名为 `billing` 的自定义角色,专门满足财务人员的需求。角色 `billing` 仅提供对与账单相关的信息的访问权限,确保财务人员可以查看必要的财务数据,而无需访问其他与业务相关的页面
68+
除了标准的内置角色,Databend Cloud 还支持创建名为 `billing` 的自定义角色,专为财务人员设计。`billing` 角色仅拥有账单信息的访问权限,确保财务人员在查看财务数据时,无法访问其他业务页面
6969

70-
要设置和使用角色 `billing`,您可以使用以下命令创建它
70+
要设置和使用 `billing` 角色,可以使用以下命令创建
7171

7272
```sql
7373
CREATE ROLE billing;
7474
```
7575

76-
角色名称不区分大小写,因此 `billing``Billing` 被认为是相同的。有关设置和分配角色 `billing` 的详细步骤,请参阅 [授予财务人员访问权限](/guides/cloud/manage/costs#granting-access-to-finance-personnel)
76+
角色名称不区分大小写,`billing``Billing` 视为相同。关于该角色的设置和分配步骤,请参阅[授予财务人员访问权限](/guides/cloud/manage/costs#granting-access-to-finance-personnel)
7777

7878
## 使用示例
7979

80-
此示例展示了基于角色的权限管理。最初,创建一个“writer角色并授予权限。随后,这些权限被分配给用户“eric”,他继承了这些权限。最后,从角色中撤销权限,展示了它们对用户权限的影响
80+
此示例展示了基于角色的权限管理。首先创建一个 `writer` 角色并授予权限,然后将这些权限授予用户 `eric`,使其继承这些权限。最后,撤销角色的权限,演示其对用户权限的影响
8181

8282
```sql title='Example:'
8383
-- 创建一个名为 'writer' 的新角色

docs/cn/sql-reference/00-sql-reference/31-system-tables/system-query-log.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ import FunctionDescription from '@site/src/components/FunctionDescription';
66

77
<FunctionDescription description="引入或更新于:v1.2.696"/>
88

9-
一个只读的内存表,用于存储所有查询日志。有关查询日志中可用字段的具体信息,请参阅[示例](#examples)部分。
9+
这是一个只读的内存表,用于存储所有的查询日志。关于查询日志中可用字段的具体信息,请参阅[示例](#examples)部分。
1010

1111
## 设置会话标签
1212

13-
可以选择为会话(Session)分配一个标签,便于根据分配的会话标签在日志表中筛选日志。例如,以下命令为当前会话分配标签`eric`
13+
您可以为会话(Session)设置标签,以便在日志表中通过标签筛选日志。例如,使用以下命令为当前会话分配标签 `eric`
1414

1515
```sql
1616
set session query_tag='eric';
1717
```
1818

19-
随后,运行查询(Query)并使用分配的标签从日志表中检索日志
19+
然后,运行查询(Query)并使用该标签在日志表中检索对应的日志记录
2020

2121
```sql
2222
show users;
2323

2424
select query_tag, query_text from system.query_log where query_tag='eric' limit 1;
2525
```
2626

27-
返回结果中可找到该查询的记录,标签为'eric'
27+
结果将显示带有 `eric` 标签的查询记录
2828

2929
```sql
3030
-[ RECORD 1 ]-----------------------------------
@@ -34,7 +34,7 @@ select query_tag, query_text from system.query_log where query_tag='eric' limit
3434

3535
## 示例
3636

37-
`system.query_log`表存储已执行查询的详细日志。以下是日志条目的示例
37+
`system.query_log` 表存储了已执行查询的详细日志。以下是一个日志条目的示例
3838

3939
```sql
4040
SELECT * FROM system.query_log;

docs/cn/sql-reference/10-sql-commands/00-ddl/02-user/10-grant.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import FunctionDescription from '@site/src/components/FunctionDescription';
1818
- [REVOKE](11-revoke.md)
1919
- [SHOW GRANTS](22-show-grants.md)
2020

21+
> 使用 `GRANT``REVOKE` 变更角色与权限后,执行 [SYSTEM FLUSH PRIVILEGES](../../50-administration-cmds/flush-privileges.md) 可立即让所有查询节点刷新缓存。
22+
2123
## Syntax
2224

2325
### Granting Privileges
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: SYSTEM FLUSH PRIVILEGES
3+
---
4+
5+
`SYSTEM FLUSH PRIVILEGES` 会向每个查询节点广播刷新请求,使其立即从 Meta 服务重新加载角色与权限缓存。执行 `GRANT``REVOKE` 之后如果希望变更立刻在整个集群生效,可以使用该命令,而不用等待默认 15 秒的缓存刷新周期。
6+
7+
参见:
8+
9+
- [GRANT](../00-ddl/02-user/10-grant.md)
10+
- [REVOKE](../00-ddl/02-user/11-revoke.md)
11+
12+
## 语法
13+
14+
```sql
15+
SYSTEM FLUSH PRIVILEGES
16+
```
17+
18+
## 使用说明
19+
20+
- 需要具备能够执行系统管理命令的角色,例如 `ACCOUNT ADMIN`
21+
- 该命令仅刷新节点本地缓存,不会修改角色或授权内容本身。
22+
- 已经在运行的语句会继续沿用启动时解析到的权限,若要使用最新权限,请在刷新之后重新执行语句。
23+
24+
## 示例
25+
26+
下面的示例为角色授予数据库访问权限,并立即刷新缓存,使所有查询节点都能看到新的权限:
27+
28+
```sql
29+
GRANT SELECT ON DATABASE marketing TO ROLE analyst;
30+
31+
SYSTEM FLUSH PRIVILEGES;
32+
```
33+
34+
35+
刷新完成后,继承 `analyst` 角色的新查询无需等待缓存失效即可获得更新后的权限。

docs/cn/sql-reference/10-sql-commands/50-administration-cmds/index.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ title: 管理命令
1313
| **[KILL](01-kill.md)** | 终止正在运行的查询或连接 |
1414
| **[RUST BACKTRACE](rust-backtrace.md)** | 调试 Rust 堆栈跟踪 |
1515

16+
## 访问控制
17+
18+
| 命令 | 说明 |
19+
|---------|-------------|
20+
| **[FLUSH PRIVILEGES](flush-privileges.md)** | 让每个查询节点立即重新加载角色与权限缓存 |
21+
1622
## 配置管理
1723

1824
| 命令 | 说明 |
@@ -43,4 +49,4 @@ title: 管理命令
4349

4450
| 命令 | 说明 |
4551
|---------|-------------|
46-
| **[EXECUTE IMMEDIATE](execute-immediate.md)** | 执行动态构造的 SQL 语句 |
52+
| **[EXECUTE IMMEDIATE](execute-immediate.md)** | 执行动态构造的 SQL 语句 |

docs/en/sql-reference/10-sql-commands/00-ddl/02-user/10-grant.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ See also:
1717
- [REVOKE](11-revoke.md)
1818
- [SHOW GRANTS](22-show-grants.md)
1919

20+
> After changing privileges or roles with `GRANT`, run [SYSTEM FLUSH PRIVILEGES](../../50-administration-cmds/flush-privileges.md) to broadcast the updates to every query node immediately.
21+
2022
## Syntax
2123

2224
### Granting Privileges
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: SYSTEM FLUSH PRIVILEGES
3+
---
4+
5+
`SYSTEM FLUSH PRIVILEGES` broadcasts a refresh request to every query node so each node immediately reloads privilege and role metadata from the Meta service. Run the command after `GRANT` or `REVOKE` statements when you need the changes to take effect across the cluster without waiting for the default 15-second role-cache interval.
6+
7+
See also:
8+
9+
- [GRANT](../00-ddl/02-user/10-grant.md)
10+
- [REVOKE](../00-ddl/02-user/11-revoke.md)
11+
12+
## Syntax
13+
14+
```sql
15+
SYSTEM FLUSH PRIVILEGES
16+
```
17+
18+
## Usage Notes
19+
20+
- Requires a role that is allowed to execute system administration commands, such as `ACCOUNT ADMIN`.
21+
- Refreshes cached privilege metadata only; it does not alter roles or grants by itself.
22+
- Statements that are already running keep using the privileges that were resolved when they started. Re-run the statement after the flush to pick up the changes.
23+
24+
## Example
25+
26+
The following sequence grants a role access to a database and immediately flushes the caches so the new privilege is visible from every query node:
27+
28+
```sql
29+
GRANT SELECT ON DATABASE marketing TO ROLE analyst;
30+
31+
SYSTEM FLUSH PRIVILEGES;
32+
```
33+
34+
After the flush completes, any new query that runs under the `analyst` role receives the updated privilege set without waiting for the cache to expire.

docs/en/sql-reference/10-sql-commands/50-administration-cmds/index.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ This page provides reference information for the system administration commands
1313
| **[KILL](01-kill.md)** | Terminate running queries or connections |
1414
| **[RUST BACKTRACE](rust-backtrace.md)** | Debug Rust stack traces |
1515

16+
## Access Control
17+
18+
| Command | Description |
19+
|---------|-------------|
20+
| **[FLUSH PRIVILEGES](flush-privileges.md)** | Force every query node to reload role and privilege metadata |
21+
1622
## Configuration Management
1723

1824
| Command | Description |
@@ -43,4 +49,4 @@ This page provides reference information for the system administration commands
4349

4450
| Command | Description |
4551
|---------|-------------|
46-
| **[EXECUTE IMMEDIATE](execute-immediate.md)** | Execute dynamically constructed SQL statements |
52+
| **[EXECUTE IMMEDIATE](execute-immediate.md)** | Execute dynamically constructed SQL statements |

0 commit comments

Comments
 (0)