目录
1. OSwatch 安装
1.1. OSwatch 下载
1.2. 部署私网监控(可选,Rac 环境心跳中使用)
1.3. 新增 archive 目录
1.4. 启动 osw
1.4.1. crontab 启动脚本
1.5. OSW 生成文件查看
1.6. 关闭 osw
2. OSwatch 数据分析
2.1. 运行前首先检查 java 环境:
2.2. 在服务端准备图形界面
2.3. 分析日志
2.3.1. 报错解决
2.4. 查询分析的结果
2.4.1. Analyze Data
2.4.2. Generate All CPU Gif Files
OSWatcher Black Box, 简称OSW,是oracle提供的一个非常有用的操作系统性能分析工具,它通过调用OS自己提供的命令来记录OS运行时的一些性能参数,比如CPU/Memory/Swap/Network IO/Disk IO相关的信息。OSW的工作机制是每隔一段时间调用OS提供的一些工具,比如ps, vmstat, netstat, mpstat, top;然后把这些工具的输出打印到文件里,当系统出现问题时我们可以利用收集的信息帮助我们去分析问题。
OSWatcher支持以下平台:
AIX
Tru64
Solaris
HP-UX
Linux
Windows
1. OSwatch 安装
1.1. OSwatch 下载
下载 OSwatch ( mos 文档 ID 301137.1 )
网盘路径
通过网盘分享的文件:oswbb840.zip
链接: 百度网盘 请输入提取码
部署在/mysql/osw1/目录下
tar – xvf oswbb840.tar -d /mysql/osw1/
1.2. 部署私网监控(可选,Rac 环境心跳中使用)
在每个节点上,根据 exampleprivate.net 文件, 新增 private.net 文件
注意修改private.net权限为755
chmod 755 private.net
vi private.net#!/bin/sh
#####################################################################
# 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 hefei1-priv
traceroute -r -F hefei2-priv
#####################################################################
# DO NOT DELETE THE FOLLOWING LINE!!!!!!!!!!!!!!!!!!!!!
#####################################################################
rm locks/lock.file
1.3. 新增 archive 目录
OSWATCH V7.3.3 以后,如果不指定 archive 目录, osw 默认的 archive 目录为 /app/oracle/tfa/repository/suptools/db01/oswbb/grid/archive, 为了避免影响 /app 目录,建议手工指定 archive 目录。
创建 archive 目录并修改权限
mkdir /osw/oswbb/archive
chmod 775 /osw/oswbb/archive
1.4. 启动 osw
cd /mysql/osw1/oswbb840/oswbb
nohup /mysql/osw1/oswbb840/oswbb/startOSWbb.sh 5 720 gzip /osw/oswbb/archive >/osw/oswbb/startOSW.sh.out 2>&1 &#其中 5 代表 5 秒收集一次 ,720 代表保留 720 小时 (可根据实际需求调整)。
#gzip /osw/oswbb/archive 代表文件压缩并指定存放位置。
startOSWbb.sh脚本有四个参数:
# $1 = snapshot interval in seconds. #快照收集的频率(秒)
# $2 = the number of hours of archive data to store. #归档数据保留的时间(小时)
# $3 = (optional) the name of the zip or compress utility you want #可选,用于在创建每个文件后自动压缩该文件的压缩实用程序的名称
# OSWbb to use to zip up the archive files upon completion. If
# no zipping is desired set this parameter = NONE. This will
# allow for the $4 parameter below to be recognized as both $3
# and $4 are optional parameters.
# $4 = (optional) the fully qualified name of the archive directory #可选,存储归档目录的备用(非默认)位置。 如果不输入任何参数,默认间隔30秒收集一次数据,并且默认保存48小时的数据。
# where you want oswbb to save your data. This option can be used
# instead of setting the UNIX environment variable OSWBB_ARCHIVE_DEST
# If this parameter is not set oswbb will look for the UNIX
# environment variable OSWBB_ARCHIVE_DEST. If neither are set
# the archive directory will remain in the default location under
# the oswbb directory
例: nohup ./startOSWbb.sh 15 120 gzip &
会每隔15秒搜集一次数据,将结果保留120 小时,并自动压缩生成的文件。
1.4.1. crontab 启动脚本
crontab -e
0,30 * * * * sh /mysql/osw1/oswbb840/oswbb/monosw.shvi monosw.sh
----------------------monosw.sh-----------------------------
#!/usr/bin/ksh
if ps -ef | grep OSWatcher | grep -v grep > /dev/null; thenecho "$(date): OSWatcher is running." >> /var/log/oswatcher.log
elseecho "$(date): OSWatcher is not running. Starting..." >> /var/log/oswatcher.logsh "$(dirname "$0")/startOSWbb.sh"
fi
1.5. OSW 生成文件查看
1.6. 关闭 osw
/mysql/osw1/oswbb840/oswbb/stopOSWbb.shORps -ef |grep OSW |grep -v grep
kill 9 sid
2. OSwatch 数据分析
2.1. 运行前首先检查 java 环境:
[root@db01 oswbb]# java -version
openjdk version "1.8.0_262"
OpenJDK Runtime Environment (build 1.8.0_262-b10)
OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)
2.2. 在服务端准备图形界面
2.3. 分析日志
运行 OSWbba 需要用-i 参数指定 archive 目录,这里的目录是 archive 的绝对路径,需要注意的是,这里生成的图形是直接弹出来的,需要用 X Windows.
export LANG=en_US
java -jar /mysql/osw1/oswbb840/oswbb/oswbba.jar -i /mysql/osw1/oswbb840/oswbb/archive[root@db01 oswbb]# java -jar /mysql/osw1/oswbb840/oswbb/oswbba.jar -i /mysql/osw1/oswbb840/oswbb/archiveValidating times in the archive...Starting OSW Analyzer V9.0.9
Copyright (c) 2022 by Oracle CorporationParsing Data. Please Wait...Scanning file headers for version and platform info...Parsing file db01_prvtnet_25.02.08.1000.dat ...
Compressed file found. Ignoring nohup.out ...Parsing file db01_pidstat_25.02.08.0900.dat ...
Parsing file db01_pidstat_25.02.08.1000.dat ...Parsing file db01_iostat_25.02.08.0900.dat ...
Parsing file db01_iostat_25.02.08.1000.dat ...Parsing file db01_nfsiostat_25.02.08.0900.dat ...
Parsing file db01_nfsiostat_25.02.08.1000.dat ...
Parsing file db01_vmstat_25.02.08.0900.dat ...
Parsing file db01_vmstat_25.02.08.1000.dat ...Parsing file db01_meminfo_25.02.08.0900.dat ...
Parsing file db01_meminfo_25.02.08.1000.dat ...Parsing file db01_netstat_25.02.08.0900.dat ...
Parsing file db01_netstat_25.02.08.1000.dat ...Parsing file db01_top_25.02.08.0900.dat ...
Parsing file db01_top_25.02.08.1000.dat ...Parsing file db01_ps_25.02.08.0900.dat ...
Parsing file db01_ps_25.02.08.1000.dat ...Parsing Completed.Enter 1 to Display CPU Process Queue Graphs
Enter 2 to Display CPU Utilization Graphs
Enter 3 to Display CPU Other Graphs
Enter 4 to Display Memory Graphs
Enter 5 to Display Disk IO Graphs
Enter 61 to Display Individual OS Process I/O RPS Graphs
Enter 62 to Display Individual OS Process I/O WPS Graphs
Enter 63 to Display Individual OS Process Percent User CPU Graphs
Enter 64 to Display Individual OS Process Percent System CPU Graphs
Enter 65 to Display Individual OS Process Percent Total CPU (User + System) Graphs
Enter 66 to Display Individual OS Process Percent Memory GraphsEnter GP to Generate Individual Process Profile
Enter GC to Generate All CPU Gif Files
Enter GM to Generate All Memory Gif Files
Enter GD to Generate All Disk Gif Files
Enter GN to Generate All Network Gif FilesEnter L to Specify Alternate Location of Gif Directory
Enter Z to Zoom Graph Time Scale (Does not change analysis dataset)
Enter B to Returns to Baseline Graph Time Scale (Does not change analysis dataset)
Enter R to Remove Currently Displayed GraphsEnter X to Export Parsed Data to Flat File
Enter S to Analyze Subset of Data(Changes analysis dataset including graph time scale)
Enter A to Analyze Data
Enter D to Generate DashBoardEnter Q to Quit ProgramPlease Select an Option:A
Enter a unique analysis directory name or enter <CR> to accept default name:A new analysis file analysis/db01_Feb08090557_1738996931/analysis.txt has been created.Enter 1 to Display CPU Process Queue Graphs
Enter 2 to Display CPU Utilization Graphs
Enter 3 to Display CPU Other Graphs
Enter 4 to Display Memory Graphs
Enter 5 to Display Disk IO Graphs
Enter 61 to Display Individual OS Process I/O RPS Graphs
Enter 62 to Display Individual OS Process I/O WPS Graphs
Enter 63 to Display Individual OS Process Percent User CPU Graphs
Enter 64 to Display Individual OS Process Percent System CPU Graphs
Enter 65 to Display Individual OS Process Percent Total CPU (User + System) Graphs
Enter 66 to Display Individual OS Process Percent Memory GraphsEnter GP to Generate Individual Process Profile
Enter GC to Generate All CPU Gif Files
Enter GM to Generate All Memory Gif Files
Enter GD to Generate All Disk Gif Files
Enter GN to Generate All Network Gif FilesEnter L to Specify Alternate Location of Gif Directory
Enter Z to Zoom Graph Time Scale (Does not change analysis dataset)
Enter B to Returns to Baseline Graph Time Scale (Does not change analysis dataset)
Enter R to Remove Currently Displayed GraphsEnter X to Export Parsed Data to Flat File
Enter S to Analyze Subset of Data(Changes analysis dataset including graph time scale)
Enter A to Analyze Data
Enter D to Generate DashBoardEnter Q to Quit ProgramPlease Select an Option:GC
Generating file gif/Feb08090557_1738996938/OSWg_OS_Run_Queue.gif
Generating file gif/Feb08090557_1738996938/OSWg_OS_Block_Queue.gif
Generating file gif/Feb08090557_1738996938/OSWg_OS_Cpu_Idle.gif
Generating file gif/Feb08090557_1738996938/OSWg_OS_Cpu_System.gif
Generating file gif/Feb08090557_1738996938/OSWg_OS_Cpu_User.gif
Generating file gif/Feb08090557_1738996938/OSWg_OS_Cpu_Wa.gif
Generating file gif/Feb08090557_1738996938/OSWg_OS_Cpu_Interrupts.gif
Generating file gif/Feb08090557_1738996938/OSWg_OS_Context_Switches.gif
Files written to the gif/Feb08090557_1738996938 directory.Enter 1 to Display CPU Process Queue Graphs
Enter 2 to Display CPU Utilization Graphs
Enter 3 to Display CPU Other Graphs
Enter 4 to Display Memory Graphs
Enter 5 to Display Disk IO Graphs
Enter 61 to Display Individual OS Process I/O RPS Graphs
Enter 62 to Display Individual OS Process I/O WPS Graphs
Enter 63 to Display Individual OS Process Percent User CPU Graphs
Enter 64 to Display Individual OS Process Percent System CPU Graphs
Enter 65 to Display Individual OS Process Percent Total CPU (User + System) Graphs
Enter 66 to Display Individual OS Process Percent Memory GraphsEnter GP to Generate Individual Process Profile
Enter GC to Generate All CPU Gif Files
Enter GM to Generate All Memory Gif Files
Enter GD to Generate All Disk Gif Files
Enter GN to Generate All Network Gif FilesEnter L to Specify Alternate Location of Gif Directory
Enter Z to Zoom Graph Time Scale (Does not change analysis dataset)
Enter B to Returns to Baseline Graph Time Scale (Does not change analysis dataset)
Enter R to Remove Currently Displayed GraphsEnter X to Export Parsed Data to Flat File
Enter S to Analyze Subset of Data(Changes analysis dataset including graph time scale)
Enter A to Analyze Data
Enter D to Generate DashBoardEnter Q to Quit ProgramPlease Select an Option:Q
[root@db01 oswbb]#
2.3.1. 报错解决
--报错:Exception in thread "main" java.lang.NullPointerException
at o.b(Unknown Source)
at B.a(Unknown Source)
at o.a(Unknown Source)
at OSWGraph.OSWGraph.main(Unknown Source)
--解决:
yum -y install *vnc*
vncserver
export LANG=en_US
--报错:内存太小,报错,需要调大内存
--解决:
java -jar –Xmx512M /mysql/osw1/oswbb840/oswbb/oswbba.jar -i /mysql/osw1/oswbb840/oswbb/archive
--报错:An exception occured in insertVmstatLists on line
--解决:
java -Duser.language=en -Duser.country=us -jar /data/oswbb/oswbba.jar -i /data/oswbb/archive/
2.4. 查询分析的结果
2.4.1. Analyze Data
cd /mysql/osw1/oswbb840/oswbb/analysis/
2.4.2. Generate All CPU Gif Files
cd /mysql/osw1/oswbb840/oswbb/gif
OSwatcher CPU:Interrupts Per Second