Distributed Replay: تبدیل، Preprocess و Replay Trace
یادداشت حقوقی: کاربر حق ترجمه و بازنشر این اثر را برای پروژه تأیید کرده است.PAGE-808بازپخش Trace
پس از Capture، Trace ابتدا به فرمت قابل استفاده برای Distributed Replay تبدیل میشود، سپس Preprocess میگردد و در نهایت با ابزار خط فرمان dreplay روی Clientها Dispatch میشود. برای تبدیل XEL به TRC، کتاب از ReadTrace در مجموعه RML Utilities استفاده میکند.
Converting the Trace File
Replaying the Trace
Now that we have captured a trace, we convert it to a .trc file and then preprocess
it before replaying it by using the Distributed Replay Administration Tool from the
command line.
Converting the Trace File
In order to use our .xel file with Distributed Replay, we first need to convert it to a .trc
file. We do this with the help of the readtrace.exe command-line tool, which uses RML
(Replay Markup Language) to convert the data. ReadTrace ships as part of Microsoft’s
RML Utilities for SQL Server toolset, which you can download from www.microsoft.com/
en-gb/download/details.aspx?id=4511. The following example assumes that you have
installed this toolkit.
Tip The preceding link contains all RML Utilities, and this chapter uses this
version of the tools. A newer version of ReadTrace can be downloaded as part of
DEA (Database Experimentation Assistant), however, which can be found at www.
microsoft.com/en-us/download/details.aspx?id=54090.
Here, we convert our trace file by navigating to the C:\Program Files\Microsoft
Corporation\RMLUtils folder and running ReadTrace.exe with the arguments detailed
in Table 21-5.
Table 21-5. ReadTrace Arguments
Argument
Description
-I
The fully qualified file name of the .xel file to convert.
-O
The folder to output the results to. This includes the log file as well as the .trc file.
-a
Prevent analytical processing.
-MS
Mirror to a single .trc file, as opposed to separate files for each SPID.
PAGE-809ReadTrace
ReadTrace پارامترهای ورودی/خروجی را دریافت میکند و Trace مناسب را تولید میکند. مسیر فایلها باید با محیط واقعی جایگزین شود. بهتر است Conversion Log بررسی شود تا Eventهای ناسازگار یا Missing Fieldها پیش از Replay مشخص شوند.
Listing 21-11 — ReadTrace
Tip You can find a full description of all ReadTrace arguments in the RML Utilities
for SQL Server help file.
We run ReadTrace by using the command in Listing 21-11.
Tip Remember to change the filename and path of the input and output files
before running this script. Even if you have used the same location, your .xel file
name will include a different uniquifier.
Listing 21-11. Converting to .trc Using ReadTrace
readtrace.exe -I"C:\MSSQL\DReplay_0_130737313343740000.xel" -O"C:\MSSQLDReplayTraceFile" -a -MS
Preprocessing the Trace Data
The Administration Tool is a command-line utility, which can be run with the options
detailed in Table 21-6.
Table 21-6. Administration Tool Options
Option
Description
Preprocess
Prepares the trace data by creating the intermediate files
Replay
Dispatches the trace to the clients and begins the replay
Status
Displays the controller’s current status
Cancel
Cancels the current operation
When run with the preprocess option, the Administration Tool accepts the
arguments detailed in Table 21-7.
PAGE-810Preprocess
دستور dreplay preprocess فایل Trace را به Intermediate Files تبدیل میکند. Controller و Working Directory باید قابل دسترس باشند و Pathها با Config هماهنگ باشند.
Listing 21-12 — Preprocess Command
To preprocess our trace file, we can use the command in Listing 21-12. This process
creates an intermediate file, which can then be dispatched to the clients, ready for replay.
Tip Change the file paths to match your configuration before you run this script.
Listing 21-12. Preprocessing the Trace
dreplay preprocess -m controller -i "C:\MSSQL\DReplayTraceFile\SPID00000.
trc" -d "c:\Distributed Replay\WorkingDir" -c "C:\Program Files (x86)Microsoft SQL Server\150\Tools\Binn\DReplay.exe.preprocess.config"
Starting the Replay
You can start the replay using the Distributed Replay Administration Tool. The arguments
accepted when the tool is used with the replay option are detailed in Table 21-8.
Table 21-7. Preprocess Arguments
Argument Full Name
Description
-m
Controller
The name of the server hosting the Distributed Replay
Controller.
-i
input_trace_file
The fully qualified file name of the trace file. If there are
rollover files, then specify a comma-separated list.
-d
controller_working_dir
The folder where intermediate files are stored.
-c
config_file
The fully qualified file name of the DReplay.exe.
preprocess.config configuration file.
-f
status_interval
The frequency with which status messages are
displayed, specified in milliseconds.
PAGE-811Replay روی Clientها
دستور dreplay replay نام Controller، Working Directory، Target و فهرست Clientها را میگیرد. در نمونه کتاب Client1 و Client2 Workload را همزمان به Target ارسال میکنند. Status و Output باید در حین اجرا مانیتور شود تا Error یا Client Drop مشخص شود.
Listing 21-13 — Replay Command
Therefore, to replay the trace, using Client1 and Client2, against our Target server, we
use the command in Listing 21-13.
Listing 21-13. Replaying the Trace
dreplay replay -m controller -d "c:\Distributed Replay\WorkingDir" -s
Target -o -w Client1,Client2 -c "C:\Program Files (x86)\Microsoft SQL
Server\150\Tools\Binn\DReplay.Exe.Replay.config"
Tip The first line of the output may indicate that no events have been dispatched.
This is not an issue—it just means that the event dispatch has not yet started.
Table 21-8. Replay Arguments
Argument
Full Name
Description
-m
Controller
The name of the server hosting the Distributed
Replay Controller
-d
controller_working_dir
The folder where intermediate files are stored
-o
output
Specifies that client’s replay activity should be
captured and saved to the Results directory
-s
target_server
The server\instance name of the Target server
-w
clients
A comma-separated list of clients
-c
config_file
The fully qualified name of the DReplay.exe.
replay.config configuration file
-f
status_interval
The frequency at which to display the status,
specified in seconds
PAGE-812جمعبندی فصل ۲۱
Distributed Replay امکان بازپخش Workload ثبتشده با Profiler یا Extended Events را فراهم میکند و بهویژه برای Load Test و شبیهسازی چند Client مفید است. اجرای قابل اعتماد نیازمند Topology صحیح، Permission و Firewall مناسب، Synchronization داده، Capture کامل Eventها، Preprocess بدون خطا و Baseline مقایسهپذیر است.
جمعبندی کامل منبع
Summary
Distributed Replay provides a mechanism to replay traces captured with either Profiler
or Extended Events. Unlike its predecessor, Profiler, which is deprecated for use with
the Database Engine, Distributed Replay can replay the workload from multiple servers,
which allows you to perform load testing and simulate multiple concurrent connections.
The controller is the server running the Distributed Replay Controller service, which
synchronizes the replay and can be configured to work in two different modes: stress and
synchronization. In stress mode, the controller fires the events as quickly as possible,
while in synchronization mode, it fires the events in the order in which they were
captured.
The clients are the servers running the Distributed Replay Client service, which
replays the trace. Distributed Replay supports a maximum of 16 clients. The target is the
instance to which the events are dispatched by the clients.
Although it is possible to replay a trace captured in Profiler, Extended Events use less
resources and provide more flexibility. Therefore, consider using this method to capture
the trace. In order to replay an Extended Event session with Distributed Replay, however,
you first need to convert the .xel file to a .trc file. You can do this using RML Utilities,
which are available for download at www.microsoft.com.
The Distributed Replay Administration Tool is a command-line tool that is used
to both preprocess and run the trace. When run in preprocess mode, it creates an
intermediate file. When run in replay mode, it generates dispatch files on the clients and
uses these files to dispatch the events to the target.