Monday, November 16, 2009

Using Oracle Database Resource Manager facilitates meeting SLAs


A big challenge DBAs face is aligning database resources with the real-world demands of daily business and realigning those resources as demands change—especially in terms of meeting SLAs (service-level agreements) with internal and external customers. Oracle Database Resource Manager, introduced in Oracle8i and improved with each subsequent release, provides new capabilities that make using it a viable approach to managing a fundamental system resource, the CPU, and how the CPU allocates its cycles to the processes running on the system.

Note that the concurrent use of Database Resource Manager with OS resource managers is supported only for utilities that use technologies such as processor sets or domains to isolate each database instance into its own "virtual partition." For more information, see MetaLink or the Oracle Database Administrator's Guide.

Overview of Oracle Database Resource Manager
Oracle Database Resource Manager takes a database-instance-centric approach to managing resources, letting DBAs apply business-operational policies to the system so that resources will be allocated to various user communities and applications in the context of the entire system, adjusting the balance according to user-defined rules.
The rules, or directives, are defined in a resource plan and apply to specific groups of users—consumer groups—that you also define. You can define many different resource plans—one for daytime operations, one for nighttime operations, for example—but only one can be active per database instance at any moment. (By default, Oracle Database Resource Manager is not enabled; it remains disabled until you select an active resource plan for your system. Also note that because Database Resource Manager works at the instance level, in an Oracle Real Application Clusters environment, you must enable it on each instance in the cluster.)

A resource plan can encompass numerous consumer groups and subplans, letting you finely control resource allocation. You can create and manage all the elements of Oracle Database Resource Manager—resource plans, resource consumer groups, and directives—with Oracle Enterprise Manager Database Control (or Grid Control, if you're running Oracle Real Application Clusters) or the DBMS_RESOURCE_MANAGER built-in PL/SQL package.

Getting Started with a Resource Plan
You'll find the Resource Manager section on the Oracle Enterprise Manager Database Control Administration page (click on the Administration link on the Oracle Enterprise Manager Database Control home page to get to the Administration page. The Resource Manager menu is adjacent to the Scheduler). Starting from this page, you can perform the administration tasks for setting up the necessary elements and monitor how an active plan is allocating resources at any moment (on the Resource Monitors page).

Before creating a new plan, you must create a few Consumer Resource Groups (click on Resource Consumer Groups on the menu under Resource Manager on the Administration page). The Resource Consumer Group page lists any existing groups (some are built-in defaults), and you can click on the Create button to create a new group and give it a name and a description, upon which you'll see all the user (schema) names in your system displayed. Until you move users into groups you create, most users in the system are members of the DEFAULT_CONSUMER_GROUP. (Another built-in group, SYS_GROUP, contains the SYSTEM user).

The plan displays the list of consumer groups in our system—CUSTOMERS and BATCH_APPS—and an Oracle-provided consumer group (OTHER_GROUPS). The CUSTOMERS consumer group comprises user accounts with strict SLA requirements—in this case, user accounts associated with purchasing applications. The BATCH_APPS consumer group comprises applications that print invoices and statements. Typically these run at night, but occasionally they are run during the day, time permitting. OTHER_GROUPS is mandatory on every resource plan and is not editable—it exists to allocate resources to processes, such as background processes, that are not accounted for in any other group.

How the Plan Affects Utilization
Consumer groups share system resources, using percentages specified in the plan. CUSTOMERS have been allocated 85 percent of system resources and BATCH_APPS 10 percent; OTHER_GROUPS has been allocated 5 percent. The plan is a simple single-level plan, with all allocations at level 1. You can, however, devise multilevel plans in which level-2 consumer groups (and groups on subsequent levels) receive their allocations only after level-1 consumer groups have received their full specified allocation of resources. (See the Oracle Database Administrator's Guide for details about constructing such plans.)

You can define plans to account for a variety of scenarios, ensuring that batch job processing won't interfere with customers trying to buy products, for example, and that distinct requirements can always be met.
By default, consumer groups share resources as percentages (you can also define simple ratios). However, if CUSTOMERS are ever the only type of consumer using the system, they will get 100 percent of the CPU, not just 85 percent. That's because Oracle Database Resource Manager is designed to maximize Oracle Database throughput rather than arbitrarily enforce allocations; that is, until the CPU or multiple CPUs are fully taxed—reach 100 percent utilization—the allocations don't come into play.

More About Resource Plan Directives
The plan is fairly straightforward, and we didn't change any directives from their default settings (null values). However, using directives lets us build even-more-powerful plans that manage resources proactively and automatically. For example, the max_idle_time directive (whose null default value means unlimited) can be set for a consumer group to ensure that sessions aren't idle beyond the limit set for that group, freeing resources for serving other consumer groups in the plan (or other sessions in the consumer group).

You set plan directives by clicking on the appropriate link on the Resource Plan Detail page; clicking on one displays the appropriate page of options available, with consumer groups and subplans.

Dynamically Switching Sessions into Groups
Several directives available on the Group Switching page (or available through the API) can be combined in various ways in a resource plan to automate your operations.

In Oracle Database 10g, the switching capability has been enhanced, with the switch_time_in_call and switch_time directives. The former sets how long, in seconds, a session can execute before switching to a new consumer group. At the end of the call, the session's consumer group is restored to the previous one. You can implement these directives in a plan with the DBMS_RESOURCE_MANAGER API. Listing 1 shows a slightly modified version of the resource plan we created with Oracle Enterprise Manager, implementing the switch_time_in_call directive for an additional group, WEB_CUSTOMERS.

The switch_time_in_call directive is especially useful in multitier applications in which a middle-tier application server has implemented session pooling. With switch_time_in_call, one client's resource consumption won't affect a future client executed in the same session.

Before setting up the directives for switching in a resource plan, grant the consumer group the privilege to switch into the target consumer group. (Actually, you can set up the consumer group to switch into, but this is ineffective until you grant the proper permission.) To grant permission to switch consumer groups, use the DBMS_ RESOURCE_MANAGER_PRIVS package, as in this example:
 
begin
dbms_resource_manager_privs
.grant_switch_consumer_group 
('WEB_CUSTOMERS', 'CUSTOMERS', true);
end;

In Listing 1, members of the consumer group WEB_CUSTOMERS are switched to the CUSTOMERS consumer group if the request they're making will exceed five seconds—they're moved into the higher-priority CUSTOMERS group until the request is processed. When the call completes, the user is moved back into the WEB_CUSTOMERS group.

Conclusion

Operating-system-level resource managers do a good job in many circumstances but often don't provide effective control of a system focused primarily on running an Oracle database instance. With new capabilities, such as the ability to switch automatically into and out of groups, Oracle Database Resource Manager is a tool to seriously consider using, especially for running a highly loaded system with a variety of applications and for meeting demanding SLAs.

REFERENCES
Database Resource Manager By Kimberly Floss, Oracle Corporation

How to protect yourself from RAID-related Unrecoverable Read Errors (UREs)

If you are ever rebuilding a RAID system, Unrecoverable Read Error (URE) is one term you don't want to learn about the hard way. As the name implies, a URE makes for a really bad day, as it can stop a RAID rebuild in its track, essentially making the entire RAID volume unusable.


I won't go into a lot of detail about the "why" behind what causes a URE because many other very smart people have already done a good job of explaining it. (Admittedly, some of the warnings might be sensationalist, and there seems to be some confusion on terminology, but do your own math to see if you might have a serious problem.) What I will do is provide you with tips on how to make sure that you don't fall victim to these errors.

1. Don't use RAID 5 if you plan to use large non-enterprise-grade SATA disks.

When it comes to reliability, enterprise grade disks are generally at least one order of magnitude more reliable than their non-enterprise counterparts. If you believe what has been written about UREs, as the size of disks increases and as more disks are added to RAID 5 arrays, the likelihood of total data loss across the entire RAID volume begins to get into dangerous territory.

If you're trying to build a 14 disk RAID array using 1.5TB or 2TB SATA disks you bought at Best Buy, consider using RAID 6 or RAID 10 instead of RAID 5. RAID 6's dual parity mechanism provides additional cushion in the event of drive failures (at the cost of performance), while RAID 10 setups can lose up to half the disks before incurring data loss.


If you're really intent on creating a large array and want minimal RAID overhead, you could even consider RAID 50, which is a RAID 0 of RAID 5 arrays. If you were going to use RAID 50 for that 14 disk array, you'd create three four-disk RAID 5 arrays and do RAID 0 across those and use the remaining two disks as spares.

2. Don't use cheap hardware if you need to push limits.

Yes, budgets are tight, but don't risk your data. Buy enterprise-grade disks such as SAS, fibre channel disks, or at the very least high-grade SATA disks with a higher mean time between failure rating.


If you're using disks that have a bit error rate of 1 in 10^14, you're using a cheap disk. Enterprise-class disks will have a bit error rate of 1 in 10^15 or, better yet, 1 in 10^16, which makes this class of disk much less susceptible to UREs.

Note: I'm not necessarily saying that you should buy SAS disks rather than SATA disks, but do look for disks with a reasonable bit error rate.

3. If you need a lot of disks for spindle performance, use smaller capacities.

There are times when quantity outweighs capacity. For example, when your disk system is constrained by IOPS, throwing more disk spindles at the solution can fix the problem, so in some cases, you might want to have a bunch of disks in a single RAID array. If you do, use smaller capacity disks.


One of the main concerns around the possibility of encountering a URE lies in the sheer amount of time it takes to rebuild after the loss of a massive disk, such as a 1TB or 2TB disk. When disk sizes were smaller, the window of opportunity for data loss was a lot smaller since smaller disks rebuild more quickly. As disk sizes continue to grow, this window of opportunity for data loss grows, and the problem will become more serious unless manufacturers can manage to produce drives with lower bit error rates.

4. Backups, backups, backups

Someone actually asked me once why we still do backups when we use RAID on all of our servers. No matter how reliable disks get, and no matter how far away you are from even the potential of a URE, nothing replaces reliable backups. If you ever run into a URE, you'll need reliable backups.

5. Be patient

Storage needs constantly increase, and RAID 6 is simply not the answer for everyone that becomes uncomfortable with RAID 5. We have a market need and someone, somewhere will come along and fill that need with a new way to provide robust redundancy. We've also seen newer data protection methods in use in products, such as Windows Home Server and Drobo's line of devices, and it's only a matter of time before similar methods - or completely new methods - become available for enterprise gear.


REFERENCES

How to protect yourself from RAID-related Unrecoverable Read Errors (UREs), by Scott Lowe, November 16th, 2009
, www.Techrepublic.com




Thursday, November 12, 2009

A Closer Look at ADDM



New diagnostics engine in Oracle 10g helps detect and diagnose performance problems
In my last column, I focused on one of Oracle Database 10g's quick wins for DBAs—using the new SQL Tuning Advisor to quickly tune poorly performing SQL statements—and touched only briefly on the new built-in diagnostic engine, Automatic Database Diagnostic Monitor (ADDM), which helps you easily identify problematic SQL statements (see "Advice and Consent" in the March/April 2004 issue for more information about using the SQL Tuning Advisor and the DBMS_SQLTUNE package). Identifying high-load SQL statements is just one of ADDM's many capabilities. A self-diagnostic engine built into the Oracle Database 10g kernel, ADDM automatically detects and diagnoses common performance problems, including:
  • Hardware issues related to excessive I/O
  • CPU bottlenecks
  • Connection management issues
  • Excessive parsing
  • Concurrency issues, such as contention for locks
  • PGA, buffer-cache, and log-buffer-sizing issues
  • Issues specific to Oracle Real Application Clusters (RAC) deployments, such as global cache hot blocks and objects and interconnect latency issues
Let's continue exploring the new performance tuning capabilities of Oracle Database 10g by taking a look at ADDM.


Automatic, Effective Problem Diagnosis
ADDM automatically analyzes the performance of the database at regular intervals (once an hour by default) and identifies any performance issues. ADDM's diagnostic engine is modeled as a classification system that quickly and effectively sifts through the statistical data in Automatic Workload Repository (AWR)—a newly introduced built-in repository in Oracle Database 10g containing performance statistics and workload information—and evaluates problem areas, based on their impact on overall database performance. ADDM's processing logic encompasses best practices and the accumulated expertise of tuning professionals throughout the industry. Ultimately ADDM presents a set of "findings" that not only identifies the cause of performance problems but can also inform administrators that certain database subcomponents, such as I/O, are functioning properly and do not require any further investigation.
Automation is just one of several unique benefits of ADDM. Another important benefit is ADDM's ability to identify the root cause of problems. Just as physicians achieve better results for their patients by treating causes rather than symptoms, DBAs can achieve better database performance by finding the root cause of performance issues before making changes to the system. However, finding a root cause can be difficult and time-consuming, given that symptoms can sometimes mask the real problem.

ADDM can distinguish between the cause and symptoms of a problem. It's able to do so, in part, by using the extensive new data (events, statistics) generated by the database at runtime. Oracle database kernel code has always been instrumented to provide raw performance data, but in this release, the instrumentation is more comprehensive.
For example, wait events are more granular, with numerous locks and latches now separated into distinct wait events. Furthermore, wait events are now grouped into classes—Application, Administration, Commit, Concurrency, Network, User I/O, System I/O, and Configuration, for example—to facilitate processing through ADDM.
In addition to the new wait-event model, Oracle Database 10g also includes an array of new statistics that provide performance data on everything from operating system performance—hard disk I/O statistics, CPU utilization, and network statistics, for example—to cumulative statistics at the system and session levels. One of the most important new statistics is database time, or DB time—the amount of time the database is actually working on database calls.

It's About Time
ADDM uses DB time to measure throughput; it's the total time spent by foreground processes—such as a read I/O—waiting for a database resource, running on the CPU, and waiting for a free CPU. The overarching goal of ADDM is to reduce the value of DB time across the system, thereby improving overall throughput.
Operational information about active sessions—those using the CPU—as well as sessions waiting for the CPU, is sampled every second and held in a scrolling buffer in the server memory—Active Session History (ASH), an important new feature of Oracle Database 10g. ASH (V$ACTIVE_SESSION_HISTORY) maintains historical data; in previous Oracle releases, DBAs had information about currently active sessions only— not historical data—so figuring out the cause of performance problems after the fact wasn't easy.
Data from ASH, along with other important database statistics, persists on the disk in the form of "snapshots." Snapshots are taken every hour and stored for seven days, by default, but DBAs can change settings for both snapshot frequency and storage duration. AWR provides the raw information for ADDM analysis, which begins automatically as soon as a new AWR snapshot is taken.


Getting Started with ADDM
Because ADDM runs automatically after each new AWR snapshot is taken, no manual steps are required to generate its findings. But you can run ADDM on demand by creating a new snapshot manually, by using either Oracle Enterprise Manager (OEM) or the command-line interface. The following shows creation of a snapshot from the command line:
 
SQL> exec dbms_workload_repository.create_
snapshot();
PL/SQL procedure successfully completed.

After the new snapshot is created, its information (snap_id, begin_interval_ time, and the like) is populated to the DBA_HIST_SNAPSHOT dictionary view. A few seconds after you take the snapshot, ADDM brings new findings to the surface, based on analysis of that snapshot. The findings are available on the new OEM Web-based console, on the Database home page.


When you access the database instance in the new OEM console, you see at a glance how the database is operating in general, on a dashboard-style home page. You can quickly verify that the server has adequate CPU and memory resources and get a general overview of the system from this one page. The Active Sessions pie chart shows the current distribution across the server in three key areas: Using CPU, Waiting I/O, and Waiting Other. You can drill down on any of these items to see a line graph of activity over the last 24 hours (and change this to values such as 31 days, 7 days, or just a few minutes).

The results of the latest ADDM run are displayed in the Performance Analysis section of the home page which provides a summary view of the top ADDM findings: the impact of the diagnosed problem as a percentage of overall database performance, a description of the finding, and a recommendations summary. The text of each finding is a hyperlink to more-detailed information on that particular finding. ADDM recommendations can include running one of the new advisors—SQL Tuning Advisor, SQL Access Advisor, Space Management Advisor, and so on—when applicable. For example, a solution for a particular finding can involve using SQL Tuning Advisor to tune a particular SQL statement or adding more resources to the machine. Clicking on the recommendation link displays the detailed finding view, which includes the full text of any recommendations.


You can also generate an ADDM report that summarizes performance data and provides a list of all findings and recommendations. You can access ADDM reports through the Web-based OEM console or from a SQL*Plus command line by using the new DBMS_ADVISOR built-in package. For example, here's how to use the command line to create an ADDM report quickly (based on the most recent snapshot):
 
set long 1000000
set pagesize 50000
column get_clob format a80
select dbms_advisor.get_task_report(
task_name, 'TEXT', 'ALL') 
as ADDM_report
from dba_advisor_tasks
        where task_id=(
        select max(t.task_id)
        from dba_advisor_tasks t,                     dba_advisor_log l
          where t.task_id = l.task_id
          and t.advisor_name='ADDM'
          and l.status= 'COMPLETED');

The ALL parameter generates additional information about the meaning of some of the elements in the report.
Findings report the impact of the identified problem as a percentage of DB time, which correlates with the expected benefit, based on the assumption that the problem described by the finding will be solved if the recommended action is taken. For example, here's a finding that identifies a configuration issue and recommends adjusting the sga_target value in the parameter file:
 
FINDING 3: 5.2% impact (147 seconds)
---------------------------------------
The buffer cache was undersized causing significant additional read I/O.
RECOMMENDATION 1: DB Configuration, 5.2% benefit (147 seconds)
ACTION: Increase SGA target size by increasing the value of parameter "sga_target" by 24 M.
SYMPTOMS THAT LED TO THE FINDING:
Wait class "User I/O" was consuming significant database time. (5.3% impact [150 seconds])
...

As you see, DBAs have the flexibility to decide how to resolve ADDM findings. In this case, the DBA might decide to use the new automatic SGA sizing feature, rather than modifying the parameter.

Conclusion
Oracle Database 10g provides DBAs with comprehensive, quantifiable diagnostic information that can be used to proactively monitor and prevent problems as well as respond to them when they arise. There's an enormous amount of new statistical information available to help keep the database running optimally. More important, the automatic performance-diagnostic capabilities of AWR and ADDM will not only help you resolve critical performance problems quickly but will also provide you with hard-and-fast, quantifiable data for making the business case for new hardware, additional staff, application development initiatives, or better training for employees. And Oracle plans to continually update ADDM's problem classification tree and diagnostic rules to keep pace with new features and technologies introduced in the database and underlying operating platform. 

REFERENCES

A Closer Look at ADDM By Kimberly Floss  , Oracle Corporation