レプリケートされたTimesTen Classicデータベースの作成

この例では、レプリケートされたTimesTenClassicオブジェクトをKubernetesネームスペースで作成およびデプロイする方法を示します。ここでは、TimesTenオペレータはオブジェクトの定義内の情報を使用してレプリケートされたTimesTen Classicデータベースのアクティブ・スタンバイ・ペアを作成するため、これを監視する方法を示します。
  1. TimesTenClassicオブジェクトのYAMLマニフェスト・ファイルを作成します。
    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
    次の点に注目してください。
    • storageClassNameoci-bvです。oci-bvを記憶域クラスの名前に置き換えます。

    • storageSize10Giです。10Giを、各ポッドがTimesTenを保持するためにリクエストする必要がある記憶域の量に置き換えます。

    • imagecontainer-registry.oracle.com/timesten/timesten:22.1.1.27.0です。imageをTimesTenコンテナ・イメージの名前および場所に置き換えます。

    • imagePullSecretsekretです。sekretを、KubernetesがTimesTenコンテナ・イメージをフェッチするために使用するイメージ・プル・シークレットに置き換えます。

    • dbConfigMapは、「例について」で作成したrepsample ConfigMapを指定します。
  2. TimesTenClassicオブジェクトをネームスペースにデプロイします。
    kubectl create -f repsample.yaml
    出力は次のようになります。
    timestenclassic.timesten.oracle.com/repsample created
  3. デプロイメントを監視します。
    1. オブジェクトのステータスを確認します。
      kubectl get ttc repsample

      出力は、次のようになります。

      NAME          STATE              ACTIVE   AGE
      repsample     Initializing       None     9s

      プロビジョニングは開始されますが、Initializing状態で示されているとおり、完了していません。

    2. 数分間待機します。次に、ステータスを再度確認します。
      kubectl get ttc repsample

      出力は、次のようになります。

      NAME        STATE    ACTIVE        AGE
      repsample   Normal   repsample-0   2m27s

      プロビジョニング・プロセスが完了します。アクティブ・データベースとスタンバイ・データベースが稼働中であり、動作しています。TimesTenオペレータにより、repsampleオブジェクトがNormal状態に遷移します。

  4. (オプション): 状態遷移を確認します。
    kubectl get events

    出力は、次のようになります。

    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

    プロビジョニング・プロセス中に、TimesTenClassicオブジェクトはInitializing状態からNormal状態に遷移します。

  5. 基礎となるオブジェクトが存在するかどうかの確認

    1. StatefulSet:

    kubectl get statefulset repsample

    出力は、次のようになります。

    NAME        READY   AGE
    repsample   1/2     7m22s

    2. サービス:

    kubectl get service repsample

    出力は、次のようになります。

    NAME        TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)             AGE
    repsample   ClusterIP   None         <none>        6625/TCP,8888/TCP   8m2s
    3 ポッド:
    kubectl get pods
    出力は、次のようになります。
    NAME                                 READY   STATUS    RESTARTS   AGE
    repsample-0                          3/3     Running   0          8m31s
    repsample-1                          2/3     Running   0          8m31s
    ...

    4.PVC:

    kubectl get pvc

    出力は、次のようになります。

    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. アクティブ・データベースに接続します。
    1. 開発ホストから、ポッドにシェルを確立します。
      kubectl exec -it repsample-0 -c tt -- /bin/bash
    2. アクティブ・データベースに接続します。表に行を挿入します。
      [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. ttIsqlおよびシェルを終了します。
      Command> exit
      Disconnecting...
      Done.
      [timesten@repsample-0 ~]$ exit
      exit
おめでとうございます。レプリケートされたTimesTenClassicオブジェクトが正常に作成およびデプロイされました。TimesTen Classicデータベースのレプリケートされたアクティブ・スタンバイ・ペアは稼働中であり、完全に動作しています。