ASE MDA 常见问与答
自 12.5.0.3 开始,ASE 引入了新的监控机制/工具,那就是 MDA 表(Monitoring and Diagnostic Access)。这些表是位于 master 库中的代理表,通常以 mon 打头,所以有时也称之为 mon 表,它们提供了访问 ASE 底层监视信息的方法。可以通过简单的 SQL 语句访问这些监控数据。
1. 安装初始配置:
-- 第一步,确保参数 'enable cis' 已设置为1(如果没有,则需要在设置后重新启动 ASE)
sp_configure 'enable cis', 1
go
-- 添加 'loopback' 别名 (假设 @@servername 在接口文件中已有定义,或直接用实际服务名作相应替换)
use master
go
sp_addserver loopback, null, @@servername
go
-- 测试配置
set cis_rpc_handling on
go
exec loopback...sp_who -- 注意:是三个点
go
-- 分配 'mon_role' 权限
use master
go
grant role mon_role to sa
go
2. 安装 mon 表:
在 ASE 安装目录的 scripts 目录中,有一个名为 installmontables 的脚本文件,使用 isql 执行该脚本即可安装 MDA 表。
isql -Usa -S
your_server -iinstallmontables
3. 测试及参数配置:
安装完后,需要做相应配置,方可开启监控功能,配置脚本如下:
-- 测试,注意为了激活 'mon_role',需要断开后重连。
select * from master..monState
go
-- 配置,参数根据实际需要自行调整
sp_configure "enable monitoring", 1
go
sp_configure "sql text pipe active", 1
go
sp_configure "sql text pipe max messages", 100
go
sp_configure "plan text pipe active", 1
go
sp_configure "plan text pipe max messages", 100
go
sp_configure "statement pipe active", 1
go
sp_configure "statement pipe max messages", 100
go
sp_configure "errorlog pipe active", 1
go
sp_configure "errorlog pipe max messages", 100
go
sp_configure "deadlock pipe active", 1
go
sp_configure "deadlock pipe max messages", 100
go
sp_configure "wait event timing", 1
go
sp_configure "process wait events", 1
go
sp_configure "object lockwait timing", 1
go
sp_configure "SQL batch capture", 1
go
sp_configure "statement statistics active", 1
go
sp_configure "per object statistics active", 1
go
-- 静态参数,需要重新启动 ASE,实际值通常较 2048 大
sp_configure "max SQL text monitored", 2048
go
正如 MDA 表的名称所确定的,它们就是一些 on the fly 的表而已,因此用简单的SQL 就可以访问它们了。当然,也有一些现成的商业软件,以良好的 GUI 来展现这些数据,如 DBXay,SpotLight 等。不过就个人使用的体会而言,还是直接用 SQL 来得方便。
select distinct P.CacheName, sum(P.AllocatedKB)/1024 as AllocatedMB,
(select sum(O.CachedKB)/1024 from monCachedObject O where O.CacheName=P.CacheName ) as CachedMB
from monCachePool P
group by P.CacheName
注意:此脚本不能统计同一 Cache 中不同 I/O size 的情况。
MDA Tables in ASE—Tips and Tricks
--
FlybeanZhou - 30 May 2006