|
| FIGURE 3: Several summary tables work together to
help in the load-balancing process: After poplulating the vol_grp
table with information about mount points and their associated
disks, you can relate the disk-level data to the file-level data and
identify which files are causing excessive activity on a disk. You
can easily create summary tables such as sum_iostat and sum_filestat
(which aggregate the disk- and file-level data by mount point) from
the vol_grp, filestat, and iostat tables.
|
- The filestat table contains the I/O data collected by modified
versions of bstat and estat; it includes mount point, filename, and
table name, as well as date and specific I/O information. The I/O data
includes the actual number of physical reads and writes, the number of
block reads and writes, and the time required to perform them.
- The iostat table also includes read and write times corresponding to
specific dates, but at the disk level. It collects information from the
iostat utility, using the script get_iostat.ksh.
To provide a cross-reference between
the filestat and iostat tables, we added the vol_grp (volume/group)
table, which links mount points to physical disks. You need to populate
this table manually, based on how your disks are partitioned into mount
points. The design of the vol_grp, filestat, and iostat tables lets you
aggregate, or average, I/O data over time and summarize it by disk,
mount point, tablespace, or data file.
In the example, we've added two
summary tables: sum_filestat and sum_iostat.
- The sum_filestat table is created (in the estat_file.sql script) by
summing I/O data from the filestat table over all files and tables for
each mount point.
- The sum_iostat table is created (in the get_iostat.ksh script) by
aggregating the I/O data from the iostat table by mount point, rather
than by disk, using the disk-to-mount-point relationships from the
vol_grp table.
Collecting the Data
This data-collection approach is based on existing UNIX and Oracle
utilities (iostat and bstat/estat, respectively), but it does require
slight modifications to these utilities. The example scripts shown in
Listings 1 through 4 will help you use these utilities to collect data
into the tables shown in Figure 3.
- The get_iostat.ksh script, in Listing
1, is a UNIX shell script that collects disk-level I/O information
at five-minute intervals. It runs the iostat utility and captures the
output into the iostat table, using the data from the vol_grp table to
create the sum_iostat table as well. Once you've run this script, you
have the data required to identify your system's hot disks and mount
points.
- The get_filestat.ksh script, in Listing
2, is a UNIX shell script that collects I/O information at the file
and table levels, as well as by mount point, also at five-minute
intervals. It calls two SQL snippets, bstat_file.sql and estat_file.sql
(shown in Listing
3 and 4),
which are customizations of Oracle's utlbstat and utlestat utilities,
modified to store the I/O statistics in Oracle tables, rather than in
report.txt output. The UNIX script runs bstat_file.sql first, waits five
minutes, and then runs estat_file.sql, causing the system to insert the
resulting data into the filestat and sum_filestat tables shown in Figure
3. After running this script, you have the data needed to track hot
disks down to the file and table level.
Generally, you should run get_filestat.ksh concurrently with
get_iostat.ksh, so that the file- and disk-level data are collected during
the same time period. You can run both scripts as often as you like, and
you can collect data over long periods of time without adverse effects on
database performance. File I/O information is generally collected very
quickly from the Oracle database's system global area (SGA) memory. (The
actual memory structures that contain the file I/O data are called
v$filestat and file$.) Disk I/O data collection is also very fast, usually
taking less than one second.
One drawback of this approach is that the data-collection tables will
eventually become very large. However, you can manage table size by
deleting low-I/O data-file entries. For example, you could delete
inactive-file entries with the following SQL (which is included in Listing
1 ):
delete from sys.iostat
where phys_read < 10 and phys_write < 10;
Bear in mind that deleting these entries will skew long-term averages,
since the averages will be based only on higher-activity entries.
Although the information collected by iostat and filestat is somewhat
redundant, the two sets of results work well together. When the iostat
results identify a hot mount point, you can turn to the filestat results
to look at the activity for each data file residing on the mount point.
The filestat results also provide more-in-depth information, including the
overall time required to perform the reads and writes. From elapsed-time
information, you can quickly identify the files that are waiting on disk
I/O and see the actual number of physical reads and writes.