群集 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. 因此,在新配置得到应用之前,可能会有几分钟的延迟。That's why 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 policy overrides

先导数据库可以替代随从群集中的以下数据库级策略:缓存策略经授权的主体A leader database can override the following database-level policies in the follower cluster: Caching policy and Authorized principals.

缓存策略Caching policy

随从群集的默认缓存策略使用先导群集的数据库级和表级缓存策略。The default caching policy for the follower cluster uses the leader cluster database and table-level caching policies.

选项Option 说明Description
(默认)None (default) 使用的缓存策略是在先导群集的源数据库中定义的那些策略。The caching policies used are those policies defined in the source database in the leader cluster.
replacereplace 先导群集中的源数据库的数据库级和表级缓存策略会被删除(设置为 null)。The source database in the leader cluster database and table-level caching policies are removed (set to null). 这些策略会被替换为数据库级和表级替代策略(如果已定义)。These policies are replaced by the database and table-level override policies, if defined.
unionunion 先导群集中的源数据库的数据库级和表级缓存策略将与数据库级和表级替代策略中定义的策略组合使用。The source database in the leader cluster database and table-level caching policies are combined with the policies defined in the database and table-level override policies.

备注

  • 如果替代数据库级和表级缓存策略的集合为空,则默认情况下会缓存所有内容。If the collection of override database and table-level caching policies is empty, then everything is cached by default.
  • 可以将数据库级缓存策略替代设置为 0d,则默认情况下不会缓存任何内容。You can set the database-level caching policy override to 0d, and nothing will be cached by default.

经授权的主体Authorized principals

选项Option 说明Description
(默认)None (default) 经授权的主体在先导群集的源数据库中定义。The authorized principals are defined in the source database of the leader cluster.
replacereplace 替代经授权的主体会替换先导群集中源数据库的经授权主体。The override authorized principals replace the authorized principals from the source database in the leader cluster.
unionunion 替代经授权的主体可与先导群集中源数据库的经授权主体组合使用。The override authorized principals are combined with the authorized principals from the source database in the leader cluster.

备注

如果替代经授权的主体的集合为空,则不会有数据库级主体。If the collection of override authorized principals is empty, there will be no database-level principals.

表和具体化视图策略替代Table and materialized views policy overrides

默认情况下,后继群集遵循的数据库中的表和具体化视图会保留源实体的缓存策略。By default, tables and materialized views in a database that is being followed by a follower cluster keep the source entity's caching policy. 但是,可以在后继群集中替代表和具体化视图缓存策略However, table and materialized view caching policies can be overridden in the follower cluster. 请使用 replace 选项来替代源实体的缓存策略。Use the replace option to override the source entity's caching policy.

数据库级命令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 序列化形式。If defined, A JSON serialization of table-level property overrides.

.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 deletion 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.

备注

语法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.

备注

语法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 caching policies modification kind for the follower database, table, and materialized views. 它需要 DatabaseAdmin 权限It requires DatabaseAdmin permissions.

备注

  • 可以使用标准 .show 命令查看在更改后生效的数据库级/表级缓存策略的集合:Viewing the effective collection of database/table-level caching policies after the change can be done using the standard .show commands:
  • 可以使用 .show follower database 查看在进行更改后的随从数据库上的替代设置Viewing the override settings on the follower database after the change can be done using .show follower database

语法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

.alter follower database prefetch-extents.alter follower database prefetch-extents

随从群集可以等待新数据从底层存储提取到到节点的 SSD(缓存),然后再使该数据可供查询。The follower cluster can wait for new data to be fetched from the underlying storage to the nodes' SSD (cache) before making this data queryable.

以下命令会在每次进行架构刷新时更改预提取新区的随从数据库配置。The following command alters the follower database configuration of pre-fetching new extents upon each schema refresh. 此命令需要 DatabaseAdmin 权限This command requires DatabaseAdmin permissions.

警告

  • 此设置可能会降低随从数据库中数据的时效性。This setting can degrade the freshness of data in the follower database.
  • 默认配置为 false,建议使用默认配置。The default configuration is false, and it is recommended to use the default.
  • 选择将设置更改为 true 时,请严谨地评估配置更改后一段时间内对时效性的影响。When choosing to alter the setting to true, closely evaluate the impact on freshness for some time period after the configuration change.

语法Syntax

.alter follower database DatabaseName prefetch-extents = (true | false).alter follower database DatabaseName prefetch-extents = (true | false)

示例Example

.alter follower database MyDB prefetch-extents = false

表和具体化视图命令Tables and materialized views commands

更改后继表或具体化视图的缓存策略Alter follower table or materialized view caching policy

更改后继数据库上表或具体化视图的缓存策略,替代在先导群集中的源数据库上设置的策略。Alters a table's or a materialized view's caching policy on the follower database, to override the policy set on the source database in the leader cluster. 它需要 DatabaseAdmin 权限It requires DatabaseAdmin permissions.

备注

语法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

.alter follower database DatabaseName materialized-view ViewName policy caching hot = HotDataSpan.alter follower database DatabaseName materialized-view ViewName policy caching hot = HotDataSpan

.alter follower database DatabaseName materialized-views (ViewName1,...,ViewNameN) policy caching hot = HotDataSpan.alter follower database DatabaseName materialized-views (ViewName1,...,ViewNameN) policy caching hot = HotDataSpan

示例Examples

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

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

删除后继表或具体化视图的缓存策略Delete follower table or materialized view caching policy

删除后继数据库上表或具体化视图的缓存策略替代。Deletes an override for a table's or a materialized-view's caching policy on the follower database. 在先导群集中的源数据库上设置的策略现在将成为有效策略。The policy set on the source database in the leader cluster will now be the effective policy. 需要 DatabaseAdmin 权限Requires DatabaseAdmin permissions.

备注

语法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

.delete follower database DatabaseName materialized-view ViewName policy caching.delete follower database DatabaseName materialized-view ViewName policy caching

.delete follower database DatabaseName materialized-views (ViewName1,...,ViewNameN) policy caching.delete follower database DatabaseName materialized-views (ViewName1,...,ViewNameN) policy caching

示例Example

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

.delete follower database MyDB materialized-views (View1, View2) 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: Set up 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