Create Metadata Files and a Kubernetes Facility

The following metadata files 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. 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.

  • 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.

  • 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.

  • 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.

  • 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_grid schema user was created in the Oracle Database, and this user is not the TimesTen cache manager user, you must create the TimesTen oratt_grid 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, use these metadata files for TimesTenScaleout objects:

  • *.connect: A file with the .connect extension signifies a direct connectable that is used for direct mode access to a database in TimesTen Scaleout. The * prefix is the name you choose for the connectable. You can define more than one. See *.connect.

  • *.csconnect: A file with the .csconnect extension signifies a client/server connectable that is used for client/server access to a database in TimesTen Scaleout. The * prefix is the name you choose for the connectable. You can define more than one. See *.csconnect.

  • adminUser (Optional): The user in this file is created in the TimesTen databases and is granted ADMIN privileges. See adminUser 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.

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_cachegrid subdirectory.
    mkdir -p cm_cachegrid
  2. Change to the cm_cachegrid directory.
    cd cm_cachegrid
  3. Create the adminUser file in this ConfigMap directory.
    vi adminUser
    
    adminuser_grid/adminuserpwd
  4. Create the db.ini file in this ConfigMap directory. 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. In this example, create the oratt_grid user. Recall that this user was previously created in the Oracle Database. See Create the Oracle Database Users for information on the oratt_grid user in the Oracle Database.
    vi schema.sql
    
    create user oratt_grid identified by ttpwd;
    grant admin to oratt_grid;
  6. Create the cacheUser metadata file in this ConfigMap directory. The cacheUser file must contain one line of the form cacheuser_grid/ttpassword/orapassword, where cacheuser_grid 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 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 cacheuser_grid user with password of oraclepwd was already created in the Oracle Database. Therefore, supply cacheuser_grid as the TimesTen cache manager user. You can assign any TimesTen password to this TimesTen cache manager user. This example assigns ttpwd.

    vi cacheuser_grid
    
    cacheuser_grid/ttpwd/oraclepwd
  7. Create the cachegroups.sql metadata file in this ConfigMap directory. The cachegroups.sql file contains the cache group definitions. In this example, a read-only cache group is created. In addition, the LOAD CACHE GROUP statement is included to load rows from the oratt_grid.readtab table in the Oracle Database into the oratt_grid.readtab cache table in the TimesTen database.
    vi cachegroups.sql
    
    CREATE READONLY CACHE GROUP readcache
    AUTOREFRESH
      INTERVAL 5 SECONDS
    FROM oratt_grid.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.
    vi tnsnames.ora
    
    OraTest =   
     (DESCRIPTION = 
       (ADDRESS = (PROTOCOL = TCP)(HOST = database.mynamespace.svc.cluster.local)
         (PORT = 1521))     
       (CONNECT_DATA =       
         (SERVER = DEDICATED)       
         (SERVICE_NAME = OraTest.my.sample.com)))
    OraCache =  
     (DESCRIPTION =   
       (ADDRESS = (PROTOCOL = TCP)(HOST = database.mynamespace.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.
    vi sqlnet.ora
    
    
    NAME.DIRECTORY_PATH= {TNSNAMES, EZCONNECT, HOSTNAME}
    SQLNET.EXPIRE_TIME = 10
    SSL_VERSION = 1.2
  10. Create the direct connectable.
    vi cachegriddirect.connect
    
    ConnectionCharacterSet=AL32UTF8
  11. Create the client/server connectable.
    vi cachegridclient.csconnect
    
    ConnectionCharacterSet=AL32UTF8
    TTC_Timeout=30
  12. (Optional): Use the Linux ls command to verify the metadata files are in the ConfigMap directory.
    ls
    The output is the following.
    adminUser                  cachegroups.sql  schema.sql
    cachegridclient.csconnect  cacheUser        sqlnet.ora
    cachegriddirect.connect    db.ini           tnsnames.ora
  13. Create the ConfigMap.

    In this example:

    • The name of the ConfigMap is cachegrid. Replace cachegrid with a name of your choosing.

    • This example uses cm_cachegrid as the directory for the ConfigMap files. If you use a different directory, replace cm_cachegrid with the name of your directory.

    kubectl create configmap cachegrid --from-file .

    The files in the cm_cachegrid directory are included in the ConfigMap and, later, will be available in the TimesTen containers.

  14. Use the kubectl describe command to verify the contents of the ConfigMap.
    kubectl describe configmap cachegrid
    The output is the following.
    Name:         cachegrid
    Namespace:    mynamespace
    Labels:       <none>
    Annotations:  <none>
    
    Data
    ====
    cachegroups.sql:
    ----
    CREATE READONLY CACHE GROUP readcache
    AUTOREFRESH
      INTERVAL 5 SECONDS
    FROM oratt_grid.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
    
    sqlnet.ora:
    ----
    NAME.DIRECTORY_PATH= {TNSNAMES, EZCONNECT, HOSTNAME}
    SQLNET.EXPIRE_TIME = 10
    SSL_VERSION = 1.2
    
    
    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)))
    
    adminUser:
    ----
    adminuser_grid/adminuserpwd
    
    cachegridclient.csconnect:
    ----
    ConnectionCharacterSet=AL32UTF8
    TTC_Timeout=30
    
    cachegriddirect.connect:
    ----
    ConnectionCharacterSet=AL32UTF8
    
    cacheUser:
    ----
    cacheuser_grid/ttpwd/oraclepwd
    
    schema.sql:
    ----
    create user oratt_grid identified by ttpwd;
    grant admin to oratt_grid;
    
    Events:  <none>
    

You successfully created and deployed the cachegrid ConfigMap.