レプリケートされていない環境でのレプリカ数の変更
レプリケートされない環境でデータベースの数を増減する必要がある場合があります。たとえば、休暇で購入がピークとなるシーズン中にリソースを増やし、後でリソースを減らす場合があります。これを行うには、TimesTenClassicオブジェクトのreplicasの数を変更します。
レプリカの数を増やすと、Kubernetesは新しいポッドにTimesTenをプロビジョニングします。
-
Kubernetesは、関連するポッドを削除します。
-
TimesTenオペレータでは、PVCを削除しません。
例をステップごとに見てみましょう。この例では、TimesTenClassicオブジェクトがネームスペースにデプロイされます。replicasの数は3です。この例では、レプリカの数を1に減らしてから、レプリカの数を3に戻す方法を示します。
- TimesTenClassicオブジェクトがネームスペースにデプロイされていることを確認します。
kubectl get ttc出力は、次のようになります。
NAME STATE ACTIVE AGE norepsample AllReplicasReady N/A 17mnorepsampleTimesTenClassicオブジェクトがデプロイされており、AllReplicasReady状態です。すべてのレプリカが使用可能で、実行中であり、データベースが正常に機能しています。 - レプリカの数を確認します。
kubectl describe ttc norepsample | grep 'Replicas'出力は、次のようになります。
Replicas: 3レプリカの数は
3です。 - ポッドの数を確認します。
kubectl get pods出力は次のようになります
NAME READY STATUS RESTARTS AGE norepsample-0 3/3 Running 0 18m norepsample-1 3/3 Running 0 18m norepsample-2 3/3 Running 0 18m ...レプリカの数に対応する3つのポッドが実行されています。各レプリカには、TimesTenデータベースが含まれています。
- データベースにデータを挿入します。
norepsample-0ポッドで実行されているデータベース:kubectl exec -it norepsample-0 -c tt -- /bin/bash [timesten@norepsample-0 ~]$ ttIsql norepsample Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. Type ? or "help" for help, type "exit" to quit ttIsql. connect "DSN=norepsample"; Connection successful: DSN=norepsample;UID=timesten;DataStore=/tt/home/timesten/datastore/norepsample;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;AutoCreate=0;PermSize=200;DDLReplicationLevel=3;ForceDisconnectEnabled=1; (Default setting AutoCommit=1) Command> CREATE TABLE testdata (col1 TT_INTEGER); Command> INSERT INTO testdata values (0); 1 row inserted. Command> SELECT * FROM testdata; < 0 > 1 row found. Command> exit Disconnecting... Done. [timesten@norepsample-0 ~]$ exit exittestdata表には1つの行があり、col1の値は0です。norepsample-1ポッドで実行されているデータベース:kubectl exec -it norepsample-1 -c tt -- /bin/bash [timesten@norepsample-0 ~]$ ttIsql norepsample Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. Type ? or "help" for help, type "exit" to quit ttIsql. connect "DSN=norepsample"; Connection successful: DSN=norepsample;UID=timesten;DataStore=/tt/home/timesten/datastore/norepsample;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;AutoCreate=0;PermSize=200;DDLReplicationLevel=3;ForceDisconnectEnabled=1; (Default setting AutoCommit=1) Command> CREATE TABLE testdata (col1 TT_INTEGER); Command> INSERT INTO testdata values (1); 1 row inserted. Command> SELECT * FROM testdata; < 1 > 1 row found. Command> exit Disconnecting... Done. [timesten@norepsample-1 ~]$ exit exittestdata表には1つの行があり、col1の値は1です。norepsample-2ポッドで実行されているデータベース:kubectl exec -it norepsample-2 -c tt -- /bin/bash [timesten@norepsample-0 ~]$ ttIsql norepsample Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. Type ? or "help" for help, type "exit" to quit ttIsql. connect "DSN=norepsample"; Connection successful: DSN=norepsample;UID=timesten;DataStore=/tt/home/timesten/datastore/norepsample;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;AutoCreate=0;PermSize=200;DDLReplicationLevel=3;ForceDisconnectEnabled=1; (Default setting AutoCommit=1) Command> CREATE TABLE testdata (col1 TT_INTEGER); Command> INSERT INTO testdata values (2); 1 row inserted. Command> SELECT * FROM testdata; < 2 > 1 row found. Command> exit Disconnecting... Done. [timesten@norepsample-2 ~]$ exit exittestdata表には1つの行があり、col1の値は2です。
- レプリカの数を減らします。
norepsampleTimesTenClassicオブジェクトを編集し、replicasを1に変更します。kubectl edit ttc norepsample # Please edit the object below. Lines beginning with a '#' will be ignored, # and an empty file will abort the edit. If an error occurs while saving this file will be # reopened with the relevant failures. # apiVersion: timesten.oracle.com/v4 kind: TimesTenClassic ... spec: ttspec: ... replicas: 1 ...- 編集内容を保存します。出力は、次のようになります。
timestenclassic.timesten.oracle.com/norepsample edited
- TimesTenClassicオブジェクトが
AllReplicasReady状態であることを確認します。kubectl get ttc出力は、次のようになります。
NAME STATE ACTIVE AGE norepsample AllReplicasReady N/A 63m - ポッドの数を確認します。
kubectl get pods出力は、次のようになります。
NAME READY STATUS RESTARTS AGE norepsample-0 3/3 Running 0 65m ...1つのポッドがあります。1つのTimesTenデータベースがそのポッドで実行されています。
- PVCの数を確認します。
kubectl get pvc出力は、次のようになります。
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE tt-persistent-norepsample-0 Bound csi-836f3962-cbfa-4f7d-9271-6393167b00bd 50Gi RWO oci-bv 67m tt-persistent-norepsample-1 Bound csi-b2bfa486-6d09-463f-a8a3-25a760d1449d 50Gi RWO oci-bv 67m tt-persistent-norepsample-2 Bound csi-820a206b-1662-4c24-821c-a947572b618a 50Gi RWO oci-bv 67m3つのPVCがあります。レプリカの数を変更しても、TimesTenオペレータではTimesTenClassicオブジェクトに関連付けられているPVCを削除しません。
- レプリカの数を増やします。
norepsampleTimesTenClassicオブジェクトを編集し、replicasを3に変更します。kubectl edit ttc norepsample # Please edit the object below. Lines beginning with a '#' will be ignored, # and an empty file will abort the edit. If an error occurs while saving this file will be # reopened with the relevant failures. # apiVersion: timesten.oracle.com/v4 kind: TimesTenClassic ... spec: ttspec: ... replicas: 3 ...- 編集内容を保存します。出力は、次のようになります。
timestenclassic.timesten.oracle.com/norepsample edited
- TimesTenClassicオブジェクトが
AllReplicasReady状態であることを確認します。kubectl get ttc出力は、次のようになります。
NAME STATE ACTIVE AGE norepsample AllReplicasReady N/A 76m - ポッドの数を確認します。
kubectl get pods出力は、次のようになります。
NAME READY STATUS RESTARTS AGE norepsample-0 3/3 Running 0 77m norepsample-1 3/3 Running 0 4m norepsample-2 3/3 Running 0 4m3つのポッドがあります。各ポッドでは、TimesTenデータベースが実行されています。
- PVCの数を確認します。
kubectl get pvc出力は、次のようになります。
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE tt-persistent-norepsample-0 Bound csi-836f3962-cbfa-4f7d-9271-6393167b00bd 50Gi RWO oci-bv 79m tt-persistent-norepsample-1 Bound csi-b2bfa486-6d09-463f-a8a3-25a760d1449d 50Gi RWO oci-bv 79m tt-persistent-norepsample-2 Bound csi-820a206b-1662-4c24-821c-a947572b618a 50Gi RWO oci-bv 79m3つのTimesTenデータベースに関連付けられた3つのPVCがあります。
- データベース内のデータを検証します。
norepsample-0ポッドで実行されているデータベース:kubectl exec -it norepsample-0 -c tt -- /bin/bash [timesten@norepsample-0 ~]$ ttIsql norepsample Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. Type ? or "help" for help, type "exit" to quit ttIsql. connect "DSN=norepsample"; Connection successful: DSN=norepsample;UID=timesten;DataStore=/tt/home/timesten/datastore/norepsample;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;AutoCreate=0;PermSize=200;DDLReplicationLevel=3;ForceDisconnectEnabled=1; (Default setting AutoCommit=1) Command> tables; TIMESTEN.TESTDATA 1 table found. Command> SELECT * FROM testdata; < 0 > 1 row found.レプリカの数を減らしたときにこのポッドは削除されなかったため、データベースのデータは変更されていません。
norepsample-1ポッドで実行されているデータベース:kubectl exec -it norepsample-1 -c tt -- /bin/bash [timesten@norepsample-1 ~]$ ttIsql norepsample Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. Type ? or "help" for help, type "exit" to quit ttIsql. connect "DSN=norepsample"; Connection successful: DSN=norepsample;UID=timesten;DataStore=/tt/home/timesten/datastore/norepsample;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;AutoCreate=0;PermSize=200;DDLReplicationLevel=3;ForceDisconnectEnabled=1; (Default setting AutoCommit=1) Command> tables; 0 tables found. Command> exit Disconnecting... Done. [timesten@norepsample-1 ~]$ exit exitTimesTenオペレータは、
norepsample-1ポッドのTimesTenを正しくプロビジョニングし、元のデータベースを正しく上書きしました。norepsample-2ポッドで実行されているデータベース:kubectl exec -it norepsample-2 -c tt -- /bin/bash [timesten@norepsample-2 ~]$ ttIsql norepsample Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. Type ? or "help" for help, type "exit" to quit ttIsql. connect "DSN=norepsample"; Connection successful: DSN=norepsample;UID=timesten;DataStore=/tt/home/timesten/datastore/norepsample;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;AutoCreate=0;PermSize=200;DDLReplicationLevel=3;ForceDisconnectEnabled=1; (Default setting AutoCommit=1) Command> tables; 0 tables found. Command> exit Disconnecting... Done. [timesten@norepsample-2 ~]$ exit exitTimesTenオペレータは、
norepsample-2ポッドのTimesTenを正しくプロビジョニングし、元のデータベースを正しく上書きしました。