Aller au contenu principal

New-ZrSiteLink

Links a store to a peer store in another workspace for WAN replication, configuring both sides of the link in one call.

Syntax​

New-ZrSiteLink
[-Store] <string>
-PeerStore <string>
[-SiteId <string>] [-Label <string>] [-LocalSeeds <string>]
[-PeerSeeds <string>] [-PeerLabel <string>]
[-PeerWorkspace <string>] [-PeerManagers <string[]>] [-PeerToken <string>]
[-Mode <SiteMode>] [-Primary <string>] [-MergePolicy <MergePolicy>]
[-HomeSitePrefixes <string[]>] [-Restart]
[-Managers <string[]>] [-Port <int>] [-Token <string>] [-TimeoutSec <int>]
[-WhatIf] [-Confirm]

Description​

You run New-ZrSiteLink from the local (bound) workspace and name the peer either by a registered workspace (-PeerWorkspace, resolved from the local registry without activating it) or inline with -PeerManagers/-PeerToken. A site's identity is its store's clusterId, so there is nothing else to name. The change feed is enabled automatically on both sides.

The -Mode chooses the replication shape:

  • ActivePassive (default) — one-way. -Primary (defaults to -Store) is the active, writable site; the other becomes a read-only mirror.
  • ActiveActive — bidirectional; both sites take writes and concurrent writes converge by -MergePolicy (HLC last-writer-wins).

The cmdlet applies the local side to every resolved local manager and the peer side to the peer's managers, printing a per-manager result and emitting a StoreSiteApplyResult. It requires local managers (active workspace or -Managers) and supports -WhatIf/-Confirm. If the peer's saved token is missing or expired, re-save it with Set-ZrWorkspace -Token or pass -PeerToken.

Parameters​

ParameterTypeRequiredDescription
-StorestringYesThe local store to link. Position 0.
-PeerStorestringYesThe peer store to link to.
-SiteIdstringNoSite id for the local store. Defaults to its clusterId.
-LabelstringNoCosmetic display label for the local site.
-LocalSeedsstringNoThe local site's external endpoint (host:port) the peer pulls from.
-PeerSeedsstringNoThe peer site's external endpoint (host:port) this site pulls from.
-PeerLabelstringNoCosmetic display label for the peer site.
-PeerWorkspacestringNoA registered workspace naming the peer's manager; resolved locally, not activated. Alternative to -PeerManagers.
-PeerManagersstring[]NoInline peer manager endpoint(s), when the peer workspace is not registered here.
-PeerTokenstringNoAdmin token for the peer manager (when inline, or to override a stale saved token).
-ModeSiteModeNoActivePassive (default) or ActiveActive.
-PrimarystringNoActive-passive only: which store is the active primary. Defaults to -Store.
-MergePolicyMergePolicyNoConflict convergence for active-active. LastWriterWins (default, HLC).
-HomeSitePrefixesstring[]NoKey prefixes homed to this site.
-RestartswitchNoRolling-restart each running node so it picks up the link immediately.
-Managersstring[]NoLocal Management Service endpoints to target. When omitted, the active workspace's managers are used.
-PortintNoManagement Service port for bare-host managers. Default 7801.
-TokenstringNoAdmin bearer token for the local managers.
-TimeoutSecintNoPer-request timeout in seconds. Default 30.

Supports -WhatIf and -Confirm.

Examples​

Link local orders to the peer orders store in a registered dr workspace, active-passive with the local store primary, and restart nodes to apply it now.

New-ZrSiteLink -Store orders -PeerStore orders -PeerWorkspace dr `
-LocalSeeds "east.example.com:7861" -PeerSeeds "west.example.com:7861" -Restart

Create a bidirectional active-active link to an inline peer.

New-ZrSiteLink -Store orders -PeerStore orders -Mode ActiveActive `
-PeerManagers @('west.example.com:7801') -PeerToken $peerToken `
-LocalSeeds "east.example.com:7861" -PeerSeeds "west.example.com:7861"