Create Metadata Files and a Kubernetes Facility

There are metadata files that are specific to using TimesTen Cache:

  • cacheUser: This file is required. The user in this file is created in the TimesTen databases and serves as the cache manager. The name of this user must match the name of the cache administration user that you created in the Oracle Database. See "Create the Oracle Database Users" for information on the cache administration user in the Oracle Database. Also see "cacheUser" for more information on the cacheUser metadata file.

  • cachegroups.sql: This file is required. The contents of this file contain the CREATE CACHE GROUP definitions. The file can also contain the LOAD CACHE GROUP statement and the built-in procedures to update statistics on the cache group tables (such as, ttOptEstimateStats and ttOptUpdateStats). See "cachegroups.sql" for more information on this file.

  • tnsnames.ora: This file is required. It defines Oracle Net Services to which applications connect. For TimesTen Cache, this file configures the connectivity between TimesTen and the Oracle Database (from which data is being cached). In this context, TimesTen is the application that is the connection to the Oracle Database. See "tnsnames.ora" for more information on this file.

  • sqlnet.ora: This file may be required. It may be necessary depending on your Oracle Database configuration. The file defines options for how client applications communicate with the Oracle Database. In this context, TimesTen is the application. The tnsnames.ora and sqlnet.ora files together define how an application communicates with the Oracle Database. See "sqlnet.ora" for information on this file.

  • db.ini: This file is required if you are using TimesTen Cache. The contents of this file contain TimesTen connection attributes for your TimesTen databases, which will be included in TimesTen's sys.odbc.ini file. For TimesTen Cache, you must specify the OracleNetServiceName and the DatabaseCharacterSet connection attributes. The DatabaseCharacterSet connection attribute must match the Oracle database character set. See "db.ini" for more information on this file.

  • schema.sql: The contents of this file contain database objects, such as tables, sequences, and users. The instance administrator uses the ttIsql utility to run this file immediately after the database is created. This file is run before the Operator configures TimesTen Cache or replication, so ensure there are no cache definitions in this file.

    In TimesTen Cache, one or more cache table users own the cache tables. If this cache table user is not the cache manager user, then you must specify the schema.sql file and in it you must include the schema user and assign the appropriate privileges to this schema user. For example, if the oratt schema user was created in the Oracle Database, and this user is not the TimesTen cache manager user, you must create the TimesTen oratt user in this file. See "Create the Oracle Database Users" for more information on the schema users in the Oracle Database. Also see "schema.sql" for more information on the schema.sql file.

In addition, you can use these other supported metadata files:

  • adminUser: The user in this file is created in the TimesTen databases and is granted ADMIN privileges. See "adminUser" for more information on this file.

  • epilog.sql: The contents of this file contain operations that must be performed after the Operator configures replication. For example, if you are using XLA, you could create replicated bookmarks for XLA in this file. This file is run after cache and replication have been configured. See "epilog.sql" for more information on this file.

You can include these metadata files in one or more Kubernetes facilities (for example, in a Kubernetes Secret, in a ConfigMap, or in an init container). This ensures the metadata files are populated in the /ttconfig directory of the TimesTen containers. Note that there is no requirement as to how to get the metadata files into this /ttconfig directory. See "Populate the /ttconfig Directory" for more information.

This example uses the ConfigMap facility to populate the /ttconfig directory in your TimesTen containers. The adminUser, db.ini, schema.sql, cacheUser, cachegroups.sql, tnsnames.ora, and sqlnet.ora metadata files are used in this example.

On your Linux development host:

  1. From the directory of your choice, create an empty subdirectory for the metadata files. This example creates the cm_cachetest subdirectory. (The cm_cachetest directory is used in the remainder of this example to denote this directory.)
    % mkdir -p cm_cachetest
  2. Navigate to the ConfigMap directory.
    % cd cm_cachetest
  3. Create the adminUser file in this ConfigMap directory (cm_cachetest, in this example). In this adminUser file, create the sampleuser user with the samplepw password.
    vi adminUser
    
    sampleuser/samplepw
  4. Create the db.ini file in this ConfigMap directory (cm_cachetest, in this example). In this db.ini file, define the PermSize, DatabaseCharacterSet, and the OracleNetServiceName connection attributes. The DatabaseCharacterSet value must match the database character set value in the Oracle Database. See "Create the Oracle Database Tables to Be Cached" for information on how to query the nls_database_parameters system view to determine the Oracle Database database character set. In this example, the value is AL32UTF8.
    vi db.ini
    
    PermSize=200
    DatabaseCharacterSet=AL32UTF8
    OracleNetServiceName=Oracache
  5. Create the schema.sql file in this ConfigMap directory (cm_cachetest, in this example). In this example, create the oratt user. Recall that this user was previously created in the Oracle Database. See "Create the Oracle Database Users" for information on the oratt user in the Oracle Database.
    vi schema.sql
    
    create user oratt identified by ttpwd;
    grant admin to oratt;
    
  6. Create the cacheUser metadata file in this ConfigMap directory (cm_cachetest, in this example). The cacheUser file must contain one line of the form cacheuser/ttpassword/orapassword, where cacheuser is the user you wish to designate as the cache manager in the TimesTen database, ttpassword is the TimesTen password you wish to assign to this user, and orapassword is the Oracle Database password that has already been assigned to the Oracle Database cache administration user. Note that the cacheUser name in this file must match the Oracle Database cache administration user that you previously created. See "Create the Oracle Database Users" for more information on the Oracle Database cache administration user.

    In this example, the cacheuser2 user with password of oraclepwd was already created in the Oracle Database. Therefore, supply cacheuser2 as the TimesTen cache manager user. You can assign any TimesTen password to this TimesTen cache manager user. This example assigns ttpwd.

    vi cacheuser
    
    cacheuser2/ttpwd/oraclepwd
  7. Create the cachegroups.sql metadata file in this ConfigMap directory (cm_cachetest, in this example). The cachegroups.sql file contains the cache group definitions. In this example, a dynamic AWT cache group and a read-only cache group are created. In addition, the LOAD CACHE GROUP statement is included to load rows from the oratt.readtab cached table in the Oracle Database into the oratt.readtab cache table in the TimesTen database.
    vi cachegroups.sql
    
    CREATE DYNAMIC ASYNCHRONOUS WRITETHROUGH CACHE GROUP writecache
    FROM oratt.writetab (pk NUMBER NOT NULL PRIMARY KEY,attr VARCHAR2(40));
     
    CREATE READONLY CACHE GROUP readcache
    AUTOREFRESH
      INTERVAL 5 SECONDS
    FROM oratt.readtab (keyval NUMBER NOT NULL PRIMARY KEY,str VARCHAR2(32));
     
    LOAD CACHE GROUP readcache COMMIT EVERY 256 ROWS;
  8. Create the tnsnames.ora metadata file in this ConfigMap directory (cm_cachetest, in this example).
    vi tnsnames.ora
    
    OraTest =   
     (DESCRIPTION = 
       (ADDRESS = (PROTOCOL = TCP)(HOST = database.myhost.svc.cluster.local)
         (PORT = 1521))     
       (CONNECT_DATA =       
         (SERVER = DEDICATED)       
         (SERVICE_NAME = OraTest.my.sample.com)))
    OraCache =  
     (DESCRIPTION =   
       (ADDRESS = (PROTOCOL = TCP)(HOST = database.myhost.svc.cluster.local)
         (PORT = 1521))     
       (CONNECT_DATA =       
         (SERVER = DEDICATED)       
         (SERVICE_NAME = OraCache.my.sample.com)))
  9. Create the sqlnet.ora metadata file in this ConfigMap directory (cm_cachetest, in this example).
    vi sqlnet.ora
    
    NAME.DIRECTORY_PATH= {TNSNAMES, EZCONNECT, HOSTNAME}
    SQLNET.EXPIRE_TIME = 10
    SSL_VERSION = 1.2
  10. Use the Linux ls command to verify the metadata files are in the ConfigMap directory (cm_cachetest, in this example).
    % ls
    adminUser        cacheUser  schema.sql  tnsnames.ora
    cachegroups.sql  db.ini     sqlnet.ora
  11. Create the ConfigMap. The files in the cm_cachetest directory are included in the ConfigMap and, later, will be available in the TimesTen containers.

    In this example:

    • The name of the ConfigMap is cachetest. Replace cachetest with a name of your choosing. (cachetest is represented in bold in this example.)

    • This example uses cm_cachetest as the directory where the files that will be copied into the ConfigMap reside. If you use a different directory, replace cm_cachetest with the name of your directory. (cm_cachetest is represented in bold in this example.)

    Use the kubectl create command to create the ConfigMap:

    % kubectl create configmap cachetest --from-file=cm_cachetest
    configmap/cachetest created
  12. Use the kubectl describe command to verify the contents of the ConfigMap. (cachetest, in this example.) The metadata files are represented in bold.
    % kubectl describe configmap cachetest;
    Name:         cachetest
    Namespace:    mynamespace
    Labels:       <none>
    Annotations:  <none>
     
    Data
    ====
    tnsnames.ora:
    ----
    
    OraTest =   
     (DESCRIPTION = 
       (ADDRESS = (PROTOCOL = TCP)(HOST = database.myhost.svc.cluster.local)
         (PORT = 1521))     
       (CONNECT_DATA =       
         (SERVER = DEDICATED)       
         (SERVICE_NAME = OraTest.my.sample.com)))
    OraCache =  
     (DESCRIPTION =   
       (ADDRESS = (PROTOCOL = TCP)(HOST = database.myhost.svc.cluster.local)
         (PORT = 1521))     
       (CONNECT_DATA =       
         (SERVER = DEDICATED)       
         (SERVICE_NAME = OraCache.my.sample.com)))
     
    adminUser:
    ----
    sampleuser/samplepw
     
    cacheUser:
    ----
    cacheuser2/ttpwd/oraclepwd
     
    cachegroups.sql:
    ----
    CREATE DYNAMIC ASYNCHRONOUS WRITETHROUGH CACHE GROUP writecache
    FROM oratt.writetab (
      pk NUMBER NOT NULL PRIMARY KEY,
      attr VARCHAR2(40)
    );
     
    CREATE READONLY CACHE GROUP readcache
    AUTOREFRESH
      INTERVAL 5 SECONDS
    FROM oratt.readtab (
      keyval NUMBER NOT NULL PRIMARY KEY,
      str VARCHAR2(32)
    );
     
    LOAD CACHE GROUP readcache COMMIT EVERY 256 ROWS;
     
    db.ini:
    ----
    permSize=200
    databaseCharacterSet=AL32UTF8
    oracleNetServiceName=Oracache
     
    schema.sql:
    ----
    create user oratt identified by ttpwd;
    grant admin to oratt;
     
    sqlnet.ora:
    ----
    NAME.DIRECTORY_PATH= {TNSNAMES, EZCONNECT, HOSTNAME}
    SQLNET.EXPIRE_TIME = 10
    SSL_VERSION = 1.2
     
     
    Events:  <none>

You have successfully created and deployed the cachetest ConfigMap.