SSISDB 系列随笔汇总:

操作实例(Operation)是对SSIS Project所做的任何一次操作,例如,部署SSIS工程,执行Package等,都被抽象成一个操作。在执行每一次操作时,SSISDB都会记录操作的执行情况和消息。消息的记录是由事件触发时的,在触发事件时,SSIS引擎会记录事件产生的消息和事件的上下文,通过操作实例的消息,能够监控操作实例的运行情况,对已发生的错误进行故障排除。

在实际的项目开发过程中,通常使用SQL Server Agent创建Job来调用Package,每一个Job Step都会创建一个操作实例,分配一个操作实例的ID。操作实例分为用户操作和系统操作,共计10种类型:

  • 1 :Integration Services initialization
  • 2 :Retention window
  • 3 :MaxProjectVersion
  • 101 :deploy_project
  • 106 :restore_project
  • 200 :create_execution and start_execution
  • 202 :stop_operation
  • 300 :validate_project
  • 301 :validate_package
  • 1000 :configure_catalog

系统操作实例主要用于系统维护和版本控制,而用户操作实例主要是Package的执行。

一,维护操作

操作实例产生的消息可能很多,SSIS引擎会把操作实例产生的消息都记录到SSISDB数据库中,随着时间的增长,数据库记录的消息数据会持续增大,导致SSISDB数据库变得臃肿,占用的硬盘空间增加,查询性能变慢。

SSIS引擎自动创建一个用于管理SSISDB的Agent,叫做“SSIS Server Maintenance Job”,该Job每天运行一次,共有两个Job Step,分别用于移除操作的消息记录和工程版本(Project Version)。这个Job的两个Step通过调用SP来清理过时的数据和工程版本:

EXEC [internal].[cleanup_server_retention_window]
EXEC [internal].[cleanup_server_project_version]

如果操作类型(Operation Type)是 Retention Windows,表示SSIS引擎执行历史消息的清理操作,将保持窗口(Retention window)之外的操作记录及其消息删除;如果操作类型是MaxProjectVersion,表示SSIS引擎执行工程版本清理操作,维持一定数量的Project version,将老的的Project Version删除。

在清理过时的数据和版本时,用户可以通过SSMS(依次点击Integration Services\SSISDB\Properties)查看SSIS的属性,用户只需要修改配置属性,就能控制Agent在何时清理过时的数据,

用户可以通过视图:catalog.catalog_properties 查看,集成服务引擎的属性

  • VERSION_CLEANUP_ENABLED:当该属性值是TRUE时,表示启用版本清理,SSISDB只存储指定数量(MAX_PROJECT_VERSIONS)的工程版本,过时的工程版本被删除;当该属性值是FALSE时,禁用版本删除,保存所有的的版本。
  • MAX_PROJECT_VERSIONS:该属性值表示SSISDB最多为一个工程(Project)保存的版本数量。如果启用版本清理功能,那么大于该版本的工程版本将会被删除。
  • OPERATION_CLEANUP_ENABLED:该属性值为TRUE时,表示启用操作消息清理,SSISDB只存储在特定时间窗口内的操作的历史记录和关于操作的消息,超过时间窗口的消息和历史记录被删除;如果该属性值是FALSE,那么SSISDB存储操作的所有历史记录和关于操作的所有消息,不会清理操作的任何信息。
  • RETENTION_WINDOW:该属性设置保持操作消息的时间窗口,单位是天(day),如果设置为-1,表示时间窗口无限大;注意,如果不做操作消息的清理,那么设置OPERATION_CLEANUP_ENABLED为FALSE,用户可以禁用操作消息的清理。

二,从SSISDB中查询操作实例

在查询操作实例之前,首先创建辅助数据,使用以下的脚本创建,便于窗口类型ID对应的类型文本(Name):

use SSISDB
go create schema helper
go create table helper.OperationType
(
operation_type int not null,
operation_type_descr varchar(256) not null,
invoker varchar(256) not null
)
go insert into helper.OperationType
(
operation_type,
operation_type_descr,
invoker
)
values
(1, 'Integration Services initialization','')
,(2, 'Retention window','SQL Agent job')
,(3, 'MaxProjectVersion','SQL Agent job')
,(101, 'deploy_project','Stored procedure')
,(106, 'restore_project','Stored procedure')
,(200, 'create_execution and start_execution','Stored procedures')
,(202, 'stop_operation','Stored procedure')
,(300, 'validate_project','Stored procedure')
,(301, 'validate_package','Stored procedure')
,(1000, 'configure_catalog','Stored procedure')
go create table helper.MessageType
(
message_type int not null,
message_type_descr varchar(256) not null
)
go insert into helper.MessageType
(
message_type,
message_type_descr
)
values
(-1,'Unknown')
,(120,'Error')
,(110,'Warning')
,(70,'Information')
,(10,'Pre-validate')
,(20,'Post-validate')
,(30,'Pre-execute')
,(40,'Post-execute')
,(60,'Progress')
,(50,'StatusChange')
,(100,'QueryCancel')
,(130,'TaskFailed')
,(90,'Diagnostic')
,(200,'Custom')
,(140,'DiagnosticEx, Whenever an Execute Package task executes a child package, it logs this event. The event message consists of the parameter values passed to child packages.')
,(400,'NonDiagnostic')
,(80,'VariableValueChanged')
go create table helper.MessageSourceType
(
message_source_type int not null,
message_source_descr varchar(256)
)
go insert into helper.MessageSourceType
(
message_source_type,
message_source_descr
)
values
(10,'Entry APIs, such as T-SQL and CLR Stored procedures')
,(20,'External process used to run package (ISServerExec.exe)')
,(30,'Package-level objects')
,(40,'Control Flow tasks')
,(50,'Control Flow containers')
,(60,'Data Flow task')
go create table helper.OperationStatus
(
operation_status int not null,
operation_status_descr varchar(256) not null
)
go insert into helper.OperationStatus
(
operation_status,
operation_status_descr
)
values
(1,'created')
,(2,'running')
,(3,'canceled')
,(4,'failed')
,(5,'pending')
,(6,'ended unexpectedly')
,(7,'succeeded')
,(8,'stopping')
,(9,'completed')
go create table helper.ObjectType
(
object_type int not null,
object_type_descr varchar(256) not null
)
go insert into helper.ObjectType
(
object_type,
object_type_descr
)
values
(10,'folder')
,(20,'project')
,(30,'package')
,(40,'environment')
,(50,'instance of execution')
go create table helper.ContextType
(
context_type int not null,
context_type_name varchar(256) not null,
context_type_descr varchar(256) not null,
)
go insert into helper.ContextType
(
context_type,
context_type_name,
context_type_descr
)
values
(10,'Task','State of a task when an error occurred.')
,(20,'Pipeline','Error from a pipeline component: source, destination, or transformation component.')
,(30,'Sequence','State of a sequence.')
,(40,'For Loop','State of a For Loop')
,(50,'Foreach Loop','State of a Foreach Loop')
,(60,'Package','State of the package when an error occurred.')
,(70,'Variable','Variable value')
,(80,'Connection Manage','Properties of a connection manager.')
go create table helper.ExecutionResult
(
execution_result int not null,
execution_result_descr varchar(256) not null
)
go insert into helper.ExecutionResult
(
execution_result,
execution_result_descr
)
values
(0,'Success')
,(1,'Failure')
,(2,'Completion')
,(3,'Cancelled')
go

1,查询操作实例

按照操作实例开始的时间倒序查询操作实例,对于系统创建的自动清理的操作实例,其object_type 是NULL

select top 11
o.operation_id,
opt.operation_type_descr ,
o.created_time,
o.object_id,
obt.object_type_descr,
o.object_name,
ops.operation_status_descr,
o.start_time,
o.end_time
from catalog.operations o
inner join helper.OperationType opt
on o.operation_type=opt.operation_type
inner join helper.OperationStatus ops
on o.status=ops.operation_status
left join helper.ObjectType obt
on o.object_type=obt.object_type
order by o.start_time desc

返回的操作实例的信息,字段operation_status_descr是操作实例的状态,running表示正在执行,succeeded表示执行成功,failed表示执行失败等。

2,查看指定操作实例的消息

根据字段message_type,能够查询特定类型的消息,例如, 120表示错误消息(Error);消息源是指产生消息的源头,最常见的消息源是:控制流任务(Control Flow Task,类型是40),控制流容器(Control Flow Container,类型是50),数据流组件(Data Flow Task,类型是60),通过查看操作实例的消息,能够监控到Package运行过程中的状态。

select om.operation_message_id,
om.message_time,
mt.message_type_descr,
om.message_source_type,
mst.message_source_descr,
om.message
from catalog.operation_messages om
inner join helper.MessageType mt
on om.message_type=mt.message_type
inner join helper.MessageSourceType mst
on om.message_source_type=mst.message_source_type
where om.operation_id=23537
  -- and mt.message_type=120 --error message
order by om.message_time desc

3,查看操作实例的Event Message

Event Message是关于Message的信息,可以认为和Message是一一对应的。

select em.event_message_id,
em.package_name,
em.package_path,
em.subcomponent_name,
em.event_name,
mt.message_type_descr,
mst.message_source_descr,
--em.message_source_id,
em.message_source_name,
em.message,
cast(em.message_time as DATETIME) as message_time,
em.execution_path
from catalog.event_messages em with(nolock)
inner join helper.MessageType mt
on em.message_type=mt.message_type
inner join helper.MessageSourceType mst
on em.message_source_type=mst.message_source_type
where em.operation_id=23537
order by em.message_time desc

4,查看指定Event Message的Context

Event Message的上下文(Context)是指Package的组件(Task、Pipeline、Sequence、For Loop、Foreach Loop、Package、Variable、Connection Manage)等在事件发生时,它们的属性值是什么,事件消息的上下文主要用于故障排除。当错误事件发生时,可以查看变量(Variable)的值,便于快速查找到Package的出错原因。

select emc.context_id,
emc.context_depth,
emc.package_path,
ct.context_type_name,
ct.context_type_descr,
emc.context_source_name,
--emc.context_source_id,
emc.property_name,
emc.property_value
from catalog.event_message_context emc with(nolock)
inner join helper.ContextType ct
on emc.context_type=ct.context_type
where emc.event_message_id=6713840
order by emc.context_type

5,用于故障排除的脚本

select
opt.operation_type_descr as Operation,
obt.object_type_descr as object_type,
o.object_name,
ops.operation_status_descr as OperationStatus,
mt.message_type_descr as message_type,
mst.message_source_descr,
om.message,
om.message_time
from catalog.operations o
inner join helper.OperationType opt
on o.operation_type=opt.operation_type
inner join helper.ObjectType obt
on o.object_type=obt.object_type
inner join helper.OperationStatus ops
on o.status=ops.operation_status
inner join catalog.operation_messages om
on o.operation_id=om.operation_id
inner join helper.MessageType mt
on om.message_type=mt.message_type
inner join helper.MessageSourceType mst
on om.message_source_type=mst.message_source_type
where o.operation_id =104627
and om.message_type in
(
120,--Error
110,--Warning
130--TaskFailed
)
order by om.message_time desc select
opt.operation_type_descr as Operation,
obt.object_type_descr as object_type,
o.object_name,
ops.operation_status_descr as OperationStatus,
em.event_message_id,
em.package_name,
em.event_name,
em.message_source_name,
em.subcomponent_name,
mt.message_type_descr as message_type,
mst.message_source_descr as message_source_type,
em.package_path,
em.event_message_id,
em.message_time,
em.message
from catalog.operations o
inner join helper.OperationType opt
on o.operation_type=opt.operation_type
inner join helper.OperationStatus ops
on o.status=ops.operation_status
inner join helper.ObjectType obt
on o.object_type=obt.object_type
inner join catalog.event_messages em
on o.operation_id=em.operation_id
inner join helper.MessageType mt
on em.message_type=mt.message_type
inner join helper.MessageSourceType mst
on em.message_source_type=mst.message_source_type
where o.operation_id =104627
and em.message_type in
(
120, --Error
110, --Warning
130 --TaskFailed;
)
--and em.package_name=N'PackageName.dtsx'
order by em.message_time desc select emc.context_depth,
emc.package_path,
ct.context_type_name as context_type,
emc.context_source_name,
emc.property_name,
emc.property_value
from catalog.event_message_context emc
inner join helper.ContextType ct
on emc.context_type=ct.context_type
where emc.event_message_id=23929777
and emc.context_type=70

附:创建SSISDB Catalog的辅助表

use SSISDB
go create schema helper
go create table helper.OperationType
(
operation_type int not null,
operation_type_descr varchar(256) not null,
invoker varchar(256) not null
)
go insert into helper.OperationType
(
operation_type,
operation_type_descr,
invoker
)
values
(1, 'Integration Services initialization','')
,(2, 'Retention window','SQL Agent job')
,(3, 'MaxProjectVersion','SQL Agent job')
,(101, 'deploy_project','Stored procedure')
,(106, 'restore_project','Stored procedure')
,(200, 'create_execution and start_execution','Stored procedures')
,(202, 'stop_operation','Stored procedure')
,(300, 'validate_project','Stored procedure')
,(301, 'validate_package','Stored procedure')
,(1000, 'configure_catalog','Stored procedure')
go create table helper.MessageType
(
message_type int not null,
message_type_descr varchar(256) not null
)
go insert into helper.MessageType
(
message_type,
message_type_descr
)
values
(-1,'Unknown')
,(120,'Error')
,(110,'Warning')
,(70,'Information')
,(10,'Pre-validate')
,(20,'Post-validate')
,(30,'Pre-execute')
,(40,'Post-execute')
,(60,'Progress')
,(50,'StatusChange')
,(100,'QueryCancel')
,(130,'TaskFailed')
,(90,'Diagnostic')
,(200,'Custom')
,(140,'DiagnosticEx, Whenever an Execute Package task executes a child package, it logs this event. The event message consists of the parameter values passed to child packages.')
,(400,'NonDiagnostic')
,(80,'VariableValueChanged')
go create table helper.MessageSourceType
(
message_source_type int not null,
message_source_descr varchar(256)
)
go insert into helper.MessageSourceType
(
message_source_type,
message_source_descr
)
values
(10,'Entry APIs, such as T-SQL and CLR Stored procedures')
,(20,'External process used to run package (ISServerExec.exe)')
,(30,'Package-level objects')
,(40,'Control Flow tasks')
,(50,'Control Flow containers')
,(60,'Data Flow task')
go create table helper.OperationStatus
(
operation_status int not null,
operation_status_descr varchar(256) not null
)
go insert into helper.OperationStatus
(
operation_status,
operation_status_descr
)
values
(1,'created')
,(2,'running')
,(3,'canceled')
,(4,'failed')
,(5,'pending')
,(6,'ended unexpectedly')
,(7,'succeeded')
,(8,'stopping')
,(9,'completed')
go create table helper.ObjectType
(
object_type int not null,
object_type_descr varchar(256) not null
)
go insert into helper.ObjectType
(
object_type,
object_type_descr
)
values
(10,'folder')
,(20,'project')
,(30,'package')
,(40,'environment')
,(50,'instance of execution')
go create table helper.ContextType
(
context_type int not null,
context_type_name varchar(256) not null,
context_type_descr varchar(256) not null,
)
go insert into helper.ContextType
(
context_type,
context_type_name,
context_type_descr
)
values
(10,'Task','State of a task when an error occurred.')
,(20,'Pipeline','Error from a pipeline component: source, destination, or transformation component.')
,(30,'Sequence','State of a sequence.')
,(40,'For Loop','State of a For Loop')
,(50,'Foreach Loop','State of a Foreach Loop')
,(60,'Package','State of the package when an error occurred.')
,(70,'Variable','Variable value')
,(80,'Connection Manage','Properties of a connection manager.')
go create table helper.ExecutionResult
(
execution_result int not null,
execution_result_descr varchar(256) not null
)
go insert into helper.ExecutionResult
(
execution_result,
execution_result_descr
)
values
(0,'Success')
,(1,'Failure')
,(2,'Completion')
,(3,'Cancelled')
go

参考文档:

catalog.operations (SSISDB Database)

catalog.catalog_properties (SSISDB Database)

SSIS Catalog: Part 6 - Operations

SSISDB2:SSIS工程的操作实例的更多相关文章

  1. CentOS 配置防火墙操作实例(启、停、开、闭端口):

    CentOS 配置防火墙操作实例(启.停.开.闭端口): 注:防火墙的基本操作命令: 查询防火墙状态: [root@localhost ~]# service   iptables status< ...

  2. python操作mysql数据库的相关操作实例

    python操作mysql数据库的相关操作实例 # -*- coding: utf-8 -*- #python operate mysql database import MySQLdb #数据库名称 ...

  3. 安卓 SQLite数据库操作实例

    前段时间写了个安卓平台下SQLite数据库操作的实例 ,一直没得时间总结 ,今天把它弄出来了. 在Android 运行时环境包含了完整的 SQLite. 首先介绍一下SQLite这个数据库: SQLi ...

  4. 在安卓开发中使用SQLite数据库操作实例

    前段时间写了个安卓平台下SQLite数据库操作的实例 ,一直没得时间总结 ,今天把它弄出来了. 在Android 运行时环境包含了完整的 SQLite. 首先介绍一下SQLite这个数据库: SQLi ...

  5. Sql Server 函数的操作实例!(执行多条语句,返回Select查询后的临时表)

    Sql Server 函数的操作实例!(执行多条语句,返回Select查询后的临时表) SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ==== ...

  6. CentOS 配置防火墙操作实例(启、停、开、闭端口)CentOS Linux-FTP/对外开放端口(接口)TomCat相关

    链接地址:http://blog.csdn.net/jemlee2002/article/details/7042991 CentOS 配置防火墙操作实例(启.停.开.闭端口): 注:防火墙的基本操作 ...

  7. Sql Server 函数的操作实例!(返回一条Select语句查询后的临时表)

    Sql Server 函数的操作实例!(返回一条Select语句查询后的临时表) SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE FUN ...

  8. FTP命令具体解释(含操作实例)

    以下是微软命令行FTPclient命令大全.假设你想使用"未加工(RAW)"FTP命令而非以下翻译过的请參考:http://www.nsftools.com/tips/RawFTP ...

  9. CentOS配置防火墙操作实例

    CentOS 配置防火墙操作实例(启.停.开.闭端口): 注:防火墙的基本操作命令: 查询防火墙状态: [root@localhost ~]# service iptables status<回 ...

随机推荐

  1. 利用Django实现RESTful API(一)

    RESTful API现在很流行,这里是它的介绍 理解RESTful架构和 RESTful API设计指南.按照Django的常规方法当然也可以实现REST,但有一种更快捷.强大的方法,那就是 Dja ...

  2. C++用法总结

    1.C++的绝对值符号 如果是整形的,就是abs() 如果是浮点型的,是fabs() 这两个函数都从属于库函数math.h #include <cmath> or #include< ...

  3. ZT 类模板Stack的实现 by vector

    *//*第3章 类模板 与函数相似,类也可以被一种或多种类型参数化.容器类就是一个具有这种特性的典型例子,它通常被用于管理某种特定类型的元素.只要使用类模板,你就可以实现容器类,而不需要确定容器中元素 ...

  4. ascii2native 转码 解码

    //把十六进制的编码转为原码function asciiHex2native(strAscii) { var output = ""; var posFrom = 0; var p ...

  5. swift的异常处理:本质是错误信息的传递方式

    func response(from resultObject: Any) throws -> Response { guard let dict = resultObject as? [Str ...

  6. AOP的本质

    AOP的本质是HOOK: HOOK的本质是:新函数包含原函数或新函数替换原函数: 需要解决的问题: 1.新函数的生成: 2.新函数的调用机制: 3.原函数的调用机制: 新函数的生成: 1.将已有的动态 ...

  7. 【洛谷】【线段树】P1471 方差

    [题目背景:] 滚粗了的HansBug在收拾旧数学书,然而他发现了什么奇妙的东西. [题目描述:] 蒟蒻HansBug在一本数学书里面发现了一个神奇的数列,包含N个实数.他想算算这个数列的平均数和方差 ...

  8. 随手练——Uva-11584 划分成回文串(区间DP)

    思路:dp[i]代表到第i位的最小值,枚举它的前几位,求出最小值. 转移方程:dp[ i ] = min(dp[ i ], dp[ j - 1 ] + 1 ) ; 本来觉得,代码加深部分可以提前bre ...

  9. Python自动化之跨域访问jsonp

    这里提到了JSONP,那有人就问了,它同JSON有什么区别不同和区别呢,接下我们就来看看,百度百科有以下说明: ''' 1. JSON(JavaScript Object Notation) 是一种轻 ...

  10. 集合之保持compareTo和equals同步

    在Java中我们常使用Comparable接口来实现排序,其中compareTo是实现该接口方法.我们知道compareTo返回0表示两个对象相等,返回正数表示大于,返回负数表示小于.同时我们也知道e ...