2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Autonomous AI DatabaseからECPU数を変更する

2
Last updated at Posted at 2025-11-11

概要

下記の記事のECPU対応をするための手法になります。
著者である先人の知識に感謝:pray:

ECPUモデルでのエラー

ECPUモデルのAutonomous AI Databaseに対して上記記事のプロシージャを実行すると、下記のようなエラーが表示されます。

ORA-20409: Request failed with status HTTP 409 - https://database.ap-osaka-1.oraclecloud.com/20160918/autonomousDatabases/ocid1.autonomousdatabase.oc1.ap-osaka-1.xxxxxxxxxx
Error response - {
  "code" : "IncorrectState",
  "message" : "Operation failed. Cannot update the Autonomous AI Database because CPU (cpuCoreCount) cannot be updated with an Autonomous AI Database using the ECPU compute model."
}
ORA-06512: "C##CLOUD$SERVICE.DBMS_CLOUD$PDBCS_251026_0", 行2251
ORA-06512: "C##CLOUD$SERVICE.DBMS_CLOUD$PDBCS_251026_0", 行14704
ORA-06512: "C##CLOUD$SERVICE.DBMS_CLOUD_OCI_DB_DATABASE", 行67780

エラーが示す通り、ECPUモデルのAutonomous AI Databaseは上記記事の方法ではECPU数を変更できません。

ECPU数を変更するプロシージャの作成

compute_countを指定してECPU数を操作します。

CREATE OR REPLACE PROCEDURE change_ecpu_count( ecpu_count IN NUMBER )
  IS
  	autonomous_database_details	dbms_cloud_oci_database_update_autonomous_database_details_t;
  	response					dbms_cloud_oci_db_database_update_autonomous_database_response_t;
	  
  	adb_ocid    VARCHAR2(200);
	adb_region  VARCHAR2(100);

  BEGIN
-- Autonomous Databaseの情報をv$pdbsから取得
	SELECT json_value(cloud_identity, '$.REGION'), LOWER(json_value(cloud_identity, '$.DATABASE_OCID'))
      INTO adb_region, adb_ocid FROM v$pdbs;
-- 確認用に各変数の値を表示
  	DBMS_OUTPUT.PUT_LINE ('ADB OCID:'||adb_ocid);
  	DBMS_OUTPUT.PUT_LINE ('ADB Region:'||adb_region);
  	DBMS_OUTPUT.PUT_LINE ('New ECPU count:'||ecpu_count);
-- 変数を初期化し、新しく設定するECPUの値をcompute_countにセット
  	autonomous_database_details := dbms_cloud_oci_database_update_autonomous_database_details_t();
  	autonomous_database_details.compute_count := ecpu_count;
-- DBMS_CLOUD_OCI_DB_DATABASE.UPDATE_AUTONOMOUS_DATABASEを実行してECPUの値を変更
  	response := DBMS_CLOUD_OCI_DB_DATABASE.UPDATE_AUTONOMOUS_DATABASE (
  		autonomous_database_id => adb_ocid,
  		update_autonomous_database_details => autonomous_database_details,
  		region => adb_region,
  		credential_name => 'OCI$RESOURCE_PRINCIPAL');

  END;
/

実行する。

SQL> exec change_ecpu_count(8);

PL/SQLプロシージャが正常に完了しました。

リソース・プリンシパルの設定をお忘れなく

下記のようなポリシーを動的グループに付与してください。
※必要に応じて許可する操作にのみポリシーを絞りましょう

Allow dynamic-group ymaejima_dynamic_group to use autonomous-database-family in compartment ymaejima
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?