1

それはmsdb、リソース、マスター、またはローカルですか?XEを実行するローカルデータベースをバックアップする場合、セッションもバックアップしますか?システムテーブルにもメタデータが保存されていますか?皆さん、ありがとうございました。

4

2 に答える 2

2

さまざまな拡張DMVからそれらを取得できます。たとえば、以下のクエリは、拡張イベントに関する一連の情報を返します。コメントアウトされたいくつかのフィルターが含まれています:

-- Extended Event Packages
select
    name,
    guid,
    description
from sys.dm_xe_packages
where (capabilities is null or capabilities & 1 = 0) -- ignore private packages for SQL Server internal use

-- Events
select
    p.name as package_name,
    o.name as source_name,
    o.description
from sys.dm_xe_packages as p
    inner join sys.dm_xe_objects as o
        on p.guid = o.package_guid
where
    (p.capabilities is null or p.capabilities & 1 = 0)
and (o.capabilities is null or o.capabilities & 1 = 0)
and o.object_type = 'event'
--and o.name like 's%'

-- Event targets
select
    p.name as package_name,
    o.name as source_name,
    o.description
from sys.dm_xe_packages as p
    inner join sys.dm_xe_objects as o
        on p.guid = o.package_guid
where
    (p.capabilities is null or p.capabilities & 1 = 0)
and (o.capabilities is null or o.capabilities & 1 = 0)
and o.object_type = 'target'

-- Predicate sources
select
    p.name as package_name,
    o.name as source_name,
    o.description
from sys.dm_xe_packages as p
    inner join sys.dm_xe_objects as o
        on p.guid = o.package_guid
where
    (p.capabilities is null or p.capabilities & 1 = 0)
and (o.capabilities is null or o.capabilities & 1 = 0)
and o.object_type = 'pred_source'

-- Predicate comparators
select
    p.name as package_name,
    o.name as source_name,
    o.description
from sys.dm_xe_packages as p
    inner join sys.dm_xe_objects as o
        on p.guid = o.package_guid
where
    (p.capabilities is null or p.capabilities & 1 = 0)
and (o.capabilities is null or o.capabilities & 1 = 0)
and o.object_type = 'pred_compare'

-- Maps
select
    p.name as package_name,
    o.name as source_name,
    o.description
from sys.dm_xe_packages as p
    inner join sys.dm_xe_objects as o
        on p.guid = o.package_guid
where
    (p.capabilities is null or p.capabilities & 1 = 0)
and (o.capabilities is null or o.capabilities & 1 = 0)
and o.object_type = 'map'

-- Types
select
    p.name as package_name,
    o.name as source_name,
    o.description
from sys.dm_xe_packages as p
    inner join sys.dm_xe_objects as o
        on p.guid = o.package_guid
where
    (p.capabilities is null or p.capabilities & 1 = 0)
and (o.capabilities is null or o.capabilities & 1 = 0)
and o.object_type = 'Type'

-- Event columns
select
    o.name as [event],
    oc.name as column_name,
    oc.column_type as column_type,
    oc.column_value as column_value,
    oc.description as column_description
from
    sys.dm_xe_packages as p
    inner join sys.dm_xe_objects as o
        on p.guid = o.package_guid
    inner join sys.dm_xe_object_columns as oc
        on o.name = oc.object_name
        and o.package_guid = oc.object_package_guid
where
    (p.capabilities is null or p.capabilities & 1 = 0)
and (o.capabilities is null or o.capabilities & 1 = 0)
and (oc.capabilities is null or oc.capabilities & 1 = 0)
and o.object_type = 'event'
--and o.name like '%lock%'
order by event, column_name


-- Configurable Event Columns
-- These elements are optional and usually not present in event output.
-- They can be enabled as needed.
select
    o.name as [event],
    oc.name as column_name,
    oc.column_type as column_type,
    oc.column_value as column_value,
    oc.description as column_description
from
    sys.dm_xe_packages as p
    inner join sys.dm_xe_objects as o
        on p.guid = o.package_guid
    inner join sys.dm_xe_object_columns as oc
        on o.name = oc.object_name
        and o.package_guid = oc.object_package_guid
where
    (p.capabilities is null or p.capabilities & 1 = 0)
and (o.capabilities is null or o.capabilities & 1 = 0)
and (oc.capabilities is null or oc.capabilities & 1 = 0)
and o.object_type = 'event'
--and o.name = 'file_write_completed'
and oc.column_type = 'customizable'

-- Configurable options
select
    oc.name as column_name,
    oc.column_id,
    oc.type_name,
    oc.capabilities_desc,
    oc.description
from
    sys.dm_xe_packages as p
    inner join sys.dm_xe_objects as o
        on p.guid = o.package_guid
    inner join sys.dm_xe_object_columns as oc
        on o.name = oc.object_name
        and o.package_guid = oc.object_package_guid
where
    (p.capabilities is null or p.capabilities & 1 = 0)
and (o.capabilities is null or o.capabilities & 1 = 0)
and (oc.capabilities is null or oc.capabilities & 1 = 0)
and o.object_type = 'target'
--and o.name = 'file_write_completed'
and oc.column_type = 'customizable'

-- Map Values
select
    name,
    map_key,
    map_value
from sys.dm_xe_map_values
where 1 = 1
--and name = 'wait_types' 
--and map_value like 'lck%'
于 2013-07-23T17:21:06.823 に答える
0

少し掘り下げてみると、セッションの定義がマスターデータベースに保存されていることがわかりました(セッションはサーバーレベルで定義されているので、考えてみると理にかなっています)。

このデータベースをバックアップすると、作成したセッションがバックアップされますが、それらを復元する最も簡単な方法ではありません。セッションをエクスポートしてテンプレートとして保存するか、スクリプトを作成して安全な場所に保存するのがおそらく最善です。

于 2013-03-22T16:18:23.543 に答える