適用於: SQL Server 2016 (13.x)、
SQL Server 2017 (14.x) 和
SQL Server 2019 (15.x)
重要
SQL Server Distributed Replay 不適用於 SQL Server 2022 (16.x)。
Microsoft SQL Server Distributed Replay 功能可協助您評定未來 SQL Server 升級的影響, 也可以用來協助評定硬體和作業系統升級以及 SQL Server 微調的影響。
Distributed Replay 功能在 SQL Server 2022 中被廢止。
從 SQL Server 2022 (16.x) 起,Distributed Replay 已被取代,如 SQL Server 2022 (16.x) 中已被取代的資料庫引擎功能中所述。 Distributed Replay 依賴於 SQL Server Native Client (SNAC),後者已從 SQL Server 2022 (16.x) 中移除。 此項變更記載於 SQL Server Native Client 的支援原則中。 In addition, Distributed Replay relies on .trc
files, which are captured with SQL Trace and SQL Server Profiler, both of which are also deprecated.
Distributed Replay Controller 已從 SQL Server 2022 (16.x) 安裝程式中移除,且從 18 版本開始的 SQL Server Management Studio (SSMS) 中已不再提供 Distributed Replay Client。 要取得 Distributed Replay Controller,您必須安裝 SQL Server 2019 (15.x) 或更早版本。 要取得 Distributed Replay Client,您必須安裝 SSMS 17.9.1。
對於使用 SQL Server 2022 (16.x) 的客戶,可以改用重新執行標記語言 (RML) 公用程式,其中包含 ostress,以重新執行工作負載。
Distributed Replay 的優點
類似於 SQL Server Profiler,您可以使用 Distributed Replay 對已升級的測試環境重播已擷取的追蹤。 而與 SQL Server Profiler 不同的是,Distributed Replay 不限於從單一電腦重新執行工作負載。
Distributed Replay 提供比 SQL Server Profiler 更容易調整的解決方案。 您可以使用 Distributed Replay,從多台電腦重播工作負載,更好地模擬關鍵任務的負載情況。
分散重播功能可以使用多台電腦來重現追蹤資料,並模擬重要的工作負荷。 您可以使用 Distributed Replay 進行應用程式相容性測試、效能測試或容量計畫。
使用 Distributed Replay 的時機
SQL Server Profiler 和 Distributed Replay 所提供的功能有部分重疊。
You can use SQL Server Profiler to replay a captured trace against an upgraded test environment. 您也可以分析重新執行結果,以便尋找可能的功能與效能不相容。 不過,SQL Server Profiler 只能從單一電腦重新執行工作負載。 When replaying an intensive OLTP application that has many active concurrent connections or high throughput, SQL Server Profiler can become a resource bottleneck.
Distributed Replay 提供比 SQL Server Profiler 更容易調整的解決方案。 您可以使用 Distributed Replay 從多台電腦重播工作負載,更有效地模擬具關鍵性的任務工作負載。
下表將描述使用每項工具的時機。
Tool | Use when... |
---|---|
SQL Server Profiler | 您想要在單一電腦上使用傳統的重播機制。 In particular, you need line-by-line debugging capabilities, such as the Step, Run to Cursor, and Toggle Breakpoint commands. You want to replay an Analysis Services trace. |
Distributed Replay | 您想要評估應用程式相容性。 例如,您想要測試 SQL Server 和作業系統升級案例、硬體升級或索引微調。 The concurrency in the captured trace is so high that a single replay client can't sufficiently simulate it. |
Distributed Replay concepts
下列元件構成 Distributed Replay 環境:
Distributed Replay 系統管理工具:用來與 Distributed Replay Controller 進行通訊的主控台應用程式 DReplay.exe。 Use the administration tool to control the distributed replay.
Distributed Replay 控制器:一部電腦,執行名為 SQL Server Distributed Replay 控制器的 Windows 服務。 Distributed Replay Controller 可協調 Distributed Replay Client 的動作。 每個 Distributed Replay 環境都只能有一個 Controller 執行個體。
Distributed Replay 用戶端:一或多部電腦 (實體或虛擬),執行名為 SQL Server Distributed Replay 用戶端的 Windows 服務。 The Distributed Replay clients work together to simulate workloads against an instance of SQL Server. 每個 Distributed Replay 環境中可以有一個或多個用戶端。
Target server: An instance of SQL Server that the Distributed Replay clients can use to replay trace data. 我們建議將目標伺服器放置於測試環境中。
Distributed Replay 管理工具、Controller 及 Client 可以安裝在不同的電腦上,也可以安裝在同一部電腦上。 在同一部電腦上,只能執行一個 Distributed Replay Controller 或 Client 服務的執行個體。
下圖顯示 SQL Server Distributed Replay 實體架構:
Distributed Replay tasks
工作描述 | Article |
---|---|
描述如何設定 Distributed Replay。 | 設定分散式重播 (Distributed Replay) |
描述如何準備輸入追蹤資料。 | 準備輸入追蹤資料 |
Describes how to replay trace data. | Replay Trace Data |
描述如何檢閱 Distributed Replay 追蹤資料結果。 | 檢閱重新執行的結果 |
描述如何使用管理工具來起始、監視和取消控制器上的作業。 | 管理工具命令列選項 (Distributed Replay Utility) |
需求
使用 Distributed Replay 功能之前,請先考慮本文所列的產品需求。
Input trace requirements
To successfully replay trace data, it must meet the requirements for version and format, and contain the required events and columns.
Input trace versions
Distributed Replay 支援從下列 SQL Server 版本收集而來的輸入追蹤資料:
- SQL Server 2019 (15.x)
- SQL Server 2017 (14.x) (累積更新 1 和更新版本 - 請參閱 SQL Server 2017 累積更新)
- SQL Server 2016 (13.x)
- SQL Server 2014 (12.x)
- SQL Server 2012 (11.x)
- SQL Server 2008 R2 (10.50.x)
- SQL Server 2008 (10.0.x)
- SQL Server 2005 (9.x)
Input trace formats
輸入追蹤資料可以採用下列任何格式:
具有
.trc
副檔名的單一追蹤檔案。一組遵循檔案換用命名規範的換用追蹤檔案,例如:
<TraceFile>.trc
、<TraceFile>_1.trc
、<TraceFile>_2.trc
、<TraceFile>_3.trc
...<TraceFile>_n.trc
。
輸入追蹤事件與欄位
The input trace data must contain specific events and columns to be replayed by Distributed Replay. SQL Server Profiler 中的 TSQL_Replay 範本包含所有必要的事件和資料,以及額外資訊。 如需該範本的詳細資訊,請參閱 重新執行需求。
警告
若您未使用 TSQL_Replay 範本來擷取輸入追蹤資料,或不符合輸入追蹤資料的需求,可能會收到未預期的重新執行結果。
您也可以建立自訂追蹤範本,並使用該範本搭配 Distributed Replay 重新執行事件,但該範本必須包含下列事件:
- 稽核登入
- Audit Logout
- 現有連接
- RPC 輸出參數
- RPC:已完成
- RPC:Starting
- SQL:BatchCompleted
- SQL:BatchStarting
If you're replaying server-side cursors, the following events are also required:
- CursorClose
- CursorExecute
- CursorOpen
- CursorPrepare
- CursorUnprepare
如果您要重新執行伺服端已準備的 SQL 陳述式,也必須有下列事件:
- Exec Prepared SQL
- Prepare SQL
所有輸入追蹤資料都必須包含下列資料行:
- 事件類別
- 事件序列
- 文本數據
- 應用程式名稱
- 登入名稱
- 資料庫名稱
- 資料庫識別碼
- 主機名稱
- 二進位資料
- SPID
- 開始時間
- EndTime
- IsSystem
Supported input trace and target server combinations
The following table lists the supported versions of trace data, and for each, the supported versions of SQL Server that data can be replayed against.
輸入追蹤資料的版本 | 目標伺服器執行個體支援的 SQL Server 版本 |
---|---|
SQL Server 2005 (9.x) | SQL Server 2008 (10.0.x)、SQL Server 2008 R2 (10.50.x)、SQL Server 2012 (11.x)、SQL Server 2014 (12.x)、SQL Server 2016 (13.x)、SQL Server 2017 (14.x)、SQL Server 2019 (15.x) |
SQL Server 2008 (10.0.x) | SQL Server 2008 (10.0.x)、SQL Server 2008 R2 (10.50.x)、SQL Server 2012 (11.x)、SQL Server 2014 (12.x)、SQL Server 2016 (13.x)、SQL Server 2017 (14.x)、SQL Server 2019 (15.x) |
SQL Server 2008 R2 (10.50.x) | SQL Server 2008 R2 (10.50.x)、SQL Server 2012 (11.x)、SQL Server 2014 (12.x)、SQL Server 2016 (13.x)、SQL Server 2017 (14.x)、SQL Server 2019 (15.x) |
SQL Server 2012 (11.x) | SQL Server 2012 (11.x)、SQL Server 2014 (12.x)、SQL Server 2016 (13.x)、SQL Server 2017 (14.x)、SQL Server 2019 (15.x) |
SQL Server 2014 (12.x) | SQL Server 2014 (12.x)、SQL Server 2016 (13.x)、SQL Server 2017 (14.x)、SQL Server 2019 (15.x) |
SQL Server 2016 (13.x) | SQL Server 2016 (13.x)、SQL Server 2017 (14.x)、SQL Server 2019 (15.x) |
SQL Server 2017 (14.x) | SQL Server 2017 (14.x)、SQL Server 2019 (15.x) |
SQL Server 2019 (15.x) | SQL Server 2019 (15.x) |
作業系統需求
支援執行管理工具以及控制器和用戶端服務的作業系統,與 SQL Server 執行個體相同。 如需 SQL Server 執行個體支援的作業系統詳細資訊,請參閱SQL Server 2016 和 2017:硬體與軟體需求。
x86 及 x64 作業系統皆支援 Distributed Replay 功能。 若為 x64 架構作業系統,只支援 Windows on Windows (WOW) 模式。
安裝限制
Any one computer can only have a single instance of each Distributed Replay feature installed. 下表列出單一 Distributed Replay 環境中對於各項功能所能夠安裝的數量。
Distributed Replay Feature | 每個重播環境的最大安裝數目 |
---|---|
SQL Server Distributed Replay controller service | 1 |
SQL Server Distributed Replay 用戶端服務 | 16 (實體或虛擬電腦) |
管理工具 | 無限制 |
Note
雖然單一電腦只能安裝一個管理工具的執行個體,不過您可以啟動多個管理工具的執行個體。 從多個管理工具發出的命令會按照系統接收的順序來解析。
資料存取提供者
Distributed Replay 只支援 SQL Server Native Client ODBC 資料存取提供者。
目標伺服器準備需求
我們建議將目標伺服器放置於測試環境中。 若要針對與原始記錄不同的 SQL Server 執行個體重新執行追蹤資料,請確定已在目標伺服器完成下列步驟:
追蹤資料中包含的所有登入與使用者都必須存在目標伺服器的相同資料庫中。
目標伺服器上的所有登入與使用者,其權限必須與在原始伺服器上擁有的權限相同。
目標上的資料庫識別碼必須與來源上的一樣。 不過,如果不相同,若追蹤內有 DatabaseName,就可以據此執行比對。
The default database for each login that is contained in the trace data must be set (on the target server) to the respective target database of the login. 例如,要重新執行的追蹤資料包含登入 Fred 的活動,位於原始 SQL Server 執行個體的資料庫 Fred_Db 中。 因此,在目標伺服器上, Fred登入的預設資料庫必須設成符合 Fred_Db 的資料庫 (即使資料庫名稱不同)。 若要設定登入的預設資料庫,可使用
sp_defaultdb
系統預存程序。
重新執行與找不到或不正確登入相關的事件時,會產生重播錯誤,但重播操作仍會繼續進行。