Oracle Database Cache Concepts and Administration Guide Release 1.0.2.1 Part Number A88706-01 |
|
To set up Oracle Database Cache, you use Cache Manager, a component of Oracle DBA Studio. Cache Manager is an easy-to-use, Java-based interface that helps you to set up the middle-tier caches, specify the data and PL/SQL objects (packages, procedures, and functions) to be cached in each, and specify the synchronization policy of each table in each cache.
Note: Oracle Database Cache provides a cache management API, which is loaded into the cache during installation. The API provides PL/SQL procedures and functions that allow you to use a utility such as SQL*Plus to perform many of the tasks you perform with Cache Manager. For more information about the API, see Chapter 6. Oracle Database Cache also provides views that allow you to use SQL to access information, such as a list of cached objects, from the cache. For more information about the views, see Appendix A. |
To set up Oracle Database Cache, you take the following general steps:
Before you begin setting up Oracle Database Cache, take time to design your Oracle Database Cache environment. In doing so, you gather the following information:
When you have answered these questions, you will have the necessary information to set up and deploy Oracle Database Cache.
The first step in designing your Oracle Database Cache environment is determining which data you should cache. To that end, answer the following questions:
Because Oracle Database Cache routes only read requests to the cache, you get the greatest benefit when most of the requests for the data are read-only.
Read/write transactions may generate some inconsistencies. For example, if a transaction contains a query, then an UPDATE statement for the same table, and subsequently another query of the same data, the data that is returned for the second query will not contain the updated data. The updated data is written to the origin database; the query is executed by the cache.
Your Web sites or applications may have one query that is executed very often or they may have several queries in this category. Before you set up your caches, you can use Oracle Performance Manager or SQL Analyze to help you determine which queries are executed most frequently. Alternatively, you can set up a cache and monitor the queries that are executed by viewing the Hit/Miss Statistics page of Cache Manager (see "Monitoring Hit and Miss Statistics").
If the data resides in more than one database, which database contains most of the frequently accessed, read-only data? For this release, you can cache data from only one origin database.
Each query may access data in one or more tables in a database.
That is, does it matter if there is a delay between when new data is entered into the origin database and when that data in the caches is synchronized with the origin database? If a delay is acceptable, then the data is well suited to be cached.
If the data is updated constantly and extensively and the read-only applications must have current data, you will have to synchronize the data at frequent intervals. See "Deciding Synchronization Policies" for information about synchronizing data.
Now you have identified the data to be cached. Oracle Database Cache caches and manages data in entities called data sets. A data set is any collection of data items that can be expressed using a SQL statement. A data set can be a table, any subset of a table, or data from more than one table.
As an example, after answering the preceding questions, you determine that your company Web site, GreatStore.com, has several frequently requested queries:
In this example, you decide that you need to cache the BOOKS_ORDERED and NYT_BEST tables from the BOOKS database and the SOFT_SPEC table from the SOFTWARE database. Each table to be cached is a data set.
Using Oracle Database Cache, you cache the data in a cache on a middle-tier node.
In most cases, a company may have several middle-tier servers, such as Web servers or application servers, that handle all requests. If the data is stored in only one origin database, you can cache the same data on all middle-tier servers. That is, you can have identical caches on all nodes.
In some cases, a company may have several middle-tier servers, but it routes different types of requests to different Web servers. For example, in an online news publishing company, Web servers A and B are responsible for requests for the weather information; Web servers C and D are responsible for requests for sports information. In this situation, you cache different data on Web servers A and B than on C and D.
Using the GreatStore.com scenario described in the previous section, you must cache your data on at least two different middle-tier nodes because your data resides in two separate origin databases. You decide to cache data about books in the caches on several middle-tier nodes. You cache identical data sets in these caches. Then, you decide to cache data about computer software in the caches located on several other middle-tier nodes. You cache identical data about computer software in these caches.
When you synchronize data, you make the data in the cache consistent with the data in the origin database by refreshing the cache with the current data from the origin database. The synchronization policy establishes how and how often the data in the cache is refreshed from the origin database. You can specify different synchronization policies for each data set.
You can choose incremental or complete synchronization:
Use this option when only a portion of the data changes.
Use this option when a large percentage of your data changes at the same time, as when the batch updates are loaded into the origin database.
If there is a large amount of data in the data set, a complete synchronization can take considerably more time than an incremental synchronization. However, if a large percentage of data in a data set changes, a complete synchronization is more efficient than an incremental synchronization.
For either of these types of synchronization, you can schedule synchronization at specified intervals or you can use Cache Manager to synchronize the data at any point in time.
When you can predict how often the data needs to be synchronized, schedule the synchronization to occur at specified intervals.
For example, your Web site may list the 100 books that are the top sellers on your Web site. The results of such a query change quite frequently, so you decide to synchronize the data once each hour.
In setting the interval, consider the frequency of updates to the data in the origin database. In addition, consider your environment's tolerance for stale data. If there is low tolerance, synchronize often; if there is high tolerance, synchronize less often.
If you cannot predict how often the data needs to be synchronized, or if you want to synchronize the data at a time other than the scheduled time, you can use Cache Manager to synchronize the data.
For example, a Web site for ordering sporting goods contains a catalog of items. New items are added to the catalog at irregular intervals, making it difficult to predict a schedule for synchronization. In this case, you can synchronize the data when the changes in data in the origin database necessitate it.
When you plan the synchronization of your data, consider carefully how you want the data to be refreshed throughout your Oracle Database Cache environment. You may want to schedule synchronization at a time of day when connectivity is guaranteed or when communication costs are lowest. If your caches or origin database experiences a high volume of transactions during the business day, consider scheduling the synchronization during off-peak hours. Furthermore, you might want to stagger the synchronization to distribute the load on the origin database over time, rather than scheduling the synchronization of many caches at the same time.
If the synchronization intervals are very short or the data changes rapidly, you may see an effect on performance because of the processing required to keep the middle-tier cache synchronized with the origin database.
If the synchronization takes longer than the interval specified, the table will be continually refreshed. For example, if you specify an interval of 5 minutes, but the synchronization takes 6 minutes to complete, the next scheduled synchronization will start immediately after the first one completes.
If two or more requests to synchronize a particular table are issued simultaneously, one of the requests will succeed. The other requests will fail with an error.
Note that while you can easily change the synchronization policy from scheduled to not scheduled, changing the policy from Complete to Incremental or Incremental to Complete consumes more resources and may take considerable time if the table is very large.
You can cache PL/SQL objects (packages, procedures, and functions). Consider the following when deciding which, if any, PL/SQL objects to cache:
If you cache PL/SQL objects that contains both read-only and read/write statements, calls to these objects may generate inconsistencies. For example, if a PL/SQL procedure contains a query, then an UPDATE statement for the same table, and subsequently another query of the same data, the first query will return data, but the UPDATE statement will fail. Oracle Database Cache will mark the call to the PL/SQL procedure as a miss.
You install Oracle Database Cache on all nodes in the middle tier where you want to cache data. When you install Oracle Database Cache, you specify which Oracle database you want to use as the origin database. The installation procedure creates a cache on the Oracle Database Cache node and prepares the origin database for use by Oracle Database Cache.
In addition, you install Oracle Enterprise Manager, including DBA Studio. Cache Manager is a component of DBA Studio.
For more information about how to install Oracle Database Cache, see the installation guide.
Oracle DBA Studio is a Java-based interface that you use to manage your Oracle environment. Cache Manager, a component of DBA Studio, provides the interface to manage your Oracle Database Cache environment and provides wizards that take you through the process of setting up and deploying your Oracle Database Cache environment.
You can start DBA Studio through the Oracle Enterprise Manager console or as a standalone application.
To invoke the Oracle Enterprise Manager console on UNIX systems, such as Sun Solaris, enter the following command:
oemapp console
To invoke the Oracle Enterprise Manager console on Windows NT systems, from the Windows NT Start menu, select Programs -> Oracle_home_name -> Oracle Enterprise Manager -> Console.
Then, from the console, select Tools -> Database Applications -> DBA Studio or select the Database Applications icon from the toolbar and then select the DBA Studio icon.
Note that Oracle Database Cache does not support the jobs and events subsystem or discovery of cache nodes.
To start DBA Studio as a standalone application on UNIX systems, enter the following command:
oemapp dbastudio
To start DBA Studio as a standalone application on Windows NT systems, from the Windows NT Start menu, select Programs -> Oracle_home_name -> DBA Management Pack -> DBA Studio.
When you invoke DBA Studio, it displays the Oracle Enterprise Manager Login dialog box:
Select Launch DBA Studio standalone. Click OK.
When you log in successfully, DBA Studio is displayed:
Before you can connect to an origin database, you must add it to the list in the Navigator tree. Take the following steps:
Alternatively, if the origin database is listed in the local tnsnames.ora file, it is displayed in the Service Name list. In this case, you can select Add selected databases from your local tnsnames.ora file. Then, select the database service name.
DBA Studio lists the origin database in the Navigator tree. When you log in to DBA Studio in the future, the database will be listed in the tree.
To connect to the database, take the following steps:
DBA Studio authenticates the user, checking that the user is a valid user with the requisite privileges in the origin database. When you log in successfully, DBA Studio expands the database in the Navigator tree.
To manage your Oracle Database Cache environment, select the Caches folder from the Navigator tree. DBA Studio displays information about Cache Manager and a button to view the Oracle Database Cache Quick Tour.
Expand Caches to see the caches associated with the origin database. Oracle Database Cache attempts to attach to the associated caches. The icons for each cache show the state of the cache.
Now, select a cache from the Navigator tree to see information about that cache:
The preceding illustration points out some of the features of DBA Studio and Cache Manager:
When you select a cache, the General property page is displayed, along with tabs for other property pages. If the cache is stopped, only the General page is displayed. If Oracle Database Cache is not running on the node or the node is not reachable, the General property page will appear dimmed and no other property pages will be shown.
For detailed information about each property page, dialog box, and wizard, see the online Help.
The caches were created when you installed Oracle Database Cache. Now, you use Cache Manager to specify which data and PL/SQL objects are cached in which middle-tier caches and the synchronization policy for each table in the caches.
Cache Manager provides the Add Wizard, which lets you set up and populate one or more caches at the same time. With the wizard, you can add tables and PL/SQL objects to one or more caches and specify the synchronization policy for each table.
When you are setting up your Oracle Database Cache environment for the first time, consider using the Add Wizard to set up one cache. Then, verify and test that you set up the cache in the best way for your environment. When you are satisfied with the setup, you can easily copy it to other caches. The following sections describe how to use this method.
If you accepted the default value for the amount of disk space allocated to the cache, you should consider increasing the amount of disk space before you add tables to the caches. The following section describes how to add disk space.
If you accepted the default value for the amount of disk space allocated to the cache and you plan to cache a large amount of data, you may need to increase the disk space allocated to the cache.
You can increase the amount of disk space available for a cache in the following ways:
Note that performance improves if you allocate the disk space in large amounts. That is, performance is better if you allocate disk space using a few large files rather than many smaller files.
To modify the amount of disk space allocated to a cache, take the following steps to invoke the Change Allocated Disk Space dialog box:
To increase the amount of disk space allocated to a cache by adding a new file, take the following steps:
To increase the amount of disk space allocated to a cache by increasing the size of an existing file, take the following steps:
To invoke the Add Wizard, select the Caches folder from the Navigator tree and choose Object -> Add Objects to Caches. Then, take the following steps:
To cache objects in particular caches, select the caches in which you want to cache objects and click the right arrow (>) to move them from the Available Caches list to the Selected Caches list. To remove caches in which you do not want to cache objects from the Selected Caches list, select the caches and click the left arrow (<).
To check the dependencies of a table, from the Available Tables list, select the table and click the Show Dependencies icon.
From the Available Tables list, select the tables that you want to include in the caches. Click the right arrow (>) to move the tables to the Selected Tables list.
To specify the same synchronization policy for all tables, select Yes, use the same policy for every table. If any caches contain any of the tables you selected on the previous page, the wizard will not add those particular tables to those caches and will not change the synchronization policies of those tables on those caches.
To specify different synchronization policies for one or more tables, select No, let me set a different policy for some tables.
See "Deciding Synchronization Policies" for more information about synchronization policies.
Text description of the illustration addwiz_sync2.gif
You can choose one of the following:
If you choose this option, you specify the start time and the interval between synchronizations:
If you selected No, let me set a different policy for some tables, Cache Manager displays the next page, Synchronization Policy for Tables.
For those tables for which you want a different synchronization policy, take these steps:
To check the dependencies of a PL/SQL object, from the Available PL/SQL Objects list, select the table and click the Show Dependencies icon.
From the Available PL/SQL Objects list, select the PL/SQL objects that you want to include in the caches. Click the right arrow (>) to move the objects to the Selected PL/SQL Objects list.
Oracle Database Cache adds the tables, their data and their dependent objects, and the PL/SQL objects to the caches. The wizard displays a progress box that shows each operation as it completes. If an operation results in an error, the wizard displays an error in the progress box and displays the warning when it completes all operations.
To verify that you set up your cache correctly, select the cache from the Navigator tree. Cache Manager displays the property sheet for the cache. Then, take the following steps:
If you selected Incremental, Scheduled, or Complete, Scheduled, select a Synchronization Start Time. Then, enter a Synchronization Interval and select a Synchronization Unit, such as minutes, hours, days, or weeks.
To increase the disk space by increasing the size of a particular file, enter the increased size in the Size column.
"Modifying the Disk Space Allocated to a Cache" provides more information about increasing or decreasing the disk space allocated.
If the cache is set up correctly, you can enable caching and test the cache.
To enable routing of queries, including PL/SQL subprograms (procedures and functions) and anonymous blocks, to the middle-tier cache, take the following steps:
Oracle Database Cache starts the middle-tier cache and enables routing of queries, including PL/SQL subprograms and anonymous blocks, to the cache.
You can disable the routing of PL/SQL subprograms and anonymous blocks by using the DBMS_ICACHE.SET_FLAG procedure. See "SET_FLAG Procedure" for more information.
Now you can test the cache to see that you cached the appropriate tables and that you specified appropriate amounts of disk and memory. For information about monitoring caches, see Chapter 3.
If the cache is set up correctly, you can copy the setup to other middle-tier caches.
If you have set up one cache and want to duplicate those cache settings to other nodes, you can easily do so using the Copy Cached Objects dialog box:
Repeat the steps outlined in "Verifying Your Cache Setup" to verify that these caches are set up correctly.
To configure your application environment to use Oracle Database Cache, you must set the environment variable ORA_OCI_CACHE and you must ensure that your applications are using the Oracle home in which Oracle Database Cache is installed.
You set the environment variable ORA_OCI_CACHE to the value "1" in the environment from which your application is invoked. All applications invoked from this environment take advantage of Oracle Database Cache.
For example, on UNIX, you use a shell environment variable; on Windows NT, you use an environment variable.
If ORA_OCI_CACHE is not set, applications will not use Oracle Database Cache. (For this release, if you set the environment variable to a value other than "1", caching will be enabled, although only the value "1" will be supported in future releases.)
See "Controlling Which Applications Use Oracle Database Cache" if you use applications that directly call OCI functions and you want to exercise greater control over which applications use Oracle Database Cache.
You must also make sure that your applications are using the Oracle home in which Oracle Database Cache is installed, including OCI libraries from that Oracle home. For example, on UNIX, set the value of the environment variable ORACLE_HOME to the Oracle home for Oracle Database Cache. Set the value of the environment variable LD_LIBRARY_PATH so that the Oracle Database Cache library directory ($ORACLE_HOME/lib) precedes other Oracle library directories.
On Windows NT, from the Start menu, select Oracle for Windows NT -> Oracle Home Selector. Then, select the Oracle home in which you installed Oracle Database Cache. Set the value of the environment variable PATH so that the Oracle Database Cache library directory (ORACLE_HOME\lib) precedes other Oracle library directories.
For more information about using the Oracle home and libraries for Oracle Database Cache, see the installation guide.
|
Copyright © 2001 Oracle Corporation. All Rights Reserved. |
|