- Kubernetesオペレータ・ユーザーズ・ガイド
- TimesTen Classicデータベースの作成
- レプリケートされていない環境でのレプリカ数の変更
レプリケートされていない環境でのレプリカ数の変更
レプリケートされない環境でデータベースの数を増減する必要がある場合があります。たとえば、休暇で購入がピークとなるシーズン中にリソースを増やし、後でリソースを減らす場合があります。これを行うには、TimesTenClassicオブジェクトのreplicas
の数を変更します。
レプリカの数を増やすと、Kubernetesは新しいポッドにTimesTenをプロビジョニングします。
-
Kubernetesは、関連するポッドを削除します。
-
TimesTenオペレータでは、PVCを削除しません。
例をステップごとに見てみましょう。この例では、TimesTenClassicオブジェクトがネームスペースにデプロイされます。replicas
の数は3
です。この例では、レプリカの数を1
に減らしてから、レプリカの数を3
に戻す方法を示します。
- TimesTenClassicオブジェクトがネームスペースにデプロイされていることを確認します。
kubectl get ttc
出力は、次のようになります。
NAME STATE ACTIVE AGE norepsample AllReplicasReady N/A 17m
norepsample
TimesTenClassicオブジェクトがデプロイされており、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 exit
testdata
表には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 exit
testdata
表には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 exit
testdata
表には1つの行があり、col1
の値は2
です。
- レプリカの数を減らします。
norepsample
TimesTenClassicオブジェクトを編集し、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/v3 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 67m
3つのPVCがあります。レプリカの数を変更しても、TimesTenオペレータではTimesTenClassicオブジェクトに関連付けられているPVCを削除しません。
- レプリカの数を増やします。
norepsample
TimesTenClassicオブジェクトを編集し、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/v3 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 4m
3つのポッドがあります。各ポッドでは、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 79m
3つの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 exit
TimesTenオペレータは、
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 exit
TimesTenオペレータは、
norepsample-2
ポッドのTimesTenを正しくプロビジョニングし、元のデータベースを正しく上書きしました。