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
| Parameter | Type | Required | Description |
|---|---|---|---|
-Store | string | Yes | The local store to link. Position 0. |
-PeerStore | string | Yes | The peer store to link to. |
-SiteId | string | No | Site id for the local store. Defaults to its clusterId. |
-Label | string | No | Cosmetic display label for the local site. |
-LocalSeeds | string | No | The local site's external endpoint (host:port) the peer pulls from. |
-PeerSeeds | string | No | The peer site's external endpoint (host:port) this site pulls from. |
-PeerLabel | string | No | Cosmetic display label for the peer site. |
-PeerWorkspace | string | No | A registered workspace naming the peer's manager; resolved locally, not activated. Alternative to -PeerManagers. |
-PeerManagers | string[] | No | Inline peer manager endpoint(s), when the peer workspace is not registered here. |
-PeerToken | string | No | Admin token for the peer manager (when inline, or to override a stale saved token). |
-Mode | SiteMode | No | ActivePassive (default) or ActiveActive. |
-Primary | string | No | Active-passive only: which store is the active primary. Defaults to -Store. |
-MergePolicy | MergePolicy | No | Conflict convergence for active-active. LastWriterWins (default, HLC). |
-HomeSitePrefixes | string[] | No | Key prefixes homed to this site. |
-Restart | switch | No | Rolling-restart each running node so it picks up the link immediately. |
-Managers | string[] | No | Local Management Service endpoints to target. When omitted, the active workspace's managers are used. |
-Port | int | No | Management Service port for bare-host managers. Default 7801. |
-Token | string | No | Admin bearer token for the local managers. |
-TimeoutSec | int | No | Per-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"