Follower 命令

用于管理关注者配置的管理命令。 这些命令以同步方式运行,但在架构下次定期刷新时应用,这可能会导致在应用新配置之前出现短暂的延迟。

follower 命令包括数据库级命令表级命令

权限

你必须至少具有数据库管理员权限才能运行此命令。

数据库策略替代

先导数据库可以替代随从群集中的以下数据库级策略:缓存策略经授权的主体

缓存策略

随从群集的默认缓存策略使用先导群集的数据库级和表级缓存策略。

选项 Description
使用的缓存策略是在先导群集的源数据库中定义的那些策略。
replace 先导群集中的源数据库的数据库级和表级缓存策略会被删除(设置为 null)。 这些策略会被替换为数据库级和表级替代策略(如果已定义)。
union(默认) 先导群集中的源数据库的数据库级和表级缓存策略将与数据库级和表级替代策略中定义的策略组合使用。

注意

  • 如果替代数据库级和表级缓存策略的集合为空,则默认情况下会缓存所有内容。
  • 可以将数据库级缓存策略替代设置为 0d,则默认情况下不会缓存任何内容。

经授权的主体

选项 Description
经授权的主体在先导群集的源数据库中定义。
replace 替代经授权的主体会替换先导群集中源数据库的经授权主体。
union(默认) 替代经授权的主体可与先导群集中源数据库的经授权主体组合使用。

注意

如果替代经授权的主体的集合为空,则不会有数据库级主体。

表和具体化视图策略替代

默认情况下,后继群集遵循的数据库中的表和具体化视图会保留源实体的缓存策略。 但是,可以在后继群集中替代表和具体化视图缓存策略。 请使用 replace 选项来替代源实体的缓存策略。

数据库级命令

.show follower database

显示从其他先导群集追随的一个或多个数据库,它们配置了一个或多个数据库级替代项。

语法

.showfollowerdatabaseDatabaseName

.showfollowerdatabases(DatabaseName1,...,DatabaseNameN)

输出

输出参数 类型 说明
DatabaseName string 被追随的数据库的名称。
LeaderClusterMetadataPath string 先导群集的元数据容器的路径。
CachingPolicyOverride string 数据库的替代缓存策略,已序列化为 JSON 或 null。
AuthorizedPrincipalsOverride string 数据库的经授权主体的替代集合,已序列化为 JSON 或 null。
AuthorizedPrincipalsModificationKind string 要使用 AuthorizedPrincipalsOverride(noneunionreplace)来应用的修改类型。
CachingPoliciesModificationKind string 要使用数据库级或表级缓存策略替代(noneunionreplace)来应用的修改类型。
IsAutoPrefetchEnabled bool 在每次进行架构刷新时是否预先提取新数据。
TableMetadataOverrides string 如果已定义此项,则此项是表级属性替代的 JSON 序列化形式。

.alter follower database policy caching

更改随从数据库缓存策略,以替代在先导群集中的源数据库上设置的策略。

说明

语法

.alterfollowerdatabaseDatabaseNamepolicycachinghot=HotDataSpan

示例

.alter follower database MyDb policy caching hot = 7d

.delete follower database policy caching

删除随从数据库替代缓存策略。 此删除操作会导致在先导群集中的源数据库上设置的策略成为生效的策略。

备注

语法

.deletefollowerdatabaseDatabaseNamepolicycaching

示例

.delete follower database MyDB policy caching

.add follower database principals

将经授权的主体添加到替代经授权主体的随从数据库集合中。 说明

语法

.addfollowerdatabaseDatabaseName (admins | users | viewers | monitors) Role (principal1,...,principalN) ['notes']

示例

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

.drop follower database principals

将经授权的主体从替代经授权主体的随从数据库集合中删除。

注意

语法

.dropfollowerdatabaseDatabaseName (admins | users | viewers | monitors) (principal1,...,principalN)

示例

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

.alter follower database principals-modification-kind

更改随从数据库经授权主体修改类型。

注意

语法

.alterfollowerdatabaseDatabaseNameprincipals-modification-kind = (none | union | replace)

示例

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

.alter follower database caching-policies-modification-kind

更改后继数据库、表和具体化视图的缓存策略修改类型。

注意

语法

.alterfollowerdatabaseDatabaseNamecaching-policies-modification-kind = (none | union | replace)

示例

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

.alter follower database prefetch-extents

随从群集可以等待新数据从底层存储提取到到节点的 SSD(缓存),然后再使该数据可供查询。

以下命令会在每次进行架构刷新时更改预提取新区的随从数据库配置。

警告

  • 此设置可能会降低随从数据库中数据的时效性。
  • 默认配置为 false,建议使用默认配置。
  • 选择将设置更改为 true 时,请严谨地评估配置更改后一段时间内对时效性的影响。

语法

.alterfollowerdatabaseDatabaseNameprefetch-extents = (true | false)

示例

.alter follower database MyDB prefetch-extents = false

表和具体化视图命令

更改后继表或具体化视图的缓存策略

更改后继数据库上表或具体化视图的缓存策略,替代在先导群集中的源数据库上设置的策略。

注意

语法

.alterfollowerdatabaseDatabaseName table TableNamepolicycachinghot=HotDataSpan

.alterfollowerdatabaseDatabaseName tables (TableName1,...,TableNameN)policycachinghot=HotDataSpan

.alterfollowerdatabaseDatabaseName materialized-view ViewNamepolicycachinghot=HotDataSpan

.alterfollowerdatabaseDatabaseName materialized-views (ViewName1,...,ViewNameN)policycachinghot=HotDataSpan

示例

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

.alter follower database MyDb materialized-views (View1, View2) policy caching hot = 7d

删除后继表或具体化视图的缓存策略

删除后继数据库上表或具体化视图的缓存策略替代。 在先导群集中的源数据库上设置的策略现在将成为有效策略。

注意

语法

.deletefollowerdatabaseDatabaseNametableTableNamepolicycaching

.deletefollowerdatabaseDatabaseNametables(TableName1,...,TableNameN)policycaching

.deletefollowerdatabaseDatabaseNamematerialized-viewViewNamepolicycaching

.deletefollowerdatabaseDatabaseNamematerialized-views(ViewName1,...,ViewNameN)policycaching

示例

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

.delete follower database MyDB materialized-views (View1, View2) policy caching

示例配置

下面是用于配置随从数据库的示例步骤。

在本示例中:

  • 我们的随从群集 MyFollowerCluster 将追随先导群集 MyLeaderCluster 中的数据库 MyDatabase

    • MyDatabase 具有 N 表:MyTable1MyTable2MyTable3、... MyTableN (N> 3)。
    • MyLeaderCluster上:
    MyTable1 缓存策略 MyTable2 缓存策略 MyTable3...MyTableN 缓存策略 MyDatabase 经授权的主体
    热数据跨度 = 7d 热数据跨度 = 30d 热数据跨度 = 365d 查看者 = aadgroup=scubadivers@contoso.com管理员 = aaduser=jack@contoso.com
    • MyFollowerCluster 上,我们需要:
    MyTable1 缓存策略 MyTable2 缓存策略 MyTable3...MyTableN 缓存策略 MyDatabase 经授权的主体
    热数据跨度 = 1d 热数据跨度 = 3d 热数据跨度 = 0d(不缓存任何内容) 管理员 = aaduser=jack@contoso.com查看者 = aaduser=jill@contoso.com

重要

MyFollowerClusterMyLeaderCluster 必须位于同一区域中。

要执行的步骤

先决条件:将群集 MyFollowerCluster 设置为追随群集 MyLeaderCluster 中的数据库 MyDatabase

注意

运行管理命令的主体应为数据库 MyDatabase 上的 DatabaseAdmin

显示当前配置

查看追随 MyFollowerCluster 上的 MyDatabase 时所遵循的当前配置:

.show follower database MyDatabase
| evaluate narrow() // just for presentation purposes
Value
DatabaseName MyDatabase
LeaderClusterMetadataPath https://storageaccountname.blob.core.chinacloudapi.cn/cluster
CachingPolicyOverride Null
AuthorizedPrincipalsOverride []
AuthorizedPrincipalsModificationKind
IsAutoPrefetchEnabled False
TableMetadataOverrides
CachingPoliciesModificationKind Union

替代经授权的主体

MyFollowerClusterMyDatabase 的授权主体集合替换为仅包含一个 Microsoft Entra 用户作为数据库管理员和一个 Microsoft Entra 用户作为数据库查看者的集合:

.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 上的 MyDatabase

.show database MyDatabase principals
角色 PrincipalType PrincipalDisplayName PrincipalObjectId PrincipalFQN 注释
MyDatabase 数据库管理员 Microsoft Entra 用户 Jack Kusto(upn:jack@contoso.com) 12345678-abcd-efef-1234-350bf486087b aaduser=87654321-abcd-efef-1234-350bf486087b;55555555-4444-3333-2222-2d7cd011db47
MyDatabase 数据库查看者 Microsoft Entra 用户 Jill Kusto(upn:jack@contoso.com) abcdefab-abcd-efef-1234-350bf486087b aaduser=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_FullyQualifiedName
aaduser=87654321-abcd-efef-1234-350bf486087b;55555555-4444-3333-2222-2d7cd011db47
aaduser=54321789-abcd-efef-1234-350bf486087b;55555555-4444-3333-2222-2d7cd011db47

替代缓存策略

通过以下方式替换 MyFollowerCluster 上的 MyDatabase 的数据库级和表级缓存策略的集合:将所有表设置为不缓存其数据,但两个特定表(MyTable1MyTable2)例外,这两个表分别将其数据缓存 1d3d

.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

只有这两个特定的表缓存了数据,其余表的热数据期间为 0d

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

摘要

查看追随 MyFollowerCluster 上的 MyDatabase 时的当前配置:

.show follower database MyDatabase
| evaluate narrow() // just for presentation purposes
Value
DatabaseName MyDatabase
LeaderClusterMetadataPath https://storageaccountname.blob.core.chinacloudapi.cn/cluster
CachingPolicyOverride {"DataHotSpan":{"Value":"00:00:00"},"IndexHotSpan":{"Value":"00:00:00"}}
AuthorizedPrincipalsOverride [{"Principal":{"FullyQualifiedName":"aaduser=87654321-abcd-efef-1234-350bf486087b",...},{"Principal":{"FullyQualifiedName":"aaduser=54321789-abcd-efef-1234-350bf486087b",...}]
AuthorizedPrincipalsModificationKind Replace
IsAutoPrefetchEnabled False
TableMetadataOverrides {"MyTargetTable":{"CachingPolicyOverride":{"DataHotSpan":{"Value":"3.00:00:00"}...},"MySourceTable":{"CachingPolicyOverride":{"DataHotSpan":{"Value":"1.00:00:00"},...}}}
CachingPoliciesModificationKind Replace