如何监控Oracle数据库中长时间运行的进程

如何监控Oracle数据库中长时间运行的进程,第1张

监控Oracle 数据库中长时间运行进程的两种方式,通过这些方 法,我们可以监控单条语句的 长时间 *** 作,监控存储过程的运行进度,甚至自己'生成'进度信息. 关键词:监控进度V$SESSION_LONGOPS 当Oracle 存储过程运行时间较长时,我们希望客 户端能了解到它在后台执行的状况或者进度信息(类 似WINDOWS 安装软件时的进度条信息),这样可以知 道运行在后台的应用进程是否终止或者休眠,更近一 步要求,最好能知道进行到哪一步骤,还有多少时间才 能完成. 简单到一条SQL 语句的情况,如果执行时间较长, 我们如何得到它的运行状况?是否后台还在运行?虽 然可以查看SQL 的执行计划了解它的执行步骤,但如 何知道它运行到哪一个步骤了呢?如何才能估计出它 的合理的较为精确的执行时间呢? Oracle 数据库前端发出执行命令后,进程在后台 执行,普通开发人员一般无法了解到后台在做什么,一 般采用的方法是用DBMSOUTPUT.PUT_LINE 来打印出 来,但DBMS—OUTPUT.PUT—LINE 打印的信息受缓冲区 大小限制,如果信息较多就容易溢出,而且如果存储过 程执行时间较长,只有在其执行完后,这些信息才会打 印出来,这就增加了调试周期,影响了调试效果.有的 开发人员在存储过程中通过写日志表的形式来记录进 度,但需要COMMIT 后其他进程才能看到这些日志信 息,而在某些控制结构中(如游标CURSOR 循环)COM— MIT,则很容易引起ORA 一01555 错误,造成程序出错. 下面介绍两种监控方法. 如何监控单条长语句从ORACLE8 开始,出现一个新的动态视图:V $SESSION_LONGOPS,从这个视图可以获知一些 *** 作 (如全表扫描,并行查询,RMAN,排序等)的执行进度, 我们先来了解一下V$SESSION—LONGOPS 视图的一些 重要字段: 列说明 sID 会话标识 5ERIAL#会话序列号 OPfE *** 作的简短描述 TARG 盯 *** 作的对象,如xx TAR~_DESC目标描述 SOFAR 目前已执行单位数目 ToTAIWORK 总单位数目 UNlTS 单位 START_TIME 开始执行时间 LAST_ UPDATE_TIME 统计数据最后更新时间 TIME_ REMAINING 估计剩余时间c ELAPSED_SECONDS 已执行时间(秒) MEsSAGE 统计数据汇总信息 USERA^^E 用户名 ~L_ADDRES5 语句的地址,,用于和V$sql_text 等关联 语句的hash 地址,用于和V$sql_texlSQLHASH VALUE等关联 这个动态视图显示各个运行时间超过6 程.这些进程包含许多备份和恢复功能,统计数据收集,查询等. 执行以下语句就可以得到数据库中各个长时间 *** 作的进程信息: select'Icfromv$sesslon_ longopswheretime_ re- malnlng>0 我们也可以用图形化工具查看,如TOAD,OEM中 均可查看长 *** 作进程进度信息. Oracle 自带的管理工具OracleEnterpriseManager (OEM)提供了图形化查看长 *** 作的功能,如: 计算机系统应用2007 Quest公司的数据库管理工具TOAD 也可以看到 长 *** 作信息,如: 表的统计信息. 长时问运行的SQL 语句可以用V$SESSION—LON? 为了能监控到查询进程执行的进度,必需使用 CBO 优化器并且: 设置TlMED—STATISTICS或者SQL—TRACE 用ANALYZE语句或者DBMS—STAT 包收集相关 108 实践经验P 帕cficalExpen GOPS来监控.实际上,长时间运行的存储过程也可以 监控.那是否任何 *** 作都可以通过这个视图来监控进 度呢?很遗憾,V$SESSION—LONGOPS 只会报告它认为 耗时长的 *** 作.对于NEsTEDLOOP/UNIQUEINDEX READS/INDEXRANGEScANS 等执行速度很快的 *** 作, 2007 期计算机系统应用由于它们执行一般不超过6 秒,因此将不会出现在V $SESSION—LONGOPS 如何监控自定义存储过程单条长语句可以用上面的方法监控,Oracle 动生成V$SE.SSION— LONGOPS 记录.那么存储过程中 有许多小 *** 作,如何监控进度呢?其实,我们也可以手 工生成V$SESSION—LONGOPS 记录,方法是调用DBMS APPLICATION—INFO 包来生成自定义进度信息. 从Oracle7.2 开始,提供了DBMS—APPLICATION— INFo 包,通过调用这个包,应用可以将自己的名字和 动作填写到V$SESSION 和V$SQLAREA 的MODULE ACTION列中.V$SESSION 列出每个会话的用户名, *** 作系统机器名,终端名,程序名等. 应用可以在执行模块时设置模块名和动作名,模 块名一般是甩户自定义的.而动作名一般描述模块中 的当前执行的事务的名字. DBMSAPPLICATION_INFO 包包含以下过程 SET_ MODULE 设置当前运行程序的模块名 SET__AEl'ION 设置当前模块的当前动作名 SESSION—LON-在V$SESSIONLONGOPS视图中 GoPS 插入一行进度信息 SETMODULE过程设置模块名和动作名: createorreplaceproceduredel—cust(v_cust—Id varchar2) begindbms—— application—— info.set— module(module—— name=>"delcust". actlon_name=>"deletetablecust)i deletefromcustwherecustld=v_ cusLIddbms_appllcatlon— Info.seLmodule(,)end以上设置的模块名和动作名可以通过查询V $sqlarea 获取. 如:selectsql—text,module,actionfromv $sqlareawheremodule="del_cust: sql_textmoduleadion Deletefr0mcustdel_ custdeletetableoust 1rowselected. SET_SESSION—LONGOPS 过程用于在V$session— longops 中插入一行,开发人员可以调用此过程设置长 时间 *** 作的状态信息,这样,任何其他其他会话都可以 看到这个进度信息.如下例所示: declare nohlntnumberdefaultdbmsapplicatlon_info.set_ session— Iongops_ nohintIdndexnumberdefaultInohlnt: slnonumberbegin forlIn1..8888888888 loop update....dbms_ appllcaflon— Info.setsesslon_ longops (rlndex=>l_rlndex, slno=>I_slno. op_name=>"updateahugetable. target=>126, target_desc=>'.msgdescription context=>0.sOfar=>j. totalwork=>8888888888. units=>loops endloopend然后,从另一个会话来执行以下语句selectfromv$sesslon_ longopswheretlmere? malnlng>0也可以用图形化工具TOAD 或OEM来查看. 因此,采用本文说明的方法,Oracle 开发人员可以 比较方便的监控长 *** 作进程的进度信息,也可以自己 设置监控信息,来了解后台存储过程的运行效率.甚 至,可以在存储过程或SQL 语句提交执行后马上观察 其执行进度,如果比较缓慢,则可以中断其执行,进行 调优,从而缩短调试周期,提高开发效率.

2010 could soon be over, I am very happy in this year met many new colleague and working with people,

Don't get along very happy right and work ability has been improved a lot.

Reviewing the past year, I mainly made the following job:

1, database daily monitoring and maintenance

Real-time to local factories and CIC, OPEN database operation monitoring, such as db lock, CPU and with usage, pro to etc

Regular use of tablespaces, database backup state monitor.

2, database emergencies and emergency treatment

Report to the database abnormal error op.9 timely processing, such as db shutdown, alter log ora - error, and watch space super threshold, filing and backup failures

3, database optimized

For each business performance problems database optimized, through monitoring find running slowly SQL adjustment.

Based on the optimization LNTDERN1_LNTPROD database, make its CPU usage a marked decline, as Poland project on-line to make the preparation.

And the LGESYMDBSY1M_CHMES, LGENT_NTMES, LNT - such as database SQL optimization XM, some business module performance was obviously ascension.

4, database and backup and restore

Due to business needs, such as changing the new server, deploy development environment, completion of the production environment data backup recovery,

For part of factory database backup strategies do adjustment. If LGENT_GSPISND, LGEHN_MES, LGECHMWDDBJ0Q_EZPTEST etc

5, finish new database creation and patch upgrade

Due to business needs, establish and deployed some new database, such as cnmas, CHNATMT

And members of the team finished CIC all database dblink patch upgrades, and some other security patch of upgrades

6 and domestic business projects and manpower support

(1). LGD database deployment project completion of guangzhou

(2). FANHAN database optimization of the project finished in tianjin

(3). MKL daily on fuzhou database monitoring and maintenance

7, participate in the database migration and integration

And members of the team finished to LGECHMDBBJ1Q server database integration and migration

8 for KEB RAC environment, database of monitoring and maintenance

9, new technology and skills upgrading of learning

Through their study, to AIX, UNIX, LINUX system, SOLARIS have more in-depth knowledge and understanding of the oracle 10g \ 11g strengthened the study

Next year's working plan and expectation:

1, earnestly databases daily monitoring and maintenance work.

2, database to dealing with emergency do more timely and accurate.

3, earnestly each business unit database support work.

4, on the database of high availability and new technologies have further study, in order to adapt to the development of the company.

Personal assessment and summary:

Overall this year's work done smoothly, as a member of the team DBA serious and responsible, can complete team leaders and long the task,

Timely and accurate processing various database abnormal problems, protect the system stability for the mistakes, loss to its lowest point. Can strictly follow the rules of the company, it makes the master consciousness.

In the year, I feel my ability of technical standards have increased, so I hope that in the New Year with adjustment of wages can ascend, to reflect more my worth.

Finally I wish companies and our department and the team of everyone in New Year have good development.

Thank you!


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/9531075.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-29
下一篇2023-04-29

发表评论

登录后才能评论

评论列表(0条)

    保存