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

数据库锁定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

Statement
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
How do you handle database upgrades in MySQL?How do you handle database upgrades in MySQL?Apr 30, 2025 am 12:28 AM

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

What are the different backup strategies you can use for MySQL?What are the different backup strategies you can use for MySQL?Apr 30, 2025 am 12:28 AM

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

What is MySQL clustering?What is MySQL clustering?Apr 30, 2025 am 12:28 AM

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

How do you optimize database schema design for performance in MySQL?How do you optimize database schema design for performance in MySQL?Apr 30, 2025 am 12:27 AM

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

How can you optimize MySQL performance?How can you optimize MySQL performance?Apr 30, 2025 am 12:26 AM

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi

How to use MySQL functions for data processing and calculationHow to use MySQL functions for data processing and calculationApr 29, 2025 pm 04:21 PM

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

An efficient way to batch insert data in MySQLAn efficient way to batch insert data in MySQLApr 29, 2025 pm 04:18 PM

Efficient methods for batch inserting data in MySQL include: 1. Using INSERTINTO...VALUES syntax, 2. Using LOADDATAINFILE command, 3. Using transaction processing, 4. Adjust batch size, 5. Disable indexing, 6. Using INSERTIGNORE or INSERT...ONDUPLICATEKEYUPDATE, these methods can significantly improve database operation efficiency.

Steps to add and delete fields to MySQL tablesSteps to add and delete fields to MySQL tablesApr 29, 2025 pm 04:15 PM

In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools