7.1 認証でのDBMS_CLOUDの使用
クラウド・ストレージには、DBMS_CLOUD Credentialコマンドを使用してアクセスできます。現在、DBMS_CLOUD CredentialはOracle Cloudデータベースをサポートしています。
DBMS_CLOUD Credentialコマンド(dbcc)を使用すると、次のことができます。
- Swift、OCI資格証明または既存のOCIプロファイルを使用して資格証明を作成します。
- 資格証明を有効化、無効化、更新および削除します。
- 資格証明をリストします。
- デフォルトの資格証明を設定します。
資格証明の作成
Swift資格証明を使用して認証を作成するには、次のコマンドを使用します。
dbcc create <new-credential-name> user <username> pass <password>
OCI資格証明を使用して認証を作成するには、次のコマンドを使用します。
dbcc create <new-credential-name> fingerprint <fingerprint> user_ocid <user-id> tenancy_ocid <tenancy-id> private_path <path-to-private-key>
OCIプロファイルを使用して認証を作成するには、次のコマンドを使用します。
dbcc create <new-credential-name> profile <oci-profile-name>
資格証明の有効化、無効化、更新および削除
資格証明を有効にするには、次のコマンドを使用します。
dbcc enable <credential-name>
資格証明を無効にするには、次のコマンドを使用します。
dbcc disable <credential-name>
資格証明を更新するには、次のコマンドを使用します。
dbcc update <credential-name> <attribute> <value>
ここで、<attribute> : [user_ocid] [tenancy | tenancy_id] [key_path | private_key_path] [print | fingerprint]
資格証明を削除するには、次のコマンドを使用します。
dbcc drop <credential-name>
資格証明のリスト
使用可能な資格証明のリストを表示するには、次のコマンドを使用します。
dbcc list
デフォルトの資格証明の設定
mycredをデフォルトの資格証明として設定するには、次のコマンドを使用します。
dbcc mycreddbccコマンドのヘルプを検索するには、次のコマンドを使用します。
help dbccredDBMS_CLOUD資格証明を作成して設定する例
次の例では、様々なタイプのDBMS_CLOUD資格証明を作成して設定するステップを詳しく説明します。
--Set the path to the Wallet zip file on your system
SQL> set cloudconfig <path-to-Wallet-file>
Operation is successfully completed.
--Supply the database user name, password and the database service name provided in the tnsnames.ora
SQL> connect admin/<password>@adw20200526_high
Connected.
--Set Cloud Storage URL to the bucket
SQL> cs https://objectstorage.us-ashburn-1.example.com/n/test/b/example
DBMS_CLOUD Credential: Not Set
OCI Profile: Not Set
Transer Method: Not Set
URI as specified: https://objectstorage.us-ashburn-1.example.com/n/test/b/example
--create CREDENTIAL using Swift authentication
SQL> dbcc create swiftcred user <username> pass <password>
Credential SWIFTCRED created.
DBMS_CLOUD Credential set to SWIFTCRED.
Transfer method set to DBMS_CLOUD.
--create CREDENTIAL using OCI authentication
SQL> dbcc create ocicred fingerprint ec:98:83:**:**:**:b5
user_ocid ocid1.user.oc1......**g4xoca
tenancy_ocid ocid1.tenancy.oc1.....a**3n3a
private_path C:\\Users\\test\\.oci/freedb_api_key.pem
Credential OCICRED created.
DBMS_CLOUD Credential set to OCICRED.
Transfer method set to DBMS_CLOUD.
--create CREDENITAL using an existing OCI profile called freedb
--If profile name is not passed as a parameter, it takes the default
OCI profile details which is already set.
SQL> dbcc create profcred profile [freedb]
Credential PROFCRED created.
DBMS_CLOUD Credential set to PROFCRED.
Transfer method set to DBMS_CLOUD.