群集 follower 命令Cluster follower commands

下面列出了用于管理随从群集配置的控制命令。Control commands for managing the follower cluster configuration are listed below. 这些命令以同步方式运行,但在下一次定期架构刷新时应用。These commands run synchronously, but are applied on the next periodic schema refresh. 因此,在新配置得以应用之前,可能会有几分钟的延迟。Therefore, there may be a few minutes delay until the new configuration is applied.

follower 命令包括数据库级命令表级命令The follower commands include database level commands and table level commands.

数据库级命令Database level commands

.show follower database.show follower database

显示从其他先导群集追随的一个或多个数据库,它们配置了一个或多个数据库级替代项。Shows a database (or databases) followed from other leader cluster, which have one or more database-level overrides configured.

语法Syntax

.show follower database DatabaseName.show follower database DatabaseName

.show follower databases (DatabaseName1,...,DatabaseNameN).show follower databases (DatabaseName1,...,DatabaseNameN)

输出Output

输出参数Output parameter 类型Type 说明Description
DatabaseNameDatabaseName StringString 被追随的数据库的名称。The name of the database being followed.
LeaderClusterMetadataPathLeaderClusterMetadataPath StringString 先导群集的元数据容器的路径。The path to the leader cluster's metadata container.
CachingPolicyOverrideCachingPolicyOverride StringString 数据库的替代缓存策略,序列化为 JSON 或 null。An override caching policy for the database, serialized as JSON or null.
AuthorizedPrincipalsOverrideAuthorizedPrincipalsOverride StringString 数据库的经授权主体的替代集合,序列化为 JSON 或 null。An override collection of authorized principals for the database, serialized as JSON or null.
AuthorizedPrincipalsModificationKindAuthorizedPrincipalsModificationKind StringString 要使用 AuthorizedPrincipalsOverride(noneunionreplace)来应用的修改类型。The modification kind to apply using AuthorizedPrincipalsOverride (none, union or replace).
CachingPoliciesModificationKindCachingPoliciesModificationKind StringString 要使用数据库级或表级缓存策略替代项(noneunionreplace)来应用的修改类型。The modification kind to apply using database or table-level caching policy overrides (none, union or replace).
IsAutoPrefetchEnabledIsAutoPrefetchEnabled 布尔Boolean 在每次进行架构刷新时是否预先提取新数据。Whether new data is pre-fetched upon each schema refresh.
TableMetadataOverridesTableMetadataOverrides StringString 表级属性替代项(如果已定义)的 JSON 序列化。A JSON serialization of table-level property overrides (if they are defined).

.alter follower database policy caching.alter follower database policy caching

更改随从数据库缓存策略,以替代在先导群集中的源数据库上设置的策略。Alters a follower database caching policy, to override the one set on the source database in the leader cluster. 它需要 DatabaseAdmin 权限It requires DatabaseAdmin permissions.

说明Notes

语法Syntax

.alter follower database DatabaseName policy caching hot = HotDataSpan.alter follower database DatabaseName policy caching hot = HotDataSpan

示例Example

.alter follower database MyDb policy caching hot = 7d

.delete follower database policy caching.delete follower database policy caching

删除随从数据库替代缓存策略。Deletes a follower database override caching policy. 这会导致在先导群集中的源数据库上设置的策略成为生效的策略。This causes the policy set on the source database in the leader cluster the effective one. 它需要 DatabaseAdmin 权限It requires DatabaseAdmin permissions.

说明Notes

语法Syntax

.delete follower database DatabaseName policy caching.delete follower database DatabaseName policy caching

示例Example

.delete follower database MyDB policy caching

.add follower database principals.add follower database principals

将经授权的主体添加到替代经授权主体的随从数据库集合中。Adds authorized principal(s) to the follower database collection of override authorized principals. 它需要 DatabaseAdmin 权限It requires DatabaseAdmin permission.

说明Notes

语法Syntax

.add follower database DatabaseName (admins | users | viewers | monitors) Role (principal1,...,principalN) ['notes'].add follower database DatabaseName (admins | users | viewers | monitors) Role (principal1,...,principalN) ['notes']

示例Example

.add follower database MyDB viewers ('aadgroup=mygroup@microsoft.com') 'My Group'

.drop follower database principals.drop follower database principals

将经授权的主体从替代经授权主体的随从数据库集合中删除。Drops authorized principal(s) from the follower database collection of override authorized principals. 它需要 DatabaseAdmin 权限It requires DatabaseAdmin permissions.

说明Notes

语法Syntax

.drop follower database DatabaseName (admins | users | viewers | monitors) (principal1,...,principalN).drop follower database DatabaseName (admins | users | viewers | monitors) (principal1,...,principalN)

示例Example

.drop follower database MyDB viewers ('aadgroup=mygroup@microsoft.com')

.alter follower database principals-modification-kind.alter follower database principals-modification-kind

更改随从数据库经授权主体修改类型。Alters the follower database authorized principals modification kind. 它需要 DatabaseAdmin 权限It requires DatabaseAdmin permissions.

说明Notes

语法Syntax

.alter follower database DatabaseName principals-modification-kind = (none | union | replace).alter follower database DatabaseName principals-modification-kind = (none | union | replace)

示例Example

.alter follower database MyDB principals-modification-kind = union

.alter follower database caching-policies-modification-kind.alter follower database caching-policies-modification-kind

更改随从数据库和表缓存策略修改类型。Alters the follower database and table caching policies modification kind. 它需要 DatabaseAdmin 权限It requires DatabaseAdmin permissions.

说明Notes

语法Syntax

.alter follower database DatabaseName caching-policies-modification-kind = (none | union | replace).alter follower database DatabaseName caching-policies-modification-kind = (none | union | replace)

示例Example

.alter follower database MyDB caching-policies-modification-kind = union

表级命令Table level commands

.alter follower table policy caching.alter follower table policy caching

更改随从数据库上的表级缓存策略,以替代在先导群集中的源数据库上设置的策略。Alters a table-level caching policy on the follower database, to override the policy set on the source database in the leader cluster. 它需要 DatabaseAdmin 权限It requires DatabaseAdmin permissions.

说明Notes

语法Syntax

.alter follower database DatabaseName table TableName policy caching hot = HotDataSpan.alter follower database DatabaseName table TableName policy caching hot = HotDataSpan

.alter follower database DatabaseName tables (TableName1,...,TableNameN) policy caching hot = HotDataSpan.alter follower database DatabaseName tables (TableName1,...,TableNameN) policy caching hot = HotDataSpan

示例Example

.alter follower database MyDb tables (Table1, Table2) policy caching hot = 7d

.delete follower table policy caching.delete follower table policy caching

删除随从数据库上的替代表级缓存策略,使在先导群集中的源数据库上设置的策略成为生效的策略。Deletes an override table-level caching policy on the follower database, making the policy set on the source database in the leader cluster the effective one. 需要 DatabaseAdmin 权限Requires DatabaseAdmin permissions.

说明Notes

语法Syntax

.delete follower database DatabaseName table TableName policy caching.delete follower database DatabaseName table TableName policy caching

.delete follower database DatabaseName tables (TableName1,...,TableNameN) policy caching.delete follower database DatabaseName tables (TableName1,...,TableNameN) policy caching

示例Example

.delete follower database MyDB tables (Table1, Table2) policy caching

示例配置Sample configuration

下面是用于配置随从数据库的示例步骤。The following are sample steps to configure a follower database.

在本示例中:In this example:

  • 我们的随从群集 MyFollowerCluster 将追随先导群集 MyLeaderCluster 中的数据库 MyDatabaseOur follower cluster, MyFollowerCluster will be following database MyDatabase from the leader cluster, MyLeaderCluster.
    • MyDatabase 具有 N 表:MyTable1MyTable2MyTable3、... MyTableN (N > 3)。MyDatabase has N tables: MyTable1, MyTable2, MyTable3, ... MyTableN (N > 3).
    • MyLeaderCluster上:On MyLeaderCluster: | MyTable1 缓存策略MyTable1 caching policy | MyTable2 缓存策略MyTable2 caching policy | MyTable3...MyTableN 缓存策略MyTable3...MyTableN caching policy | MyDatabase 经授权的主体MyDatabase Authorized principals | | ------------------------- | ------------------------- | -------------------------------------- | ------------------------------------------------------------------------------------- | | 热数据跨度 = 7dhot data span = 7d | 热数据跨度 = 30dhot data span = 30d | 热数据跨度 = 365dhot data span = 365d | 查看者 = aadgroup=scubadivers@contoso.com管理员 = aaduser=jack@contoso.comViewers = aadgroup=scubadivers@contoso.com; Admins = aaduser=jack@contoso.com |
    • MyFollowerCluster 上,我们需要:On MyFollowerCluster we want: | MyTable1 缓存策略MyTable1 caching policy | MyTable2 缓存策略MyTable2 caching policy | MyTable3...MyTableN 缓存策略MyTable3...MyTableN caching policy | MyDatabase 经授权的主体MyDatabase Authorized principals | | ------------------------- | ------------------------- | ---------------------------------------- | ----------------------------------------------------------------------------- | | 热数据跨度 = 1dhot data span = 1d | 热数据跨度 = 3dhot data span = 3d | 热数据跨度 = 0d(不缓存任何内容)hot data span = 0d (nothing is cached) | 管理员 = aaduser=jack@contoso.com查看者 = aaduser=jill@contoso.comAdmins = aaduser=jack@contoso.com, Viewers = aaduser=jill@contoso.com |

重要

MyFollowerClusterMyLeaderCluster 必须位于同一区域中。Both MyFollowerCluster and MyLeaderCluster must be in the same region.

要执行的步骤Steps to execute

先决条件:将群集 MyFollowerCluster 设置为追随群集 MyLeaderCluster 中的数据库 MyDatabasePrerequisite: Setup cluster MyFollowerCluster to follow database MyDatabase from cluster MyLeaderCluster.

备注

运行控制命令的主体应为数据库 MyDatabase 上的 DatabaseAdminThe principal running the control commands is expected to be a DatabaseAdmin on database MyDatabase.

显示当前配置Show the current configuration

查看追随 MyFollowerCluster 上的 MyDatabase 时所遵循的当前配置:See the current configuration according to which MyDatabase is being followed on MyFollowerCluster:

.show follower database MyDatabase
| evaluate narrow() // just for presentation purposes
Column ValueValue
DatabaseNameDatabaseName MyDatabaseMyDatabase
LeaderClusterMetadataPathLeaderClusterMetadataPath https://storageaccountname.blob.core.chinacloudapi.cn/cluster
CachingPolicyOverrideCachingPolicyOverride Nullnull
AuthorizedPrincipalsOverrideAuthorizedPrincipalsOverride [][]
AuthorizedPrincipalsModificationKindAuthorizedPrincipalsModificationKind None
IsAutoPrefetchEnabledIsAutoPrefetchEnabled FalseFalse
TableMetadataOverridesTableMetadataOverrides
CachingPoliciesModificationKindCachingPoliciesModificationKind UnionUnion

替代经授权的主体Override authorized principals

MyFollowerCluster 上的 MyDatabase 的经授权主体集合替换为仅包含一个 AAD 用户作为数据库管理员并包含一个 AAD 用户作为数据库查看者的集合:Replace the collection of authorized principals for MyDatabase on MyFollowerCluster with a collection that includes only one AAD user as the database admin, and one AAD user as a database viewer:

.add follower database MyDatabase admins ('aaduser=jack@contoso.com')

.add follower database MyDatabase viewers ('aaduser=jill@contoso.com')

.alter follower database MyDatabase principals-modification-kind = replace

只有这两个特定主体才有权访问 MyFollowerCluster 上的 MyDatabaseOnly those two specific principals are authorized to access MyDatabase on MyFollowerCluster

.show database MyDatabase principals
角色Role PrincipalTypePrincipalType PrincipalDisplayNamePrincipalDisplayName PrincipalObjectIdPrincipalObjectId PrincipalFQNPrincipalFQN 注释Notes
MyDatabase 数据库管理员Database MyDatabase Admin AAD 用户AAD User Jack Kusto(upn:jack@contoso.com)Jack Kusto (upn: jack@contoso.com) 12345678-abcd-efef-1234-350bf486087b12345678-abcd-efef-1234-350bf486087b aaduser=87654321-abcd-efef-1234-350bf486087b;55555555-4444-3333-2222-2d7cd011db47aaduser=87654321-abcd-efef-1234-350bf486087b;55555555-4444-3333-2222-2d7cd011db47
MyDatabase 数据库查看者Database MyDatabase Viewer AAD 用户AAD User Jill Kusto(upn:jack@contoso.com)Jill Kusto (upn: jack@contoso.com) abcdefab-abcd-efef-1234-350bf486087babcdefab-abcd-efef-1234-350bf486087b aaduser=54321789-abcd-efef-1234-350bf486087b;55555555-4444-3333-2222-2d7cd011db47aaduser=54321789-abcd-efef-1234-350bf486087b;55555555-4444-3333-2222-2d7cd011db47
.show follower database MyDatabase
| mv-expand parse_json(AuthorizedPrincipalsOverride)
| project AuthorizedPrincipalsOverride.Principal.FullyQualifiedName
AuthorizedPrincipalsOverride_Principal_FullyQualifiedNameAuthorizedPrincipalsOverride_Principal_FullyQualifiedName
aaduser=87654321-abcd-efef-1234-350bf486087b;55555555-4444-3333-2222-2d7cd011db47aaduser=87654321-abcd-efef-1234-350bf486087b;55555555-4444-3333-2222-2d7cd011db47
aaduser=54321789-abcd-efef-1234-350bf486087b;55555555-4444-3333-2222-2d7cd011db47aaduser=54321789-abcd-efef-1234-350bf486087b;55555555-4444-3333-2222-2d7cd011db47

替代缓存策略Override Caching policies

通过以下方式替换 MyFollowerCluster 上的 MyDatabase 的数据库级和表级缓存策略的集合:将所有表设置为不缓存其数据,但两个特定表(MyTable1MyTable2)例外,这两个表分别将其数据缓存 1d3dReplace the collection of database and table-level caching policies for MyDatabase on MyFollowerCluster by setting all tables to not have their data cached, excluding two specific tables - MyTable1, MyTable2 - that will have their data cached for periods of 1d and 3d, respectively:

.alter follower database MyDatabase policy caching hot = 0d

.alter follower database MyDatabase table MyTable1 policy caching hot = 1d

.alter follower database MyDatabase table MyTable2 policy caching hot = 3d

.alter follower database MyDatabase caching-policies-modification-kind = replace

只有这两个特定的表缓存了数据,其余表的热数据期间为 0dOnly those two specific tables have data cached, and the rest of the tables have a hot data period of 0d:

.show tables details
| summarize TableNames = make_list(TableName) by CachingPolicy
CachingPolicyCachingPolicy TableNamesTableNames
{"DataHotSpan":{"Value":"1.00:00:00"},"IndexHotSpan":{"Value":"1.00:00:00"}}{"DataHotSpan":{"Value":"1.00:00:00"},"IndexHotSpan":{"Value":"1.00:00:00"}} ["MyTable1"]["MyTable1"]
{"DataHotSpan":{"Value":"3.00:00:00"},"IndexHotSpan":{"Value":"3.00:00:00"}}{"DataHotSpan":{"Value":"3.00:00:00"},"IndexHotSpan":{"Value":"3.00:00:00"}} ["MyTable2"]["MyTable2"]
{"DataHotSpan":{"Value":"0.00:00:00"},"IndexHotSpan":{"Value":"0.00:00:00"}}{"DataHotSpan":{"Value":"0.00:00:00"},"IndexHotSpan":{"Value":"0.00:00:00"}} ["MyTable3",...,"MyTableN"]["MyTable3",...,"MyTableN"]
.show follower database MyDatabase
| mv-expand parse_json(TableMetadataOverrides)
| project TableMetadataOverrides
TableMetadataOverridesTableMetadataOverrides
{"MyTable1":{"CachingPolicyOverride":{"DataHotSpan":{"Value":"1.00:00:00"},"IndexHotSpan":{"Value":"1.00:00:00"}}}}{"MyTable1":{"CachingPolicyOverride":{"DataHotSpan":{"Value":"1.00:00:00"},"IndexHotSpan":{"Value":"1.00:00:00"}}}}
{"MyTable2":{"CachingPolicyOverride":{"DataHotSpan":{"Value":"3.00:00:00"},"IndexHotSpan":{"Value":"3.00:00:00"}}}}{"MyTable2":{"CachingPolicyOverride":{"DataHotSpan":{"Value":"3.00:00:00"},"IndexHotSpan":{"Value":"3.00:00:00"}}}}

摘要Summary

查看追随 MyFollowerCluster 上的 MyDatabase 时的当前配置:See the current configuration where MyDatabase is being followed on MyFollowerCluster:

.show follower database MyDatabase
| evaluate narrow() // just for presentation purposes
Column ValueValue
DatabaseNameDatabaseName MyDatabaseMyDatabase
LeaderClusterMetadataPathLeaderClusterMetadataPath https://storageaccountname.blob.core.chinacloudapi.cn/cluster
CachingPolicyOverrideCachingPolicyOverride {"DataHotSpan":{"Value":"00:00:00"},"IndexHotSpan":{"Value":"00:00:00"}}{"DataHotSpan":{"Value":"00:00:00"},"IndexHotSpan":{"Value":"00:00:00"}}
AuthorizedPrincipalsOverrideAuthorizedPrincipalsOverride [{"Principal":{"FullyQualifiedName":"aaduser=87654321-abcd-efef-1234-350bf486087b",...},{"Principal":{"FullyQualifiedName":"aaduser=54321789-abcd-efef-1234-350bf486087b",...}][{"Principal":{"FullyQualifiedName":"aaduser=87654321-abcd-efef-1234-350bf486087b",...},{"Principal":{"FullyQualifiedName":"aaduser=54321789-abcd-efef-1234-350bf486087b",...}]
AuthorizedPrincipalsModificationKindAuthorizedPrincipalsModificationKind ReplaceReplace
IsAutoPrefetchEnabledIsAutoPrefetchEnabled FalseFalse
TableMetadataOverridesTableMetadataOverrides {"MyTargetTable":{"CachingPolicyOverride":{"DataHotSpan":{"Value":"3.00:00:00"}...},"MySourceTable":{"CachingPolicyOverride":{"DataHotSpan":{"Value":"1.00:00:00"},...}}}{"MyTargetTable":{"CachingPolicyOverride":{"DataHotSpan":{"Value":"3.00:00:00"}...},"MySourceTable":{"CachingPolicyOverride":{"DataHotSpan":{"Value":"1.00:00:00"},...}}}
CachingPoliciesModificationKindCachingPoliciesModificationKind ReplaceReplace