Home > Database > Mysql Tutorial > body text

使用Procwatcher监控Oracle数据库锁定Contention

WBOY
Release: 2016-06-07 16:49:02
Original
1275 people have browsed it

数据库锁定Contention是我们在实际中经常遇到的问题。严重的Contention可能会引起整体数据库性能衰减,乃至连接失败。实际生产如

数据库锁定Contention是我们在实际中经常遇到的问题。严重的Contention可能会引起整体数据库性能衰减,乃至连接失败。实际生产如果出现Contention,通常是比较紧急的情况,快速定位错误问题,解决问题是运维人员的挑战。
 
Contention出现的原因很多,但总的来说有两个大的类型,一个是数据库本身后台进程之间协调故障,另一个是应用程序或者用户操作导致的等待锁定。前者通常是由于Oracle Bug引起的,后者是由于不成熟的设计开发引起的。
 
Contention锁定通常是进程之间的关系,所以解决问题的通法常常是利用oradebug和操作系统本身携带的Trace监控工具。对初学者而言,在紧急情况下使用这些工具常常是比较困难的。所以,Oracle推出了Procwatcher工具脚本,来进行统一的锁定分析工作。
 
Procwatcher可以从MOS官方网站进行下载,对应的文档ID为:459694.1。本篇主要介绍Procwatcher工具安装和使用。

--------------------------------------分割线 --------------------------------------

 CentOS 5.2 x86 安装Oracle 11g R2 笔记

在CentOS 6.4下安装Oracle 11gR2(x64)

Oracle 11gR2 在VMWare虚拟机中安装步骤

--------------------------------------分割线 --------------------------------------

1、环境介绍

 

我们使用的操作系统环境是Red Hat Linux 6.5。

 

[root@SimpleLinux /]# uname -r

2.6.32-431.el6.i686

 

2、Procwatcher安装配置

 

从MOS上下载的脚本是一个zip包,笔者版本为:prw_12.1.13.11.1.zip。在Linux中,创建专门目录进行上传。

 

[root@SimpleLinux ~]# cd /

[root@SimpleLinux /]# mkdir prw

[root@SimpleLinux /]# chown oracle:oinstall prw

[root@SimpleLinux /]# ls -l | grep prw

drwxr-xr-x.  2 oracle oinstall  4096 Apr 30 09:12 prw

 

使用sftp客户端上传zip包。

 

[root@SimpleLinux prw]# ls -l

total 36

-rw-r--r--. 1 root root 36203 Apr 30 09:16 prw_12.1.13.11.1.zip

[root@SimpleLinux prw]# unzip prw_12.1.13.11.1.zip

Archive:  prw_12.1.13.11.1.zip

  inflating: prw.sh                 

[root@SimpleLinux prw]# ls -l

total 220

-rw-r--r--. 1 root root  36203 Apr 30 09:16 prw_12.1.13.11.1.zip

-rwxr-xr-x. 1 root root 187245 Nov 26 23:12 prw.sh

[root@SimpleLinux prw]# chown oracle:oinstall *

[root@SimpleLinux prw]# ls -l

total 220

-rw-r--r--. 1 oracle oinstall  36203 Apr 30 09:16 prw_12.1.13.11.1.zip

-rwxr-xr-x. 1 oracle oinstall 187245 Nov 26 23:12 prw.sh

 

prw.sh就是工具的唯一实体,,可以执行脚本来进行操作。

使用Procwatcher是需要操作系统环境检查,首先要求执行用户PATH中包括/usr/bin和/bin目录。

 

 

[oracle@SimpleLinux ~]$ env | grep PATH

PATH=/usr/lib/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/bin:/u01/app/oracle/bin
 
MODULEPATH=/usr/share/Modules/modulefiles:/etc/modulefiles

 

环境变量中包括标准的$ORACLE_系列。

 

[oracle@SimpleLinux ~]$ env | grep ORA

ORACLE_SID=ora11g

ORACLE_BASE=/u01/app

ORACLE_HOME=/u01/app/oracle

 

执行用户要求是Oracle owner用户。如果是cluster(RAC)或者多个oracle user的情况,可以使用root来执行。

操作系统中必须包括系统调试工具。列表如下:

 

Linux - /usr/bin/gdb

HP-UX and HP Itanium - /opt/langtools/bin/gdb64 or /usr/ccs/bin/gdb64

Sun - /usr/bin/pstack

IBM AIX - /bin/procstack or /bin/dbx

HP Tru64 - /bin/ladebug

 

 

[oracle@SimpleLinux ~]$ rpm -qa | grep gdb

gdb-7.2-60.el6_4.1.i686

gdbm-1.8.0-36.el6.i686

eggdbus-0.6-3.el6.i686

gdbm-devel-1.8.0-36.el6.i686

 

执行脚本prw.sh,可以自动的进行进程级别的数据收集。可以调用参数help来进行帮助信息。

 

[oracle@SimpleLinux prw]$ ./prw.sh help

 

Usage:  prw.sh

Verbs are:

 

start [all] - Start Procwatcher on local node, if 'all' is specified, start on all nodes
 
stop [all] - Stop Procwatcher on local node, if 'all' is specified, stop on all nodes
 
stat - Check the current status of Procwatcher

pack - Package up Procwatcher files (on all nodes) to upload to support

param - Check current Procwatcher parameters

log [number] - See the last [number] lines of the procwatcher log file

log [runtime] - See contiuous procwatcher log file info - use Cntrl-C to break

help - What you are looking at...

 

参数调用是比较简单的,通过帮助信息可以了解使用的方法。相对于oradebug和操作系统层面的调用,易用性要好得多。使用stat参数,可以来查看脚本当前运行情况。
 
 

[oracle@SimpleLinux prw]$ ./prw.sh stat

Wed Apr 30 09:25:46 CST 2014: PROCWATCHER VERSION: 12.1.13.11.1

Wed Apr 30 09:25:46 CST 2014: ### Parameters ###

Wed Apr 30 09:25:46 CST 2014: EXAMINE_CLUSTER=false

Wed Apr 30 09:25:46 CST 2014: EXAMINE_BG=true

Wed Apr 30 09:25:46 CST 2014: PRWPERM=777

Wed Apr 30 09:25:46 CST 2014: RETENTION=7

Wed Apr 30 09:25:46 CST 2014: WARNINGEMAIL=

Wed Apr 30 09:25:46 CST 2014: INTERVAL=60

Wed Apr 30 09:25:46 CST 2014: THROTTLE=5

Wed Apr 30 09:25:46 CST 2014: IDLECPU=3

Wed Apr 30 09:25:46 CST 2014: SIDLIST=

Wed Apr 30 09:25:46 CST 2014: ### Advanced Parameters (non-default) ###

Wed Apr 30 09:25:46 CST 2014: ### End Parameters ###

 

Wed Apr 30 09:25:46 CST 2014: Procwatcher is not running on local node SimpleLinux
 
Wed Apr 30 09:25:46 CST 2014: Procwatcher files are be written to: /prw

更多详情见请继续阅读下一页的精彩内容:

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!