扩展事件 - 无法将对象添加到事件会话
Extended Events - Object cannot be added to the event session
当我尝试 运行 扩展事件时:
CREATE EVENT SESSION [Loading] ON SERVER
ADD EVENT sqlserver.sql_statement_completed(SET collect_statement=(1))
ADD TARGET package0.event_file(SET filename=N'C:\Users\user\Documents\test.xel',max_file_size=(10))
WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=3 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=OFF)
GO
在 SQL Server 2016 上,我得到:
The target, "5B2DA06D-898A-43C8-9309-39BBBE93EBBD.package0.event_file",
encountered a configuration error during initialization. Object cannot
be added to the event session. The operating system returned error 5:
'Access is denied.
' while creating the file 'C:\Users\user\Documents\test_0_131207679384970000.xel'. (Microsoft
SQL Server, Error: 25602)
问题出在哪里?我对 C:\Users\user\Documents.
有足够的权限
您需要向 NTService\MSSQLServer 授予对该文件夹的写入权限,这就是 SQL 服务器服务的运行方式。
您可以使用 "C:\Temp" 文件夹,它应该可以工作。
当我尝试 运行 扩展事件时:
CREATE EVENT SESSION [Loading] ON SERVER
ADD EVENT sqlserver.sql_statement_completed(SET collect_statement=(1))
ADD TARGET package0.event_file(SET filename=N'C:\Users\user\Documents\test.xel',max_file_size=(10))
WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=3 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=OFF)
GO
在 SQL Server 2016 上,我得到:
The target, "5B2DA06D-898A-43C8-9309-39BBBE93EBBD.package0.event_file", encountered a configuration error during initialization. Object cannot be added to the event session. The operating system returned error 5: 'Access is denied. ' while creating the file 'C:\Users\user\Documents\test_0_131207679384970000.xel'. (Microsoft SQL Server, Error: 25602)
问题出在哪里?我对 C:\Users\user\Documents.
有足够的权限您需要向 NTService\MSSQLServer 授予对该文件夹的写入权限,这就是 SQL 服务器服务的运行方式。
您可以使用 "C:\Temp" 文件夹,它应该可以工作。