3 Setting Up a Caching Infrastructure

The following sections describe the tasks for setting up the TimesTen and Oracle Database systems before you can start caching Oracle Database data in a TimesTen database:

Configuring your system to cache Oracle Database data in TimesTen

TimesTen Application-Tier Database Cache supports the following Oracle Database Server releases:

  • Oracle 11g Release 2 (11.2.0.2.0 or above)

  • Oracle 11g Release 1 (11.1.0.7.0 or above)

  • Oracle 10g Release 2 (10.2.0.5.0 or above)

Configure the environment variables for your particular operating system, as described in "TimesTen Application-Tier Database Cache environment variables for UNIX" or "TimesTen Application-Tier Database Cache environment variables for Microsoft Windows".

Then, install TimesTen as described in Oracle TimesTen In-Memory Database Installation Guide.

Note:

From a product perspective, "TimesTen Application-Tier Database Cache" is used interchangeably with "TimesTen" because the TimesTen Application-Tier Database Cache product option includes the Oracle TimesTen In-Memory Database.

TimesTen does not support Oracle Name Server for Windows clients.

TimesTen Application-Tier Database Cache environment variables for UNIX

The shared library search path environment variable such as LD_LIBRARY_PATH or SHLIB_PATH must include the TimesTen_install_dir/lib directory.

For more information, see "Shared library path environment variable" in Oracle TimesTen In-Memory Database Installation Guide.

The PATH environment variable must include the TimesTen_install_dir/bin directory.

In the following example, TimesTen is installed in the /timesten/myinstance directory:

LD_LIBRARY_PATH=/timesten/myinstance/lib
PATH=/timesten/myinstance/bin

TimesTen Application-Tier Database Cache environment variables for Microsoft Windows

The PATH system environment variable must include the following directories:

  • Oracle_install_dir\bin

  • TimesTen_install_dir\lib

  • TimesTen_install_dir\bin

In the following example, Oracle Database is installed in the C:\oracle\ora112 directory and TimesTen is installed in the C:\timesten\myinstance directory:

PATH=C:\oracle\ora112\bin;C:\timesten\myinstance\lib;C:\timesten\myinstance\bin

Configuring the Oracle database to cache data in TimesTen

The following sections describe the tasks that must be performed on the Oracle database by the sys user:

Create the Oracle database users

You must create a default tablespace and a user timesten that is to own the Oracle Database tables that store information about cache operations.

Create or designate a default tablespace for the timesten user, which is passed as an argument to the initCacheGlobalSchema.sql script. This tablespace is used for storing TimesTen Application-Tier Database Cache management objects that should not be shared with other applications. While you may also store Oracle base tables that are cached in TimesTen, we strongly recommend that this tablespace be used solely by TimesTen for cache management.

Execute the SQL*Plus script TimesTen_install_dir/oraclescripts/initCacheGlobalSchema.sql, which creates:

  • The timesten user

  • The Oracle Database tables owned by the timesten user to store information about the cache environment, including a cache grid if one is configured

  • The TT_CACHE_ADMIN_ROLE role that defines privileges on these Oracle Database tables

See "Managing a caching environment with Oracle Database objects" for a list of Oracle Database tables owned by the timesten user.

Example 3-1 Creating the timesten user and its tables

In the following SQL*Plus example, the default tablespace that is created for the timesten user is cachetblsp.

% cd TimesTen_install_dir/oraclescripts
% sqlplus sys as sysdba
Enter password: password
SQL> CREATE TABLESPACE cachetblsp DATAFILE 'datfttuser.dbf' SIZE 100M;
SQL> @initCacheGlobalSchema "cachetblsp"

Create or designate one or more users to own Oracle Database tables that are to be cached in a TimesTen database. These users are the schema users. These may be existing users or new users. The tables to be cached may or may not already exist.

Example 3-2 Creating a schema user

As the sys user, the following SQL*Plus example creates a schema user oratt.

SQL> CREATE USER oratt IDENTIFIED BY oracle;

Next, you must create a user that creates, owns, and maintains Oracle Database objects that store information used to manage the cache environment (including a cache grid if one is configured) for a TimesTen database and enforce predefined behaviors of particular cache group types. We refer to this user as the cache administration user.

Note:

Each TimesTen database can be managed by only a single cache administration user on the Oracle database. However, a single cache administration user can manage multiple TimesTen databases. You can specify one or more cache administration users where each manages one or more TimesTen databases.

For more details, see "Caching the same Oracle table on two or more TimesTen databases".

Designate the tablespace that was created for the timesten user as the default tablespace for the cache administration user. This user creates tables in this tablespace that are used to store information about the cache environment and its cache groups. Other Oracle Database objects (such change log tables, replication metadata tables, and triggers) are used to enforce the predefined behaviors of autorefresh cache groups and AWT cache groups are created in the same tablespace. To create and manage these objects, the cache administration user must have a high level of privileges.

Note:

If you create multiple cache administration users, each may use the same or different tablespace as their default tablespace.

See "Managing a caching environment with Oracle Database objects" for a list of Oracle Database tables and triggers owned by the cache administration user.

Note:

An autorefresh cache group refers to a read-only cache group or a user managed cache group that uses the AUTOREFRESH MODE INCREMENTAL cache group attribute.

Example 3-3 Creating the cache administration user

As the sys user, create a cache administration user cacheuser. In the following example, the default tablespace for the cacheuser user is cachetblsp.

Use SQL*Plus to create the cache administration user:

SQL> CREATE USER cacheuser IDENTIFIED BY oracle
  2  DEFAULT TABLESPACE cachetblsp QUOTA UNLIMITED ON cachetblsp;

Grant privileges to the Oracle database users

The cache administration user must be granted a high level of privileges depending on the cache group types created and the operations performed on these cache groups. You can run the SQL*Plus script TimesTen_install_dir/oraclescripts/grantCacheAdminPrivileges.sql as the sys user to grant the cache administration user the minimum set of privileges required to perform cache grid and cache group operations. For more information on this SQL script, see "Automatically create Oracle Database objects used to manage data caching".

The entire list of privileges required for this user for each cache operation are listed in the first column of Table A-1 that is detailed in "Required privileges for the cache administration user and the cache manager user".

Automatically create Oracle Database objects used to manage data caching

TimesTen can automatically create Oracle Database objects owned by the cache administration user, such as cache and replication metadata tables, change log tables, and triggers when particular cache environment, cache group, and cache grid operations are performed. Some of these objects are used to store information about TimesTen databases that are associated with a particular cache grid. Other objects are used to enforce the predefined behaviors of autorefresh cache groups and AWT cache groups.

These Oracle Database objects are automatically created if the cache administration user has been granted the required privileges by running the SQL*Plus script TimesTen_install_dir/oraclescripts/grantCacheAdminPrivileges.sql as the sys user. The set of required privileges include CREATE SESSION, RESOURCE, CREATE ANY TRIGGER, and the TT_CACHE_ADMIN_ROLE role. The cache administration user name is passed as an argument to the grantCacheAdminPrivileges.sql script.

Note:

Alternatively, you can manually create these objects as described in "Manually create Oracle Database objects used to manage data caching" before performing any cache grid or cache group operations if, for security purposes, you do not want to grant the RESOURCE or CREATE ANY TRIGGER privileges to the cache administration user required to automatically create these tables and triggers.

In addition to the privileges granted to the cache administration user by running the grantCacheAdminPrivileges.sql script, this user may also need to be granted privileges such as SELECT or INSERT on the cached Oracle Database tables depending on the types of cache groups you create, and the operations that you perform on the cache groups and their cache tables. See Table A-1 for a complete list of privileges that need to be granted to the cache administration user in order to perform particular cache grid, cache group, and cache table operations.

Example 3-4 Granting privileges to automatically create Oracle Database objects

As the sys user, run the grantCacheAdminPrivileges.sql script to grant privileges to the cache administration user to automatically create Oracle Database objects used to manage caching Oracle Database data in a TimesTen database. In the following example, the cache administration user name is cacheuser.

Use SQL*Plus to run the grantCacheAdminPrivileges.sql script:

SQL> @grantCacheAdminPrivileges "cacheuser"
SQL> exit

For example, with autorefresh cache groups, the Oracle Database objects used to enforce the predefined behaviors of these cache group types are automatically created if the objects do not already exist and one of the following occurs:

  • The cache group is created with its autorefresh state set to PAUSED or ON.

  • The cache group is created with its autorefresh state set to OFF and then altered to either PAUSED or ON.

Manually create Oracle Database objects used to manage data caching

The cache administration user requires the RESOURCE privilege to automatically create the Oracle Database objects used to:

  • Store information about TimesTen databases that are associated with a particular cache environment, including a cache grid if one is configured.

  • Enforce the predefined behaviors of autorefresh cache groups. In this case, the cache administration user also requires the CREATE ANY TRIGGER privilege to automatically create these Oracle Database objects.

  • Enforce the predefined behaviors of AWT cache groups.

For security purposes, if you do not want to grant the RESOURCE and CREATE ANY TRIGGER privileges to the cache administration user required to automatically create the Oracle Database objects, you can manually create these objects.

To manually create the Oracle Database tables and triggers used to enforce the predefined behaviors of particular cache group types, run the SQL*Plus script TimesTen_install_dir/oraclescripts/initCacheAdminSchema.sql as the sys user. These objects must be created before you can create autorefresh cache groups and AWT cache groups. The cache administration user name is passed as an argument to the initCacheAdminSchema.sql script.

The initCacheAdminSchema.sql script also grants a minimal set of required privileges including CREATE SESSION and the TT_CACHE_ADMIN_ROLE role to the cache administration user. In addition to the privileges granted to the cache administration user by running the initCacheAdminSchema.sql script, this user may also need to be granted privileges such as SELECT or INSERT on the cached Oracle Database tables depending on the types of cache groups you create and the operations that you perform on the cache groups and their cache tables. See Table A-1 for a complete list of privileges that need to be granted to the cache administration user in order to perform particular cache grid, cache group, and cache table operations.

To manually create the Oracle Database tables used to store information about TimesTen databases that are associated with a particular cache grid, run the SQL*Plus script TimesTen_install_dir/oraclescripts/initCacheGridSchema.sql as the sys user. These tables must be created before you can create a cache grid. The cache administration user name and the name of the cache grid that you create are passed as arguments to the initCacheGridSchema.sql script.

Example 3-5 Manually creating Oracle Database objects used to manage caching data

As the sys user, run the initCacheAdminSchema.sql script to manually create Oracle Database objects used to enforce the predefined behaviors of autorefresh cache groups and AWT cache groups, and grant a limited set of privileges to the cache administration user. Then, run the initCacheGridSchema.sql script to manually create Oracle Database objects used to store information about TimesTen databases associated with a particular cache grid. In the following example, the cache administration user name is cacheuser and the cache grid name is ttGrid.

Use SQL*Plus to run the initCacheAdminSchema.sql and initCacheGridSchema.sql scripts:

SQL> @initCacheAdminSchema "cacheuser"
SQL> @initCacheGridSchema "cacheuser" "ttGrid"
SQL> exit

Other Oracle Database objects associated with Oracle Database tables that are cached in an autorefresh cache group are needed to enforce the predefined behaviors of these cache group types. See "Manually creating Oracle Database objects for autorefresh cache groups" for details about how to create these additional objects after you create the cache group.

To view a list of the Oracle Database objects created and used by TimesTen to manage the caching of Oracle Database data, execute the following query in SQL*Plus as the sys user:

SQL> SELECT owner, object_name, object_type FROM all_objects WHERE object_name 
  2  LIKE 'TT\___%' ESCAPE '\';

The query returns a list of tables, indexes, and triggers owned by either the timesten user or the cache administration user.

Configuring a TimesTen database to cache Oracle Database data

The following sections describe the operations that must be performed on the TimesTen database by the instance administrator or the cache manager user:

Define a DSN for the TimesTen database

A TimesTen database that caches data from an Oracle database can be referenced by either a system DSN or a user DSN. See "Managing TimesTen Databases" in Oracle TimesTen In-Memory Database Operations Guide for more information about creating TimesTen DSNs.

When creating a DSN for a TimesTen database that caches data from an Oracle database, pay special attention to the settings of the following connection attributes. All of these connection attributes can be set in a Data Manager DSN or a connection string, unless otherwise stated.

  • PermSize specifies the allocated size of the database's permanent region in MB. Set this value to at least 32 MB.

  • OracleNetServiceName must be set to the net service name of the Oracle database instance.

    On Microsoft Windows systems, the net service name of the Oracle database instance is specified in the Oracle Net Service Name field of the TimesTen Cache tab within the TimesTen ODBC Setup dialog box.

  • DatabaseCharacterSet must be set to the Oracle database character set.

    You can determine the Oracle database character set by executing the following query in SQL*Plus as any user:

    SQL> SELECT value FROM nls_database_parameters
       2 WHERE parameter='NLS_CHARACTERSET';
    
  • UID specifies the name of a cache user, such as the cache manager user, that has the same name as a companion Oracle Database user who can access the cached Oracle Database tables. The UID connection attribute can be specified in a Data Manager DSN, a client DSN, or a connection string.

  • PWD specifies the password of the TimesTen user specified in the UID connection attribute. The PWD connection attribute can be specified in a Data Manager DSN, a client DSN, or a connection string.

  • OraclePWD specifies the password of the companion Oracle Database user that has the same name as the TimesTen user specified in the UID connection attribute and can access the cached Oracle Database tables.

    Note:

    See "Create the TimesTen users" for more details on the cache manager user and its companion Oracle Database user.
  • PassThrough can be set to control whether statements are to be executed in the TimesTen database or passed through to be executed in the Oracle database. See "Setting a passthrough level".

  • LockLevel must be set to its default of 0 (row-level locking) because TimesTen Application-Tier Database Cache does not support database-level locking.

  • TypeMode must be set to its default of 0 (Oracle Database type mode).

  • ReplicationApplyOrdering and CacheAWTParallelism control parallel propagation of changes to TimesTen cache tables in an AWT cache group to the corresponding Oracle Database tables. See "Configuring parallel propagation to Oracle Database tables".

  • CacheGridEnable configures whether you will create a cache grid to manage global cache groups. Set to 0 if you are not planning on using a cache grid; set to 1 if you are planning on using a cache grid.

Example 3-6 DSN for a TimesTen database that caches data from an Oracle database

The following example is the definition of the cachealone1 DSN that references the first standalone TimesTen database that becomes a member of the ttGrid cache grid:

[cachealone1]
DataStore=/users/OracleCache/alone1
PermSize=64
OracleNetServiceName=orcl
DatabaseCharacterSet=WE8ISO8859P1
CacheGridEnable=1

Create the TimesTen users

First, you must create a user who performs cache grid (if one is configured) and cache group operations. We refer to this user as the cache manager user. The TimesTen cache manager user must have the same name as a companion Oracle Database user that can access the cached Oracle Database tables. For example, the companion Oracle Database user must have privileges to select from and update the cached Oracle Database tables. The companion Oracle Database user can be the cache administration user, a schema user, or some other existing user. For ease of use, making the cache administration user be the companion Oracle Database user of the cache manager user is preferable; however, if you are concerned with the high level of privileges assigned to the cache administration user, then choose another Oracle Database user as the companion Oracle user. The password of the cache manager user can be different than the password of the companion Oracle Database user with the same name.

Note:

You can create multiple cache manager users on a TimesTen database, such as one for each TimesTen DBA. However, you can only define a single cache administration user on the Oracle database for this particular TimesTen database. (You can use the same cache administration user for all TimesTen databases that connect to the Oracle database or define a separate cache administration user for each TimesTen database.) If you create multiple cache manager users, one or more of these users can use the cache administration user as its companion Oracle user.

The cache manager user creates and configures the cache grid, if one is configured, and creates the cache groups. It may perform operations such as loading or refreshing a cache group although these operations can be performed by any TimesTen user that has sufficient privileges. The cache manager user can also monitor various aspects of the caching environment, such as the grid itself or asynchronous operations that are performed on cache groups such as autorefresh.

Then, you must create a user with the same name as an Oracle Database schema user for each schema user who owns or will own Oracle Database tables to be cached in the TimesTen database. We refer to these users as cache table users, because the TimesTen cache tables are to be owned by these users. Therefore, the owner and name of a TimesTen cache table is the same as the owner and name of the corresponding cached Oracle Database table. The password of a cache table user can be different than the password of the Oracle Database schema user with the same name.

Operations on a cache group or a cache table, such as loading a cache group or updating a cache table, can be performed by any TimesTen user that has sufficient privileges. In the examples throughout this guide, the cache manager user performs these types of operations although these operations can be performed by another user, such as a cache table user, that has the required privileges. If these operations are to be performed by a TimesTen user other than the cache manager user, the other user must have the same name as a companion Oracle Database user that can select from and update the cached Oracle Database tables. Connect to the TimesTen database specifying that user's name in the UID connection attribute, and supply the corresponding TimesTen and Oracle Database passwords in the PWD and OraclePWD connection attributes, respectively, to perform operations on a cache group or cache table.

Example 3-7 Creating the TimesTen users

In the following ttIsql utility example, create the TimesTen database by connecting to the cachealone1 DSN as the instance administrator. Then create the cache manager user cacheuser whose name, in this example, is the same as the cache administration user, who will also act as the cache manager's companion Oracle user. Then, create a cache table user oratt whose name is the same as the Oracle Database schema user who is to own the Oracle Database tables to be cached in the TimesTen database.

% ttIsql cachealone1
Command> CREATE USER cacheuser IDENTIFIED BY timesten;
Command> CREATE USER oratt IDENTIFIED BY timesten;

Grant privileges to the TimesTen users

The privileges that the TimesTen users require depend on the types of cache groups you create and the operations that you perform on the cache groups. All of the privileges required for the TimesTen cache manager user for each cache operation are listed in the second column in Table A-1.

Example 3-8 Granting privileges to the cache manager user

The cacheuser cache manager user requires privileges to perform the following operations:

  • Set the cache administration user and password (CACHE_MANAGER).

  • Create and associate the TimesTen database with a cache grid (CACHE_MANAGER).

  • Start the cache agent and replication agent processes on the TimesTen database (CACHE_MANAGER).

  • Attach the TimesTen database to the cache grid (CACHE_MANAGER).

  • Create cache groups to be owned by the cache manager user (CREATE CACHE GROUP, inherited by the CACHE_MANAGER privilege; CREATE ANY TABLE to create the underlying cache tables which are to be owned by the oratt cache table user).

As the instance administrator, use the ttIsql utility to grant the cacheuser cache manager user the required privileges:

Command> GRANT CREATE SESSION, CACHE_MANAGER, CREATE ANY TABLE TO cacheuser;
Command> exit

Set the cache administration user name and password

You must set the cache administration user name and password in the TimesTen database before any cache grid or cache group operation can be issued with the ttCacheUidPwdSet built-in procedure. The cache agent connects to the Oracle database as this user to create and maintain Oracle Database objects that store information used to manage a cache grid and enforce predefined behaviors of particular cache group types. In addition, both the cache and replication agents connect to the Oracle database with the credentials set with the ttCacheUidPwdSet built-in procedure to manage Oracle database operations.

Note:

When you connect to the TimesTen database to work with AWT or read-only cache groups, TimesTen uses the credentials set with the ttCacheUidPwdSet built-in procedure when connecting to the Oracle database on behalf of these cache groups.

When you connect to the TimesTen database to work with SWT or user managed cache groups or passthrough operations, TimesTen connects to the Oracle database using the current user's credentials as the user name and the OraclePwd connection attribute as the Oracle password. Thus, the correct user name and Oracle database password that should be used for connecting to the Oracle database must be set correctly in the connection string or with the connection attributes.

The cache administration user name and password need to be set only once in each TimesTen database that caches Oracle Database data unless it needs to be changed. For example, if you modify the password of the cache administration user, if the TimesTen database is destroyed and re-created, or if the cache administration user name is dropped and re-created in the Oracle database, the cache administration user name and password must be set again.

The cache administration user name cannot be changed if there are cache groups in the database. The cache groups must be dropped before you can drop and recreate the cache administration user. See "Changing cache user names and passwords" for more details.

Example 3-9 Setting the cache administration user name and password

The cache administration user name and password can be set programmatically by calling the ttCacheUidPwdSet built-in procedure after connecting as the cache manager user:

% ttIsql "DSN=cachealone1;UID=cacheuser;PWD=timesten;OraclePWD=oracle"
Command> call ttCacheUidPwdSet('cacheuser','oracle');

It can also be set from a command line by running a ttAdmin -cacheUidPwdSet utility command as a TimesTen external user with the CACHE_MANAGER privilege:

% ttAdmin -cacheUidPwdSet -cacheUid cacheuser -cachePwd oracle cachealone1

If you do not specify the -cachePwd option, the ttAdmin utility prompts for the cache administration user's password.

For more information about the utility, see "ttAdmin" in Oracle TimesTen In-Memory Database Reference.

Configuring data management

You can configure how TimesTen manages cached data either locally in a single TimesTen database or globally across multiple TimesTen in-memory databases.

  • Manage data locally, where each TimesTen in-memory database operates separately from other TimesTen in-memory databases. While this option is simpler, TimesTen does not manage data coherence across all TimesTen in-memory databases. For more details, see "Managing data locally".

  • Manage data globally across multiple TimesTen in-memory databases with a cache grid. This is the default method. A cache grid is a collection of TimesTen Cache databases that collectively manage application data located within global cache groups. A cache grid contains a set of distributed TimesTen in-memory databases that work together to cache data from an Oracle database and guarantee cache coherence for global cache groups located on these TimesTen databases. See "Configuring a cache grid" for more information.

Managing data locally

If you are not planning to use global cache groups, you do not need to create a cache grid. In this case, set the CacheGridEnable connection attribute to 0, which can be configured in the DSN as described in "Define a DSN for the TimesTen database".

This connection attribute states that you will not use global cache groups. Once set, TimesTen does not require you to create a cache grid or associate the TimesTen database with the grid before cache groups can be created within that database.

Note:

While you may have multiple TimesTen in-memory databases that interact with the same Oracle database, they will each operate independently. Thus, any data cached in separate TimesTen databases will each interact with the Oracle database independently.

Use a cache grid if you want to scale data across several TimesTen databases with read and write data consistency and predictable latency for their database transactions.

With this option, you cannot create global cache groups within that database. If, at some point in the future, you decide to use global cache groups within a cache grid, perform the following:

  1. Drop all existing cache groups.

  2. Create the cache grid and associate the TimesTen in-memory database as a member, as described in "Overview of a cache grid".

  3. Recreate all pre-existing cache groups.

See "Global cache groups" for more information about global cache groups.

Configuring a cache grid

An Oracle Database table cannot be cached in separate cache groups within the same TimesTen database. However, the table can be cached in separate cache groups within different TimesTen databases.

A TimesTen cache grid provides users with Oracle databases a means to horizontally scale out cache groups across multiple systems with read and write data consistency across the TimesTen databases and predictable latency for database transactions. A cache grid contains one or more grid members that collectively manage application data using the relational data model. A grid member is either a standalone TimesTen database or an active standby pair that consists of at least two replicated TimesTen databases.

Each database of a grid member is called a grid node. A node is a single TimesTen database that is either a standalone database, or the active database or standby database of an active standby pair. Therefore, a grid member is composed of one or two nodes.

Note:

See "Administering an Active Standby Pair with Cache Groups" in Oracle TimesTen In-Memory Database Replication Guide for more information about replicating cache tables.

Grid members can reside on the same system or on different systems. If the grid members reside across different systems, the systems must be connected to each other in a TCP/IP private network. Each system must have the same machine architecture, operating system version, platform, and bit version. The TimesTen major release number of all grid members must be the same.

A TimesTen database that is or is part of a grid member can contain local and global cache groups as well as explicitly loaded and dynamic cache groups.

Note:

See "Dynamic cache groups" for more information about dynamic cache groups.

See "Global cache groups" for more information about global cache groups.

A cache grid can be associated with only one Oracle database. A TimesTen database can be a member of only one cache grid. An Oracle database can be associated with more than one cache grid and each grid can be administered by a different cache administration user. A cache grid has no association with other cache grids.

The following sections describe the operations that must be performed on the TimesTen database by the cache manager user:

Modify the PROCESSES system parameter for ten or more grid nodes

If you are planning a grid with ten or more nodes, modify the PROCESSES Oracle Database system parameter. Use this guideline:

PROCESSES >= 10*GridMembers + DLConnections + OraBackgroundProcesses

where:

  • GridMembers = number of grid members

  • DLConnections = number of dynamic load connections

  • OraBackgroundProcesses = number of Oracle Database background processes

The number of dynamic load connections is determined by how many sessions are to have dynamic cache group operations.

For more information about modifying an Oracle Database system parameter, see "Changing Parameter Values in a Parameter File" in Oracle Database Reference. For more information about Oracle Database background processes, see "Background Processes" in Oracle Database Reference.

Create a cache grid

The examples in the rest of this guide create a cache grid ttGrid that contains three grid members: two standalone TimesTen databases and an active standby pair consisting of three TimesTen databases. This chapter shows how to associate one of the standalone databases with the cache grid. Subsequent chapters show how to create the other standalone database and the active standby pair, and how to associate those members with the grid.

See Example 3-6 for the DSN definition of the first standalone TimesTen database.

You can create a cache grid from any of the standalone databases, or from either the active or standby database of the active standby pair. A cache grid is created only once from any one of the grid members.

Example 3-10 Creating a cache grid

Create the ttGrid cache grid from the first standalone database by calling the ttGridCreate built-in procedure as the cache manager user:

Command> call ttGridCreate('ttGrid');

All the databases in these examples, except for the read-only subscriber database of the active standby pair, are associated with the ttGrid cache grid.

If you manually created the Oracle Database objects used to store information about TimesTen databases that are associated with a particular cache grid as described in "Manually create Oracle Database objects used to manage data caching", you do not need to call ttGridCreate because the grid, in effect, was created by running the initCacheGridSchema.sql script.

You can associate a TimesTen database with a cache grid before creating cache groups in the database. If you do not want to use a cache grid, you can set the CacheGridEnable connection attribute to 0 so that you do not have to create a cache grid and associate the TimesTen database with the grid before cache groups can be created within that database.

See "Global cache groups" for more information about global cache groups.

CacheGridEnable is set to 1 by default.

Associate a TimesTen database with a cache grid

All standalone databases, and the active and standby databases of the active standby pair must be associated with a cache grid before you can create cache groups within those databases.

Example 3-11 Associating a TimesTen database with a cache grid

Associate the first standalone database to the ttGrid cache grid by calling the ttGridNameSet built-in procedure as the cache manager user:

Command> call ttGridNameSet('ttGrid');

Testing the connectivity between the TimesTen and Oracle databases

To test the connectivity between the TimesTen and Oracle databases, set the passthrough level to 3 and execute the following query, to be processed on the Oracle database, as the cache manager user:

Command> passthrough 3;
Command> SELECT * FROM V$VERSION;
Command> passthrough 0;

If connectivity has been successfully established, the query returns the version of the Oracle database. If it does not, check the following for correctness:

  • The Oracle Net service name set in the OracleNetServiceName connection attribute and the state of the Oracle database server

  • The settings of the shared library search path environment variable such as LD_LIBRARY_PATH or SHLIB_PATH

  • The setting of the cache administration user name in the TimesTen database

Example 3-12 Determining the cache administration user name setting

The cache administration user name setting can be returned programmatically by calling the ttCacheUidGet built-in procedure as the cache manager user:

Command> call ttCacheUidGet;

It can also be returned from a command line by running a ttAdmin -cacheUidGet utility command as a TimesTen external user with the CACHE_MANAGER privilege:

% ttAdmin -cacheUidGet cachealone1

Managing the cache agent

The cache agent is a TimesTen process that performs cache operations such as loading a cache group and autorefresh, as well as manages Oracle Database objects used to enforce the predefined behaviors of particular cache group types.

Example 3-13 Starting the cache agent

The cache agent can be manually started programmatically by calling the ttCacheStart built-in procedure as the cache manager user:

Command> call ttCacheStart;

It can also be started from a command line by running a ttAdmin -cacheStart utility command as a TimesTen external user with the CACHE_MANAGER privilege:

% ttAdmin -cacheStart cachealone1

Example 3-14 Stopping the cache agent

The cache agent can be manually stopped programmatically by calling the ttCacheStop built-in procedure as the cache manager user:

Command> call ttCacheStop;

It can also be stopped from a command line by running a ttAdmin -cacheStop utility command as a TimesTen external user with the CACHE_MANAGER privilege:

% ttAdmin -cacheStop cachealone1

The ttCacheStop built-in procedure has an optional parameter and the ttAdmin -cacheStop utility command has an option -stopTimeout that specifies how long the TimesTen main daemon process waits for the cache agent to stop. If the cache agent does not stop within the specified timeout period, the TimesTen daemon stops the cache agent. The default cache agent stop timeout is 100 seconds. A value of 0 specifies to wait indefinitely.

Do not stop the cache agent immediately after you have dropped or altered an autorefresh cache group. Instead, wait for at least two minutes to allow the cache agent to clean up Oracle Database objects such as change log tables and triggers that were created and used to manage the cache group.

Note:

The TimesTen X/Open XA and Java Transaction API (JTA) implementations do not work with TimesTen Application-Tier Database Cache. The start of any XA or JTA transaction fails if the cache agent is running.

Set a cache agent start policy

A cache agent start policy determines how and when the cache agent process starts on a TimesTen database. The cache agent start policy can be set to:

  • manual

  • always

  • norestart

The default start policy is manual, which means the cache agent must be started manually by calling the ttCacheStart built-in procedure or running a ttAdmin -cacheStart utility command. To manually stop a running cache agent process, call the ttCacheStop built-in procedure or run a ttAdmin -cacheStop utility command.

When the start policy is set to always, the cache agent starts automatically when the TimesTen main daemon process starts. With the always start policy, the cache agent cannot be stopped when the main daemon is running unless the start policy is first changed to either manual or norestart. Then issue a manual stop by calling the ttCacheStop built-in procedure or running a ttAdmin -cacheStop utility command.

With the manual and always start policies, the cache agent automatically restarts when the database recovers after a failure such as a database invalidation. If the database was attached to a cache grid when the failure occurred, it is automatically reattached to the grid when the database recovers.

Setting the cache agent start policy to norestart means the cache agent must be started manually by calling the ttCacheStart built-in procedure or running a ttAdmin -cacheStart utility command, and stopped manually by calling the ttCacheStop built-in procedure or running a ttAdmin -cacheStop utility command.

With the norestart start policy, the cache agent does not automatically restart when the database recovers after a failure such as a database invalidation. You must restart the cache agent manually by calling the ttCacheStart built-in procedure or running a ttAdmin -cacheStart utility command. If the database was attached to a cache grid when the failure occurred, it is not automatically reattached to the grid when the database recovers. You must call the ttGridAttach built-in procedure to reattach the database to the grid.

Note:

For more details, see "ttAdmin," "ttCachePolicySet," "ttCacheStart," "ttCacheStop," and "ttGridAttach" in the Oracle TimesTen In-Memory Database Reference.

Example 3-15 Setting a cache agent start policy

The cache agent start policy can be set programmatically by calling the ttCachePolicySet built-in procedure as the cache manager user:

Command> call ttCachePolicySet('always');

It can also be set from a command line by running a ttAdmin -cachePolicy utility command as a TimesTen external user with the CACHE_MANAGER privilege:

% ttAdmin -cachePolicy norestart cachealone1