ORACLE利器之OSWatch监控操作系统性能和RAC心跳

本文介绍了Oracle官方提供的OSWatch工具,该工具无需安装,支持多种操作系统,并集成了基础命令用于监控系统性能。文中详细展示了如何使用OSWatch进行系统监控,包括启动、关闭命令及配置过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

OSWatch介绍

    今天简单介绍一下ORACLE官方提供的利器OSWatch,它是个:无须安装、支持主流的操作系统(AIX,LINUX,Solaris,HP-UX,WINDOWS)、集成了一些操作系统的基础命令,如topas,traceroute,vmstat,iostat等来监控操作系统的性能。虽然会有一些资源消耗,可别小看这些事故现场的数据信息,因为我们可以依靠这些性能数据还原故障发生前操作系统的资源负载情况和心跳通信情况。另外OSWatch还可以通过自身的java(要求java版本是1.4.2以上)工具生成图形更直观地反应“心电图”。

 

 The OSWatcher Analyzer (oswbba) is a graphing and analysis    utility which comes bundled withOSWatcher v4.0 and higher.  oswbba allows the user to graphically display data collected, generate reports containing these graphs and provides a built in analyzer to analyze the data and provide details on any performance problems it detects. The ability to graph and analyze this information relieves the user of manually inspecting all the files.

 

OSWatch的简单使用

[数据库环境:/oracle/oswatch] ls -lrt
total 2640
-rw-r--r--    1 oracle   oinstall    1341440 Jun 04 11:29 oswbb601.tar            <<<<---从官方下载的压缩包
drwxr-xr-x   10 oracle   oinstall       4096 Sep 17 09:03 oswbb                      <<<<---解压以后生成的目录

[数据库环境:/oracle/oswatch/oswbb] ls -lrt st*.sh             
-rwxr-xr-x    1 oracle   oinstall        542 Oct 11 2012  stopOSWbb.sh             <<<--关闭脚本
-rwxr-xr-x    1 oracle   oinstall       2385 Jan 09 2013  startOSWbb.sh           <<<--启动脚本

 

启动命令:

[数据库环境:/oracle/oswatch/oswbb] nohup sh *start*.sh 15 168 &

--------------------------

nohup command &   将命令放至后台执行

sh *start*.sh         执行startOSWbb.sh脚本

15                        每15秒为间隔收集一次系统信息(topas,vmstat,traceroute等)

168                      保留Nums的小时数据,这些数据是可以复用的,类似于UNDO,redo

--------------------------

[数据库环境:/oracle/oswatch/oswbb] ps -ef  | grep osw         
  oracle 50921778 49676404   0 09:20:49      -  0:04 /bin/sh ./OSWatcherFM.sh 168 /oracle/oswatch/oswbb/archive             <<<<进程信息,另archive就是信息存放的目录
  oracle 51708332 65339518   0 23:47:40  pts/0  0:00 grep osw

[数据库环境:/oracle/oswatch/oswbb/archive] ls -lrt
total 112
drwxr-xr-x    2 oracle   oinstall       8192 Sep 17 23:00 oswvmstat
drwxr-xr-x    2 oracle   oinstall       8192 Sep 17 23:00 oswtop
drwxr-xr-x    2 oracle   oinstall       8192 Sep 17 23:00 oswps
drwxr-xr-x    2 oracle   oinstall       8192 Sep 17 23:00 oswprvtnet
drwxr-xr-x    2 oracle   oinstall       8192 Sep 17 23:00 oswnetstat
drwxr-xr-x    2 oracle   oinstall       8192 Sep 17 23:00 oswmpstat
drwxr-xr-x    2 oracle   oinstall       8192 Sep 17 23:00 oswiostat

[数据库环境:/oracle/oswatch/oswbb/archive] ls -lrt oswprvtne
-rw-r--r--    1 oracle   oinstall     105782 Sep 17 12:59 czdb2_prvtnet_14.09.17.1200.dat
-rw-r--r--    1 oracle   oinstall     105782 Sep 17 13:59 czdb2_prvtnet_14.09.17.1300.dat
-rw-r--r--    1 oracle   oinstall     105782 Sep 17 14:59 czdb2_prvtnet_14.09.17.1400.dat
-rw-r--r--    1 oracle   oinstall     106249 Sep 17 15:59 czdb2_prvtnet_14.09.17.1500.dat
-rw-r--r--    1 oracle   oinstall     105782 Sep 17 16:59 czdb2_prvtnet_14.09.17.1600.dat
-rw-r--r--    1 oracle   oinstall     105782 Sep 17 17:59 czdb2_prvtnet_14.09.17.1700.dat
-rw-r--r--    1 oracle   oinstall     106248 Sep 17 18:59 czdb2_prvtnet_14.09.17.1800.dat
-rw-r--r--    1 oracle   oinstall     105782 Sep 17 19:59 czdb2_prvtnet_14.09.17.1900.dat
-rw-r--r--    1 oracle   oinstall     106248 Sep 17 20:59 czdb2_prvtnet_14.09.17.2000.dat
-rw-r--r--    1 oracle   oinstall     105782 Sep 17 21:59 czdb2_prvtnet_14.09.17.2100.dat
-rw-r--r--    1 oracle   oinstall     105782 Sep 17 22:59 czdb2_prvtnet_14.09.17.2200.dat
-rw-r--r--    1 oracle   oinstall      87608 Sep 17 23:49 czdb2_prvtnet_14.09.17.2300.dat         <<<每一个小时一下文件,这些文件可以用vi等编辑器编辑或查看

 

关闭命令:

关闭的命令也非常简单,直接执行脚本stopOSWbb.sh

$ sh stopOSWbb.sh

 

为了使OSWatch能监控到心跳网络的情况,我们需要稍加配置,配置过程非常简单:

1. 查看example文件

[数据库环境:/oracle/oswatch/oswbb] cat Exampleprivate.net

######################################################################
# This file contains examples of how to monitor private networks. To
# monitor your private networks create an executable file in this same
# directory named private.net. Use the example for your host os below.
# Make sure not to remove the last line in this file. Your file
# private.net MUST contain the rm lock.file line.
######################################################################
#Solaris Example
######################################################################
echo "zzz ***"`date`
traceroute -r -F <node1-priv>
traceroute -I -r -F <node1-priv>
traceroute -r -F <node2-priv>
traceroute -I -r -F <node2-priv>
######################################################################
#HP Example
######################################################################
echo "zzz ***"`date`
traceroute -r -F <node1-priv> 
traceroute -r -F <node2-priv> 

######################################################################
#Linux Example
######################################################################
echo "zzz ***"`date`
traceroute -r -F <node1-priv> 
traceroute -r -F <node2-priv>
######################################################################
#Tru64 Example
######################################################################
echo "zzz ***"`date`
traceroute -r -f <node1-priv>
traceroute -r -f <node2-priv>
######################################################################
#AIX Example
######################################################################
echo "zzz ***"`date`
traceroute -r <node1-priv>
traceroute -r <node2-priv>
######################################################################
# DO NOT DELETE THE FOLLOWING LINE!!!!!!!!!!!!!!!!!!!!!
######################################################################
rm locks/lock.file

 

根据文件描述,我们新建一个private.net文件,内容如下:

[数据库环境:/oracle/oswatch/oswbb] ls -lrt private.net

-rwxr-xr-x    1 oracle   oinstall        839 Jun 04 14:44 private.net
[数据库环境:/oracle/oswatch/oswbb] cat private.net
######################################################################
# This file contains examples of how to monitor private networks. To
# monitor your private networks create an executable file in this same
# directory named private.net. Use the example for your host os below.
# Make sure not to remove the last line in this file. Your file
# private.net MUST contain the rm lock.file line.
######################################################################
#AIX Example
######################################################################
echo "zzz ***"`date`
traceroute -r czdb1-priv
traceroute -r czdb2-priv
######################################################################
# DO NOT DELETE THE FOLLOWING LINE!!!!!!!!!!!!!!!!!!!!!
######################################################################
rm locks/lock.file


[数据库环境:/oracle/oswatch/oswbb] grep priv /etc/hosts

172.168.1.11     czdb1-priv
172.168.1.12     czdb2-priv


只要private.net文件创建好,就会将心跳信息存放在archive/oswprvtne目录下了. 

 

 仔细看,以下内容是心跳异常时候的输入

zzz ***Thu Jun 5 04:08:48 CST 2014
trying to get source for czdb1-priv
source should be 172.168.1.12
traceroute to czdb1-priv (172.168.1.11) from 172.168.1.12 (172.168.1.12), 30 hops max
outgoing MTU = 1500
 1  czdb1-priv (172.168.1.11)  1 ms  0 ms  0 ms
trying to get source for czdb2-priv
source should be 172.168.1.12
traceroute to czdb2-priv (172.168.1.12) from 172.168.1.12 (172.168.1.12), 30 hops max
outgoing MTU = 1500
 1  czdb2-priv (172.168.1.12)  0 ms  0 ms  0 ms
zzz ***Thu Jun 5 04:09:04 CST 2014
trying to get source for czdb1-priv
source should be 172.168.1.12
traceroute to czdb1-priv (172.168.1.11) from 172.168.1.12 (172.168.1.12), 30 hops max
outgoing MTU = 1500
<span style="color:#ff0000;"><span style="font-size:18px;"><strong> 1  * * *
 2  * * *</strong>
</span></span> 3  czdb1-priv (172.168.1.11)  0 ms  0 ms  0 ms

以上表明有两次监测不到心跳通信.众所周知,在RAC环境中如果心跳网络不稳定,集群为了避免"脑裂"现象的发生,利用VOTINGDISK仲裁盘投票将强制将权重低的节点驱逐出集群.这一动作的完成,可以从CRS的相关日志可以看到evting,reconfigure等操作,但OSWatch的这部分信息无疑更有说服力,说明心跳不稳定,对问题的排查提供了强有力的证据.

 

如果对OSWatch有兴趣的朋友,可以查看文档 461053.1,文章里描述了如何利用jar包生成图形报告.

没有OSWatch工具包的朋友可以把邮箱地址留言给我,我逐一发送。

 

-------------------------------------------------------------------------------------------------

本文来自于我的技术博客 http://blog.youkuaiyun.com/robo23

转载请标注源文链接,否则追究法律责任!

### 关于Oracle OSW工具的使用 Oracle OSW (OS Watcher) 是一种用于监控操作系统性能的工具,能够帮助数据库管理员开发人员诊断并解决与系统性能相关的问题。以下是有关 Oracle OSW 工具的官方文档、教程以及示例的相关信息。 #### 1. **OSW工具的功能** OSW工具定期捕获操作系统的状态数据,并将其存储为压缩文件以便后续分析。这些数据包括但不限于 CPU 使用率、内存利用率、磁盘 I/O 网络活动等指标[^5]。 #### 2. **安装与配置** 为了启用 OSW 工具,通常需要执行以下操作: - 下载并解压 OSW 脚本包至目标服务器。 - 配置 `oswbb` 的参数文件(通常是 `config.txt`),指定采样频率其他选项。 - 启动脚本以开始采集数据。 具体命令如下所示: ```bash # 解压OSWBB软件包 tar -zxvf oswbb.tar.gz # 进入安装目录 cd oswbb/ # 编辑配置文件 vi config.txt # 启动OSWBB服务 ./start.sh ``` #### 3. **数据分析** 当发生性能问题时,可以通过查看由 OSW 工具生成的日志来获取详细的系统运行状况报告。日志路径一般位于 `/tmp/oswbb/` 或者自定义的位置中。通过解析这些日志文件,可以了解当时的操作系统负载情况及其变化趋势[^6]。 #### 4. **案例研究** 假设有一个场景:某个基于 Oracle 数据库的企业应用程序响应时间突然变慢。此时可利用 OSW 收集的数据配合其他诊断手段一起排查原因。例如检查是否有高 IO wait 时间或者是否存在严重的上下文切换现象等等[^7]。 #### 5. **注意事项** 在实际部署过程中需要注意几点事项: - 确保有足够的磁盘空间保存历史记录; - 设置合理的轮转周期以免占用过多资源; - 对敏感信息采取适当保护措施防止泄露。 --- ### 示例代码片段展示如何读取部分关键指标 下面提供了一个简单的 Python 脚本来演示如何提取某些特定字段的信息: ```python import os from datetime import datetime def parse_osw_log(log_path): """Parse the given OSW log file.""" results = [] with open(log_path, 'r') as f: lines = f.readlines() for line in lines: if "CPU" in line or "MEM" in line: timestamp_str, metric_name, value = line.split(',') result = { 'timestamp': datetime.strptime(timestamp_str.strip(), '%Y-%m-%d %H:%M:%S'), 'metric': metric_name.strip(), 'value': float(value.strip()) } results.append(result) return results if __name__ == "__main__": logs_dir = '/path/to/logs' all_logs = [f"{logs_dir}/{fname}" for fname in os.listdir(logs_dir)] parsed_data = [] for log_file in all_logs: parsed_data.extend(parse_osw_log(log_file)) print(parsed_data[:10]) # Print first ten entries. ``` ---
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值