Create Replicated TimesTen Classic Databases

This example shows you how to create and deploy a replicated TimesTenClassic object in your Kubernetes namespace. It shows you how to monitor the TimesTen Operator as it uses the information in the object's definition to create an active standby pair of replicated TimesTen Classic databases.
  1. Create the YAML manifest file for the TimesTenClassic object.
    vi repsample.yaml
    
    apiVersion: timesten.oracle.com/v2
    kind: TimesTenClassic
    metadata:
      name: repsample
    spec:
      ttspec:
        storageClassName: oci-bv
        storageSize: 10Gi
        image: container-registry.oracle.com/timesten/timesten:22.1.1.27.0
        imagePullSecret: sekret
        dbConfigMap:
        - repsample
    Note the following:
    • The storageClassName is oci-bv. Replace oci-bv with the name of your storage class.

    • The storageSize is 10Gi. Replace 10Gi with the amount of storage that needs to be requested for each Pod to hold TimesTen.

    • The image is container-registry.oracle.com/timesten/timesten:22.1.1.27.0. Replace image with the name and location of your TimesTen container image.

    • The imagePullSecret is sekret. Replace sekret with the image pull secret that Kubernetes needs to use to fetch the TimesTen container image.

    • The dbConfigMap specifies the repsample ConfigMap created in About the Examples.
  2. Deploy the TimesTenClassic object into your namespace.
    kubectl create -f repsample.yaml
    The output is the following:
    timestenclassic.timesten.oracle.com/repsample created
  3. Monitor deployment.
    1. Check status of object.
      kubectl get ttc repsample

      The output is similar to the following:

      NAME          STATE              ACTIVE   AGE
      repsample     Initializing       None     9s

      The provisioning starts, but is not completed as indicated by the Initializing state.

    2. Wait a few minutes. Then, check status again.
      kubectl get ttc repsample

      The output is similar to the following:

      NAME        STATE    ACTIVE        AGE
      repsample   Normal   repsample-0   2m27s

      The provisioning process completes. The active and standby databases are up and running and operational. The TimesTen Operator transitions the repsample object to the Normal state.

  4. (Optional): Review the state transitions.
    kubectl get events

    The output is similar to the following:

    LAST SEEN   TYPE      REASON                   OBJECT                                              MESSAGE
    ...
    
    4m46s       Normal    Create                   timestenclassic/repsample                           Service repsample created
    4m46s       Warning   Warning                  timestenclassic/repsample                           Database CPU limit/request not specified
    4m46s       Normal    Create                   timestenclassic/repsample                           StatefulSet repsample created
    4m46s       Warning   Create                   timestenclassic/repsample                           PodMonitor repsample created
    3m46s       Normal    Info                     timestenclassic/repsample                           Pod repsample-0 Agent Up
    3m46s       Normal    Info                     timestenclassic/repsample                           Pod repsample-0 Release 22.1.1.27.0
    3m46s       Normal    Info                     timestenclassic/repsample                           Pod repsample-1 Agent Up
    3m46s       Normal    Info                     timestenclassic/repsample                           Pod repsample-1 Release 22.1.1.27.0
    3m46s       Normal    Info                     timestenclassic/repsample                           Pod repsample-0 Daemon Up
    3m45s       Normal    Info                     timestenclassic/repsample                           Pod repsample-1 Daemon Up
    3m30s       Normal    Info                     timestenclassic/repsample                           Pod repsample-0 Database Loaded
    3m30s       Normal    Info                     timestenclassic/repsample                           Pod repsample-0 Database Updatable
    3m29s       Normal    Info                     timestenclassic/repsample                           Pod repsample-0 RepAgent Running
    3m29s       Normal    Info                     timestenclassic/repsample                           Pod repsample-0 RepScheme Exists
    3m29s       Normal    StateChange              timestenclassic/repsample                           Pod repsample-0 RepState ACTIVE
    2m38s       Normal    Info                     timestenclassic/repsample                           Pod repsample-1 Database Loaded
    2m38s       Normal    Info                     timestenclassic/repsample                           Pod repsample-1 RepScheme Exists
    2m38s       Normal    StateChange              timestenclassic/repsample                           Pod repsample-1 RepState IDLE
    2m37s       Normal    Info                     timestenclassic/repsample                           Pod repsample-1 Database Loaded
    2m37s       Normal    Info                     timestenclassic/repsample                           Pod repsample-1 RepScheme Exists
    2m37s       Normal    StateChange              timestenclassic/repsample                           Pod repsample-1 RepState IDLE
    2m32s       Normal    Info                     timestenclassic/repsample                           Pod repsample-1 RepAgent Running
    2m32s       Normal    StateChange              timestenclassic/repsample                           Pod repsample-1 RepState STANDBY
    2m31s       Normal    StateChange              timestenclassic/repsample                           TimesTenClassic was Initializing, now Normal
    2m26s       Normal    StateChange              timestenclassic/repsample                           Pod repsample-0 is Ready
    2m26s       Normal    StateChange              timestenclassic/repsample                           Pod repsample-0 is Active Ready
    2m26s       Normal    StateChange              timestenclassic/repsample                           Pod repsample-1 is Ready

    During the provisioning process, the TimesTenClassic object transitions from the Initializing to the Normal state.

  5. Verify the existence of the underlying objects.

    1. StatefulSet:

    kubectl get statefulset repsample

    The output is similar to the following:

    NAME        READY   AGE
    repsample   1/2     7m22s

    2. Service:

    kubectl get service repsample

    The output is similar to the following:

    NAME        TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)             AGE
    repsample   ClusterIP   None         <none>        6625/TCP,8888/TCP   8m2s
    3. Pods:
    kubectl get pods
    The output is similar to the following:
    NAME                                 READY   STATUS    RESTARTS   AGE
    repsample-0                          3/3     Running   0          8m31s
    repsample-1                          2/3     Running   0          8m31s
    ...

    4. PVCs:

    kubectl get pvc

    The output is similar to the following:

    NAME                          STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
    tt-persistent-repsample-0     Bound    csi-f36b2402-9745-46bd-a023-811839ab518e   250Gi      RWO            oci-bv         8m59s
    tt-persistent-repsample-1     Bound    csi-0a0cfd59-b2bf-48b7-bdef-6ee03794891b   250Gi      RWO            oci-bv         8m59s
    
  6. Connect to the active database.
    1. From your development host, establish a shell in the Pod.
      kubectl exec -it repsample-0 -c tt -- /bin/bash
    2. Connect to the active database. Insert a row in a table.
      [timesten@repsample-0 ~]$ ttIsql repsample
      
      Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
      Type ? or "help" for help, type "exit" to quit ttIsql.
      
      
      
      connect "DSN=repsample";
      Connection successful: DSN=repsample;UID=timesten;DataStore=/tt/home/timesten/datastore/repsample;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;AutoCreate=0;PermSize=200;DDLReplicationLevel=3;ForceDisconnectEnabled=1;
      (Default setting AutoCommit=1)
      Command> select * from adminuser.emp;
      0 rows found.
      Command> describe adminuser.emp;
      
      Table ADMINUSER.EMP:
        Columns:
         *ID                              NUMBER NOT NULL
          NAME                            CHAR (32)
        PRIMARY KEY (ID) RANGE INDEX
      
      1 table found.
      (primary key columns are indicated with *)
      Command> insert into adminuser.emp values (1,'test');
      1 row inserted.
      Command> commit;
      Command> select * from adminuser.emp;
      < 1, test                             >
      1 row found.
    3. Exit from ttIsql and from the shell.
      Command> exit
      Disconnecting...
      Done.
      [timesten@repsample-0 ~]$ exit
      exit
Congratulations! You successfully created and deployed a replicated TimesTenClassic object. The replicated active standby pair of TimesTen Classic databases are up and running and fully operational.