Database Support Blog

  • Oracle Cloud
2024.07.02

OCI CLIでデータベースインスタンスを作成する方法

OCI CLIは、Oracle Cloud Infrastructure(以下、OCI)の各種サービスを操作するためのコマンドラインツールです。 前回はコンピュートインスタンスを作成する方法についてご紹介しました。

今回はデータベースインスタンスの構築方法についてご紹介します。また今回からはシェルを用いた構築もご紹介します。

1)事前準備

1-1)前提条件

今回データベースインスタンスを構築する環境は、前記事で作成したネットワーク(VCNおよびサブネット)を利用します。

1-2)パラメーターの取得と検討

1-2-1)パラメーター確認

事前の準備として以下のパラメーターを確認しておきます。

・コンパートメントのOCID
・VCNのOCID
・サブネットのOCID
・データベースインスタンスを作成する可用性ドメイン名(※1)
・データベースインスタンスを作成するフォルト ドメイン名(※1)
・データベースのバージョン

※1
可用性ドメイン名とフォルト ドメインの確認は前回の「1-1-2)パラメーターの取得(可用性ドメイン名、フォルト ドメイン名)」を参照

設定可能なデータベースバージョンの確認には、以下のコマンドを実行します。

コマンド構文
oci db version list\
--compartment-id <コンパートメントのOCID>\
--db-system-shape "<シェイプ名>"\
--output table\
--query 'data[].{"DB_Version":"version"}'

# 実行結果
xxxxxxxxxx@cloudshell:~ (ap-tokyo-1)$ oci db version list\
> --compartment-id ocid1.compartment.oc1..aaa…\
> --db-system-shape "VM.Standard.E4.Flex"\
> --output table\
> --query 'data[].{"DB_Version":"version"}'
+--------------+
| DB_Version |
+--------------+
| 19.0.0.0 |
| 19.20.0.0 |
| 19.21.0.0 |
| 19.22.0.0 |
| 19.23.0.0 |
| 21.0.0.0 |
| 21.11.0.0 |
| 21.12.0.0 |
| 21.13.0.0 |
| 21.14.0.0 |
| 23.0.0.0.0 |
| 23.4.0.24.05 |
+--------------+

実行結果から、設定可能なデータベースのバージョン一覧を確認できます。


1-2-2)パラメーター検討

データベースインスタンスへ設定する主なパラメーターを整理したものが以下です。

大項目名 必須 パラメーター 備考
compartment-id ocid1.compartment.oc1..xxxxx 所属するコンパートメントのOCIDを指定
display-name - ocicli_test_db DBインスタンスの表示名を指定
availability-domain xxxx:AP-TOKYO-1-AD-1 作成する可用性ドメイン名を指定
fault-domains - FAULT-DOMAIN-1 作成するフォルト ドメイン名を指定
shape VM.Standard.E4.Flex DBシステムのシェイプ名を指定
cpu-core-count 2 ノードあたりのOCPU数を指定
storage-management - ASM ストレージ管理方法を指定
storage-performance - BALANCED ストレージのパフォーマンスを指定
initial-data-storage-size-in-gb - 512 ストレージのサイズを指定
node-count - 1 ノードの数を指定
database-edition STANDARD_EDITION DBのエディションを指定
ssh-authorized-keys-file /home/xxxxxxxxxx/03_create_paas/sshkey/ssh-key-2024-02-15.key.pub 公開鍵のファイルを指定
license-model - BRING_YOUR_OWN_LICENSE ライセンス・タイプを指定
subnet-id ocid1.subnet.oc1.ap-tokyo-1.xxxxx サブネットのOCIDを指定
hostname ocicli_test_db ホスト名を指定
private-ip - 10.0.2.100 プライベートIPを指定
db-name CLI01DB DBインスタンス名を指定
db-version 19.22.0.0 DBのバージョンを指定
pdb-name - CLI01PDB PDB名を指定
admin-password <要件を満たす任意のパスワード> SYSユーザーのパスワードを指定
auto-backup-enabled - FALSE 自動バックアップを有効化するか指定
character-set - AL32UTF8 DBのキャラクタセットを指定
ncharacter-set - AL16UTF16 各国語キャラクタセットを指定

※必須のパラメーター以外は任意で設定するパラメーターです。必要に応じて設定ください。
※これ以外にもパラメーターは存在します。詳細はリファレンスをご参照ください。


1-3)シェルの準備

冒頭でも述べたとおり、今回はシェルを用いた構築方法についてご紹介します。
作業ディレクトリを作成して、以下のシェルを準備します。

シェル名 概要
01_check_vcn_before.sh VCNの情報を確認をするシェル
02_update_routerule.sh ルートルールを更新するシェル
03_update_securityrule.sh セキュリティルールを更新するシェル
04_check_vcn_after.sh VCNの情報を確認をするシェル
05_create_database.sh データベースインスタンスを作成するシェル
06_check_create_db_progress.sh インスタンス作成の進捗を確認するシェル
07_check_database.sh データベースインスタンスを確認するシェル
08_stop_database_node.sh データベースノードを停止するシェル
09_start_database_node.sh データベースノードを起動するシェル

※本記事でご紹介するサンプルコードに関するサポートはご提供しておりません。
 ご利用の際には、ご自身の責任のもとでご利用いただけますようお願いいたします。


1-3-1)VCNの情報を確認をするシェル

データベースインスタンスを作成するには、サブネットとオブジェクトストレージが通信可能な状態であることが前提となります。この条件を満たすため、データベースを配置するサブネットに紐づくルート表とセキュリティリストのルールを更新する必要があります。

ルールの更新を行う前に、サブネットにアタッチされているルート表とセキュリティリストを「01_check_vcn_before.sh」で確認します。

01_check_vcn_before.sh

#!/bin/sh
echo " ########################################"
echo " # 01.1.サブネットの情報確認"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci network subnet list\
--compartment-id <所属するコンパートメントのOCID>\
--vcn-id <VCNのOCID>\
--output table\
--query 'data[].{"01_Name":"display-name", "02_CIDR_Block":"cidr-block", "03_Prohibit_public_ip_on_vnic":"prohibit-public-ip-on-vnic", "04_RouteTable":"route-table-id", "05_SecurityList":"security-list-ids", "06_Lifecyclestate":"lifecycle-state", "07_Created":"time-created"}'
echo " ########################################"
echo " # 01.2.ルート表のOCID確認"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci network route-table list\
--compartment-id <所属するコンパートメントのOCID>\
--vcn-id <VCNのOCID>\
--output table\
--query 'data[].{"01_Name":"display-name", "02_OCID":"id"}'
echo " ########################################"
echo " # 01.3.セキュリティリストのOCID確認"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci network security-list list\
--compartment-id <所属するコンパートメントのOCID>\
--vcn-id <VCNのOCID>\
--output table\
--query 'data[].{"01_Name":"display-name", "02_OCID":"id"}'


1-3-2)ルートルールを更新するシェル

「02_update_routerule.sh」では、ルート表にオブジェクトストレージへのルーティング設定を行います。
以下のルールを設定します。

大項目名 小項目名 必須 パラメーター
rt-id - ocid1.routetable.oc1.ap-tokyo-1.xxxxx.....
route-rules - - -
route-rules network-entity-id (〇) ocid1.servicegateway.oc1.ap-tokyo-1.aaa...
route-rules destination-type (-) SERVICE_CIDR_BLOCK
route-rules destination (-) all-nrt-services-in-oracle-services-network
route-rules description (-) create_db_test

02_update_routerule.sh

#!/bin/sh
echo " ########################################"
echo " # 02.1.ルート表に設定したルールの事前確認"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci network route-table get\
--rt-id <ルート表のOCID>\
--output table\
--query 'data."route-rules"[].{"01_Desc":"description", "02_CIDR":"cidr-block", "03_Destination_type":"destination-type", "04_Destination":"destination", "05_Routetype":"route-type", "06_Gateway_OCID":"network-entity-id"}'
echo " ########################################"
echo " # 02.2.ルートルールの更新"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci network route-table update\
--rt-id <ルート表のOCID>\
--route-rules '[ { "network-entity-id": "<サービスゲートウェイのOCID>", "destination-type": "SERVICE_CIDR_BLOCK", "destination": "all-nrt-services-in-oracle-services-network", "description": "create_db_test" } ]'
echo " ########################################"
echo " # 02.3.ルート表に設定したルールの事後確認"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci network route-table get\
--rt-id <ルート表のOCID>\
--output table\
--query 'data."route-rules"[].{"01_Desc":"description", "02_CIDR":"cidr-block", "03_Destination_type":"destination-type", "04_Destination":"destination", "05_Routetype":"route-type", "06_Gateway_OCID":"network-entity-id"}'


1-3-3)セキュリティルールを更新するシェル

「03_update_securityrule.sh」では、オブジェクトストレージと通信ができるようにセキュリティリストに仮想ファイアウォールの設定を行います。
以下のルールを設定します。

大項目名 必須 ルール1 ルール2
イングレスルール isStateless - false -
protocol all -
sourceType - SERVICE_CIDR_BLOCK -
source oci-nrt-objectstorage -
description - create_db_test -
エグレスルール isStateless - false false
protocol all all
destinationType - SERVICE_CIDR_BLOCK CIDR_BLOCK
destination objectstorage 0.0.0.0/0
description - create_db_test create_db_test

03_update_securityrule.sh

#!/bin/sh
echo " ########################################"
echo " # 03.1.セキュリティルール(エグレス)の事前確認"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci network security-list get\
--security-list-id <セキュリティリストのOCID>\
--output table\
--query 'data."egress-security-rules"[].{"01_Stateless":"is-stateless", "02_Destination-type":"destination-type", "03_Destination":"destination", "04_Protocol":"protocol", "05_ICMP":"icmp-options", "06_TCP":"tcp-options", "07_UDP":"udp-options", "Description":"description"}'
echo " ########################################"
echo " # 03.2.セキュリティルール(イングレス)の事前確認"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci network security-list get\
--security-list-id <セキュリティリストのOCID>\
--output table\
--query 'data."ingress-security-rules"[].{"01_Stateless":"is-stateless", "02_Source-type":"source-type", "03_Source":"source", "04_Protocol":"protocol", "05_ICMP":"icmp-options", "06_TCP":"tcp-options", "07_UDP":"udp-options", "Description":"description"}'
echo " ########################################"
echo " # 03.3.セキュリティルール(エグレス)の更新"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci network security-list update\
--security-list-id <セキュリティリストのOCID>\
--egress-security-rules\
'[
{ "isStateless": false, "protocol": "all", "destinationType": "SERVICE_CIDR_BLOCK", "destination": "oci-nrt-objectstorage", "description": "create_db_test" }
,{ "isStateless": false, "protocol": "all", "destinationType": "CIDR_BLOCK", "destination": "0.0.0.0/0", "description": "create_db_test" }
]'
echo " ########################################"
echo " # 03.4.セキュリティルール(イングレス)の更新"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci network security-list update\
--security-list-id <セキュリティリストのOCID>\
--ingress-security-rules\
'[
{ "isStateless": false, "protocol": "all", "sourceType": "SERVICE_CIDR_BLOCK", "source": "oci-nrt-objectstorage", "description": "create_db_test" }
]'
echo " ########################################"
echo " # 03.5.セキュリティルール(エグレス)の事後確認"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci network security-list get\
--security-list-id <セキュリティリストのOCID>\
--output table\
--query 'data."egress-security-rules"[].{"01_Stateless":"is-stateless", "02_Destination-type":"destination-type", "03_Destination":"destination", "04_Protocol":"protocol", "05_ICMP":"icmp-options", "06_TCP":"tcp-options", "07_UDP":"udp-options", "Description":"description"}'
echo " ########################################"
echo " # 03.6.セキュリティルール(イングレス)の事後確認"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci network security-list get\
--security-list-id <セキュリティリストのOCID>\
--output table\
--query 'data."ingress-security-rules"[].{"01_Stateless":"is-stateless", "02_Source-type":"source-type", "03_Source":"source", "04_Protocol":"protocol", "05_ICMP":"icmp-options", "06_TCP":"tcp-options", "07_UDP":"udp-options", "Description":"description"}'


1-3-4)VCNの情報を確認をするシェル

ルートルールとセキュリティルールの変更作業以外に変更箇所がないことを、「04_check_vcn_after.sh」で確認します。
※実行内容は「01_check_vcn_before.sh」と同じものとなります。


04_check_vcn_after.sh

#!/bin/sh
echo " ########################################"
echo " # 04.1.サブネットの情報確認"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci network subnet list\
--compartment-id <所属するコンパートメントのOCID>\
--vcn-id <VCNのOCID>\
--output table\
--query 'data[].{"01_Name":"display-name", "02_CIDR_Block":"cidr-block", "03_Prohibit_public_ip_on_vnic":"prohibit-public-ip-on-vnic", "04_RouteTable":"route-table-id", "05_SecurityList":"security-list-ids", "06_Lifecyclestate":"lifecycle-state", "07_Created":"time-created"}'
echo " ########################################"
echo " # 04.2.ルート表のOCID確認"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci network route-table list\
--compartment-id <所属するコンパートメントのOCID>\
--vcn-id <VCNのOCID>\
--output table\
--query 'data[].{"01_Name":"display-name", "02_OCID":"id"}'
echo " ########################################"
echo " # 04.3.セキュリティリストのOCID確認"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci network security-list list\
--compartment-id <所属するコンパートメントのOCID>\
--vcn-id <VCNのOCID>\
--output table\
--query 'data[].{"01_Name":"display-name", "02_OCID":"id"}'


1-3-5)データベースインスタンスを作成するシェル

「05_create_database.sh」では、データベースインスタンスを作成します。


05_create_database.sh

#!/bin/sh
echo " ########################################"
echo " # 05.1.データベースインスタンスの作成"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci db system launch\
--compartment-id <所属するコンパートメントのOCID>\
--display-name "<データベースインスタンスの表示名>"\
--availability-domain "<有効な可用性ドメイン名>"\
--fault-domains '["<フォルト ドメイン名>"]'\
--shape "<シェイプ名>"\
--cpu-core-count <ノード当たりのOCPU数>\
--storage-management "<ストレージの管理方法>"\
--storage-performance "<ストレージのパフォーマンス>"\
--initial-data-storage-size-in-gb <ストレージのサイズ>\
--node-count <ノード数>\
--database-edition "<データベースのエディション>"\
--ssh-authorized-keys-file <データベースに登録する公開鍵の配置先>\
--license-model "<ライセンス・タイプ>"\
--subnet-id <サブネットのOCID>\
--hostname "<ホスト名>"\
--private-ip "<プライベートIP>"\
--db-name "<データベース名>"\
--db-version "<データベースバージョン>"\
--pdb-name "<プラガブルデータベース名>"\
--admin-password "<SYSユーザーのパスワード>"\
--auto-backup-enabled <自動バックアップの有効無効>\
--character-set "<データベースのキャラクタセット>"\
--ncharacter-set "<各国語キャラクタセット>"


1-3-6)インスタンス作成の進捗を確認するシェル

「06_check_create_db_progress.sh」では、データベースインスタンス作成の作業リクエストの進捗を確認します。


06_check_create_db_progress.sh

#!/bin/sh
echo " ########################################"
echo " # 06.1.作業リクエストの進捗"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci work-requests work-request get\
--work-request-id "<作業リクエストのOCID>"\
--output table\
--query 'data.{"01_Operation":"operation-type", "02_Progress_Rate":"percent-complete", "03_Status":"status", "04_Started":"time-started", "05_Finished":"time-finished"}'
echo " ########################################"
echo " # 06.2.OCID確認"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci work-requests work-request get\
--work-request-id "<作業リクエストのOCID>"\
--output table\
--query 'data."resources"[].{"01_Operation":"entity-type", "02_Status":"action-type", "03_Entity-URL":"entity-uri", "04_OCID":"identifier"}'


1-3-7)データベースインスタンスを確認するシェル

「07_check_database.sh」では、作成したデータベースインスタンスの詳細を確認します。


07_check_database.sh

#!/bin/sh
echo " ########################################"
echo " # 07.1.データベースインスタンスの詳細確認"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci db system get\
--db-system-id <データベースシステムのOCID>


1-3-8)データベースノードを停止するシェル

「08_stop_database_node.sh」では、起動しているデータベースノードを停止します。


08_stop_database_node.sh

#!/bin/sh
echo " ########################################"
echo " # 08.1.データベースノードの起動状態確認"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci db node get\
--db-node-id <データベースノードのOCID>\
--output table\
--query 'data.{"01_Hostname":"hostname", "02_Status":"lifecycle-state", "03_OCID":"id", "04_Created":"time-created"}'
echo " ########################################"
echo " # 08.2.データベースノードの停止"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci db node stop\
--db-node-id <データベースノードのOCID>\
--wait-for-state "STOPPED"


1-3-9)データベースノードを起動するシェル

「09_start_database_node.sh」では、停止しているデータベースノードを起動します。


09_start_database_node.sh

#!/bin/sh
echo " ########################################"
echo " # 09.1.データベースノードの起動状態確認"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci db node get\
--db-node-id <データベースノードのOCID>\
--output table\
--query 'data.{"01_Hostname":"hostname", "02_Status":"lifecycle-state", "03_OCID":"id", "04_Created":"time-created"}'
echo " ########################################"
echo " # 09.2.データベースノードの起動"
echo " ########################################"
date '+%Y/%m/%d %H:%M:%S' ; oci db node start\
--db-node-id <データベースノードのOCID>\
--wait-for-state "AVAILABLE"


1-4)認証鍵の作成

データベースに登録する公開鍵と接続時に利用する秘密鍵のペアを作成し、任意のディレクトリに配置します。今回は作業ディレクトリ内にsshkeyディレクトリを作成して、配置します。

# 確認結果
xxxxxxxxxx@cloudshell:03_create_paas (ap-tokyo-1)$ ls -l
total 36
-rw-r--r--. 1 xxxxxxxxxx oci 1235 Jun 11 00:36 01_check_vcn_before.sh
-rw-r--r--. 1 xxxxxxxxxx oci 1204 Jun 10 08:35 02_update_routerule.sh
-rw-r--r--. 1 xxxxxxxxxx oci 2732 Jun 11 01:03 03_update_securityrule.sh
-rw-r--r--. 1 xxxxxxxxxx oci 1235 Jun 11 00:36 04_check_vcn_after.sh
-rw-r--r--. 1 xxxxxxxxxx oci 990 Jun 10 09:01 05_create_database.sh
-rw-r--r--. 1 xxxxxxxxxx oci 743 Jun 11 01:07 06_check_create_db_progress.sh
-rw-r--r--. 1 xxxxxxxxxx oci 165 Jun 11 04:20 07_check_database.sh
-rw-r--r--. 1 xxxxxxxxxx oci 475 Jun 11 04:52 08_stop_database_node.sh
-rw-r--r--. 1 xxxxxxxxxx oci 478 Jun 11 04:52 09_start_database_node.sh
drwxr-xr-x. 2 xxxxxxxxxx oci 40 Jun 7 01:45 sshkey

xxxxxxxxxx@cloudshell:03_create_paas (ap-tokyo-1)$ ls sshkey
ssh-key-2024-02-15.key.pub

2)OCI CLIを使用したデータベースインスタンスの作成

2-1)ルーティング、FW設定

はじめにサブネットにアタッチされているルート表とセキュリティリストを確認します。確認には「01_check_vcn_before.sh」を実行します。
以降、シェルの実行時にはteeコマンドで画面とログファイル両方の出力をしています。

# 実行結果
xxxxxxxxxx@cloudshell:03_create_paas (ap-tokyo-1)$ . 01_check_vcn_before.sh | tee 01_check_vcn_before.log
########################################
# 01.1.サブネットの情報確認
########################################
2024/06/13 02:37:03
+----------------------------+---------------+-------------------------------+----------------------------------------------+----------------------------------------------------+-------------------+----------------------------------+
| 01_Name | 02_CIDR_Block | 03_Prohibit_public_ip_on_vnic | 04_RouteTable | 05_SecurityList | 06_Lifecyclestate | 07_Created |
+----------------------------+---------------+-------------------------------+----------------------------------------------+----------------------------------------------------+-------------------+----------------------------------+
| subnet_ocicli_test_private | 10.0.2.0/24 | True | ocid1.routetable.oc1.ap-tokyo-1.aaa...hzk2ua | ['ocid1.securitylist.oc1.ap-tokyo-1.aaa...66csla'] | AVAILABLE | 2024-03-22T02:34:40.306000+00:00 |
| subnet_ocicli_test_public | 10.0.1.0/24 | False | ocid1.routetable.oc1.ap-tokyo-1.aaa...hzk2ua | ['ocid1.securitylist.oc1.ap-tokyo-1.aaa...66csla'] | AVAILABLE | 2024-03-22T02:29:15.033000+00:00 |
+----------------------------+---------------+-------------------------------+----------------------------------------------+----------------------------------------------------+-------------------+----------------------------------+
########################################
# 01.2.ルート表のOCID確認
########################################
2024/06/13 02:37:05
+------------------------------------+----------------------------------------------+
| 01_Name | 02_OCID |
+------------------------------------+----------------------------------------------+
| RT_ocicli_test_1 | ocid1.routetable.oc1.ap-tokyo-1.aaa...6mjsna |
| Default Route Table for ociclitest | ocid1.routetable.oc1.ap-tokyo-1.aaa...hzk2ua |
+------------------------------------+----------------------------------------------+
########################################
# 01.3.セキュリティリストのOCID確認
########################################
2024/06/13 02:37:06
+--------------------------------------+------------------------------------------------+
| 01_Name | 02_OCID |
+--------------------------------------+------------------------------------------------+
| SL_test_1 | ocid1.securitylist.oc1.ap-tokyo-1.aaa...z6c5lq |
| Default Security List for ociclitest | ocid1.securitylist.oc1.ap-tokyo-1.aaa...66csla |
+--------------------------------------+------------------------------------------------+

実行結果から、データベースインスタンスを作成するプライベートサブネット(subnet_ocicli_test_private)には、デフォルトのルート表(Default Route Table for ociclitest)とセキュリティリスト(Default Security List for ociclitest)が紐づいていることを確認できます。

以降の手順で利用する「02_update_routerule.sh」と「03_update_securityrule.sh」に、確認したデフォルトのルート表とセキュリティリストのOCIDを追記します。


次にルートルールを更新します。
更新には「02_update_routerule.sh」を実行します。

# 実行結果
xxxxxxxxxx@cloudshell:03_create_paas (ap-tokyo-1)$ . 02_update_routerule.sh | tee 02_update_routerule.log
########################################
# 02.1.ルート表に設定したルールの事前確認
########################################
2024/06/13 02:37:11
etag: xxxxxxxx
Command returned empty list, no table to display.
########################################
# 02.2.ルートルールの更新
########################################
2024/06/13 02:37:13
WARNING: Updates to defined-tags and freeform-tags and route-rules will replace any existing values. Are you sure you want to continue? [y/N]: y
{
"data": {
"compartment-id": "ocid1.compartment.oc1..aaa...",
"defined-tags": {
"Oracle-Tags": {
"CreatedBy": "xxxxxxxxxx",
"CreatedOn": "2024-03-22T02:26:51.894Z"
}
},
"display-name": "Default Route Table for ociclitest",
"freeform-tags": {},
"id": "ocid1.routetable.oc1.ap-tokyo-1.aaa...hzk2ua",
"lifecycle-state": "AVAILABLE",
"route-rules": [
{
"cidr-block": null,
"description": "create_db_test",
"destination": "all-nrt-services-in-oracle-services-network",
"destination-type": "SERVICE_CIDR_BLOCK",

"network-entity-id": "ocid1.servicegateway.oc1.ap-tokyo-1.aaa...",
"route-type": "STATIC"
}
],
"time-created": "2024-03-22T02:26:51.986000+00:00",
"vcn-id": "ocid1.vcn.oc1.ap-tokyo-1.ama..."
},
"etag": "xxxxxxxx"
}
########################################
# 02.3.ルート表に設定したルールの事後確認
########################################
2024/06/13 02:37:15
etag: xxxxxxxx
+----------------+---------+---------------------+---------------------------------------------+--------------+--------------------------------------------+
| 01_Desc | 02_CIDR | 03_Destination_type | 04_Destination | 05_Routetype | 06_Gateway_OCID |
+----------------+---------+---------------------+---------------------------------------------+--------------+--------------------------------------------+
| create_db_test | None | SERVICE_CIDR_BLOCK | all-nrt-services-in-oracle-services-network | STATIC | ocid1.servicegateway.oc1.ap-tokyo-1.aaa... |
+----------------+---------+---------------------+---------------------------------------------+--------------+--------------------------------------------+

実行結果の事前の確認より、「Command returned empty list, no table to display.」と表示され、デフォルトのルート表にはルールが構成されていないことが確認できます。

ルート表の更新時に、「既存のルールが全て置き換えられるため、続行するか」といった内容の警告文が出力されるため、既存の設定値の確認後に y を入力します。

※ルートルールを追加する構文は執筆時点(2024年7月2日)では存在しません。
 既存のルールを含めて新しいルールに置換されるため、注意が必要です。

設定後の確認結果より、デフォルトのルート表にオブジェクトストレージへのルールが構成されたことを確認できます。


次にセキュリティルールを更新します。
更新には「03_update_securityrule.sh」を実行します。

# 実行結果
xxxxxxxxxx@cloudshell:03_create_paas (ap-tokyo-1)$ . 03_update_securityrule.sh | tee 03_update_securityrule.log
########################################
# 03.1.セキュリティルール(エグレス)の事前確認
########################################
2024/06/13 02:37:24
etag: xxxxxxxx
+--------------+---------------------+----------------+-------------+---------+--------+--------+-------------+
| 01_Stateless | 02_Destination-type | 03_Destination | 04_Protocol | 05_ICMP | 06_TCP | 07_UDP | Description |
+--------------+---------------------+----------------+-------------+---------+--------+--------+-------------+
| False | CIDR_BLOCK | 0.0.0.0/0 | all | None | None | None | None |
+--------------+---------------------+----------------+-------------+---------+--------+--------+-------------+
########################################
# 03.2.セキュリティルール(イングレス)の事前確認
########################################
2024/06/13 02:37:25
etag: xxxxxxxx
+--------------+----------------+-------------+-------------+---------------------------+-------------------------------------------------------------------------------+--------+-------------+
| 01_Stateless | 02_Source-type | 03_Source | 04_Protocol | 05_ICMP | 06_TCP | 07_UDP | Description |
+--------------+----------------+-------------+-------------+---------------------------+-------------------------------------------------------------------------------+--------+-------------+
| False | CIDR_BLOCK | 0.0.0.0/0 | 6 | None | {'destination-port-range': {'max': 22, 'min': 22}, 'source-port-range': None} | None | None |
| False | CIDR_BLOCK | 0.0.0.0/0 | 1 | {'code': 4, 'type': 3} | None | None | None |
| False | CIDR_BLOCK | 10.0.0.0/16 | 1 | {'code': None, 'type': 3} | None | None | None |

+--------------+----------------+-------------+-------------+---------------------------+-------------------------------------------------------------------------------+--------+-------------+
########################################
# 03.3.セキュリティルール(エグレス)の更新
########################################
2024/06/13 02:37:27
WARNING: Updates to defined-tags and egress-security-rules and freeform-tags and ingress-security-rules will replace any existing values. Are you sure you want to continue? [y/N]: y
{
"data": {
"compartment-id": "ocid1.compartment.oc1..aaa...",
"defined-tags": {
"Oracle-Tags": {
"CreatedBy": "xxxxxxxxxx",
"CreatedOn": "2024-03-22T02:26:51.894Z"
}
},
"display-name": "Default Security List for ociclitest",
"egress-security-rules": [
{
"description": "create_db_test",
"destination": "oci-nrt-objectstorage",
"destination-type": "SERVICE_CIDR_BLOCK",
"icmp-options": null,
"is-stateless": false,
"protocol": "all",
"tcp-options": null,
"udp-options": null
},
{
"description": "create_db_test",
"destination": "0.0.0.0/0",
"destination-type": "CIDR_BLOCK",
"icmp-options": null,
"is-stateless": false,
"protocol": "all",
"tcp-options": null,
"udp-options": null
}
],

"freeform-tags": {},
"id": "ocid1.securitylist.oc1.ap-tokyo-1.aaa...66csla",
"ingress-security-rules": [
{
"description": null,
"icmp-options": null,
"is-stateless": false,
"protocol": "6",
"source": "0.0.0.0/0",
"source-type": "CIDR_BLOCK",
"tcp-options": {
"destination-port-range": {
"max": 22,
"min": 22
},
"source-port-range": null
},
"udp-options": null
},
{
"description": null,
"icmp-options": {
"code": 4,
"type": 3
},
"is-stateless": false,
"protocol": "1",
"source": "0.0.0.0/0",
"source-type": "CIDR_BLOCK",
"tcp-options": null,
"udp-options": null
},
{
"description": null,
"icmp-options": {
"code": null,
"type": 3
},
"is-stateless": false,
"protocol": "1",
"source": "10.0.0.0/16",
"source-type": "CIDR_BLOCK",
"tcp-options": null,
"udp-options": null
}
],
"lifecycle-state": "AVAILABLE",
"time-created": "2024-03-22T02:26:51.986000+00:00",
"vcn-id": "ocid1.vcn.oc1.ap-tokyo-1.ama..."
},
"etag": "xxxxxxxx"
}
########################################
# 03.4.セキュリティルール(イングレス)の更新
########################################
2024/06/13 02:37:34
WARNING: Updates to defined-tags and egress-security-rules and freeform-tags and ingress-security-rules will replace any existing values. Are you sure you want to continue? [y/N]: y
{
"data": {
"compartment-id": "ocid1.compartment.oc1..aaa...",
"defined-tags": {
"Oracle-Tags": {
"CreatedBy": "xxxxxxxxxx",
"CreatedOn": "2024-03-22T02:26:51.894Z"
}
},
"display-name": "Default Security List for ociclitest",
"egress-security-rules": [
{
"description": "create_db_test",
"destination": "oci-nrt-objectstorage",
"destination-type": "SERVICE_CIDR_BLOCK",
"icmp-options": null,
"is-stateless": false,
"protocol": "all",
"tcp-options": null,
"udp-options": null
},
{
"description": "create_db_test",
"destination": "0.0.0.0/0",
"destination-type": "CIDR_BLOCK",
"icmp-options": null,
"is-stateless": false,
"protocol": "all",
"tcp-options": null,
"udp-options": null
}
],
"freeform-tags": {},
"id": "ocid1.securitylist.oc1.ap-tokyo-1.aaa...66csla",
"ingress-security-rules": [
{
"description": "create_db_test",
"icmp-options": null,
"is-stateless": false,
"protocol": "all",
"source": "oci-nrt-objectstorage",
"source-type": "SERVICE_CIDR_BLOCK",
"tcp-options": null,
"udp-options": null
}
],

"lifecycle-state": "AVAILABLE",
"time-created": "2024-03-22T02:26:51.986000+00:00",
"vcn-id": "ocid1.vcn.oc1.ap-tokyo-1.ama..."
},
"etag": "xxxxxxxx"
}
########################################
# 03.5.セキュリティルール(エグレス)の事後確認
########################################
2024/06/13 02:37:38
etag: xxxxxxxx
+--------------+---------------------+-----------------------+-------------+---------+--------+--------+----------------+
| 01_Stateless | 02_Destination-type | 03_Destination | 04_Protocol | 05_ICMP | 06_TCP | 07_UDP | Description |
+--------------+---------------------+-----------------------+-------------+---------+--------+--------+----------------+
| False | SERVICE_CIDR_BLOCK | oci-nrt-objectstorage | all | None | None | None | create_db_test |
| False | CIDR_BLOCK | 0.0.0.0/0 | all | None | None | None | create_db_test |

+--------------+---------------------+-----------------------+-------------+---------+--------+--------+----------------+
########################################
# 03.6.セキュリティルール(イングレス)の事後確認
########################################
2024/06/13 02:37:40
etag: xxxxxxxx
+--------------+--------------------+-----------------------+-------------+---------+--------+--------+----------------+
| 01_Stateless | 02_Source-type | 03_Source | 04_Protocol | 05_ICMP | 06_TCP | 07_UDP | Description |
+--------------+--------------------+-----------------------+-------------+---------+--------+--------+----------------+
| False | SERVICE_CIDR_BLOCK | oci-nrt-objectstorage | all | None | None | None | create_db_test |
+--------------+--------------------+-----------------------+-------------+---------+--------+--------+----------------+

実行結果の事前の確認より、デフォルトのセキュリティリストにはデフォルトのセキュリティルールが構成されていることを確認できます。

セキュリティルールの更新時もルートルールと同様に、「既存のルールが全て置き換えられるため、続行するか」といった内容の警告文が出力されるため、既存の設定値の確認後に y を入力します。

※セキュリティルールを追加する構文は執筆時点(2024年7月2日)では存在しません。
 既存のルールを含めて新しいルールに置換されるため、注意が必要です。

設定後の確認結果より、デフォルトのセキュリティリストにオブジェクトストレージへのルールが構成されたことを確認できます。


最後に、ルール変更の作業前後でサブネットに紐づくルート表とセキュリティリストが変化していないことを確認します。
確認には「04_check_vcn_after.sh」を実行します。

# 実行結果
xxxxxxxxxx@cloudshell:03_create_paas (ap-tokyo-1)$ . 04_check_vcn_after.sh | tee 04_check_vcn_after.log
########################################
# 04.1.サブネットの情報確認
########################################
2024/06/13 02:37:45
+----------------------------+---------------+-------------------------------+----------------------------------------------+----------------------------------------------------+-------------------+----------------------------------+
| 01_Name | 02_CIDR_Block | 03_Prohibit_public_ip_on_vnic | 04_RouteTable | 05_SecurityList | 06_Lifecyclestate | 07_Created |
+----------------------------+---------------+-------------------------------+----------------------------------------------+----------------------------------------------------+-------------------+----------------------------------+
| subnet_ocicli_test_private | 10.0.2.0/24 | True | ocid1.routetable.oc1.ap-tokyo-1.aaa...hzk2ua | ['ocid1.securitylist.oc1.ap-tokyo-1.aaa...66csla'] | AVAILABLE | 2024-03-22T02:34:40.306000+00:00 |
| subnet_ocicli_test_public | 10.0.1.0/24 | False | ocid1.routetable.oc1.ap-tokyo-1.aaa...hzk2ua | ['ocid1.securitylist.oc1.ap-tokyo-1.aaa...66csla'] | AVAILABLE | 2024-03-22T02:29:15.033000+00:00 |
+----------------------------+---------------+-------------------------------+----------------------------------------------+----------------------------------------------------+-------------------+----------------------------------+
########################################
# 04.2.ルート表のOCID確認
########################################
2024/06/13 02:37:47
+------------------------------------+----------------------------------------------+
| 01_Name | 02_OCID |
+------------------------------------+----------------------------------------------+
| RT_ocicli_test_1 | ocid1.routetable.oc1.ap-tokyo-1.aaa...6mjsna |
| Default Route Table for ociclitest | ocid1.routetable.oc1.ap-tokyo-1.aaa...hzk2ua |
+------------------------------------+----------------------------------------------+
########################################
# 04.3.セキュリティリストのOCID確認
########################################
2024/06/13 02:37:49
+--------------------------------------+------------------------------------------------+
| 01_Name | 02_OCID |
+--------------------------------------+------------------------------------------------+
| SL_test_1 | ocid1.securitylist.oc1.ap-tokyo-1.aaa...z6c5lq |
| Default Security List for ociclitest | ocid1.securitylist.oc1.ap-tokyo-1.aaa...66csla |
+--------------------------------------+------------------------------------------------+


diffコマンドで作業前後のログを比較します。

# 実行結果
xxxxxxxxxx@cloudshell:03_create_paas (ap-tokyo-1)$ . diff 01*log 04*log
2c2
< # 01.1.サブネットの情報確認

> # 04.1.サブネットの情報確認
4c4
< 2024/06/13 02:37:03

> 2024/06/13 02:37:45
12c12
< # 01.2.ルート表のOCID確認

> # 04.2.ルート表のOCID確認
14c14
< 2024/06/13 02:37:05

> 2024/06/13 02:37:47
22c22
< # 01.3.セキュリティリストのOCID確認

> # 04.3.セキュリティリストのOCID確認
24c24
< 2024/06/13 02:37:06

> 2024/06/13 02:37:49

作業前後で、サブネットに紐づくルート表とセキュリティリストに変化がないことを確認できました。

2-2)データベースインスタンスの作成

2-2-1)データベースインスタンスの作成

データベースインスタンスを作成するには「05_create_database.sh」を実行します。実行の前に「1-2-2)パラメーター検討」で整理したパラメーターをシェルに追記します。

# 実行結果
xxxxxxxxxx@cloudshell:03_create_paas (ap-tokyo-1)$ . 05_create_database.sh | tee 05_create_database.log
########################################
# 05.1.データベースインスタンスの作成
########################################
2024/06/13 02:38:02
{
"data": {
"availability-domain": "xxxx:AP-TOKYO-1-AD-1",
"backup-network-nsg-ids": null,
"backup-subnet-id": null,
"cluster-name": null,
"compartment-id": "ocid1.compartment.oc1..aaa...",
"cpu-core-count": 2,
"data-collection-options": {
"is-diagnostics-events-enabled": false,
"is-health-monitoring-enabled": false,
"is-incident-logs-enabled": false
},
"data-storage-percentage": 80,
"data-storage-size-in-gbs": 512,
"database-edition": "STANDARD_EDITION",

"db-system-options": {
"storage-management": "ASM"
},
"defined-tags": {
"Oracle-Tags": {
"CreatedBy": "xxxxxxxxxx",
"CreatedOn": "2024-06-11T01:06:08.364Z"
}
},
"disk-redundancy": "HIGH",
"display-name": "ocicli_test_db",
"domain": "ociclitestpri.ociclitest1.oraclevcn.com",
"fault-domains": [
"FAULT-DOMAIN-1"
],
"freeform-tags": {},
"gi-software-image-id": null,
"hostname": "ociclitestdb",
"id": "ocid1.dbsystem.oc1.ap-tokyo-1.anx...",
"iorm-config-cache": null,
"kms-key-id": null,
"last-maintenance-run-id": null,
"last-patch-history-entry-id": null,
"license-model": "BRING_YOUR_OWN_LICENSE",
"lifecycle-details": null,
"lifecycle-state": "PROVISIONING",
"listener-port": 1521,
"maintenance-window": null,
"memory-size-in-gbs": 32,
"next-maintenance-run-id": null,
"node-count": 1,
"nsg-ids": null,
"os-version": null,
"point-in-time-data-disk-clone-timestamp": null,
"reco-storage-size-in-gb": 256,
"scan-dns-name": null,
"scan-dns-record-id": null,
"scan-ip-ids": null,
"shape": "VM.Standard.E4.Flex",
"source-db-system-id": null,
"sparse-diskgroup": null,
"ssh-public-keys": [
"ssh-rsa AAA..."
],
"storage-volume-performance-mode": "BALANCED",
"subnet-id": "ocid1.subnet.oc1.ap-tokyo-1.aaa...",
"time-created": "2024-06-11T01:06:08.728000+00:00",
"time-zone": "UTC",
"version": null,
"vip-ids": null,
"zone-id": null
},
"etag": "xxxxxxxx",
"opc-work-request-id": "ocid1.coreservicesworkrequest.oc1.ap-tokyo-1.abx..."
}

実行結果より、”lifecycle-state”の項目が”PROVISIONING”であり、データベースインスタンスが作成中であることを確認できます。また、”reco-storage-size-in-gb”の項目は”256”と表示されており、設定したストレージサイズ(512 GB)の半分の値でRECO領域が作成されていることも確認できます。

ここで、最後に表示された作業リクエストのOCID(opc-work-request-id)を、インスタンス作成の進捗を確認する「06_check_create_db_progress.sh」に追記します。


なお、「2-1)ルーティング、FW設定」の事前設定が実施されていない場合、「05_create_database.sh」の実行時に以下のエラーが発生します。

# オブジェクトストレージへのルーティング設定、FW設定がされていない場合に発生するエラー
ServiceError:
{
"client_version": "Oracle-PythonSDK/2.127.0, Oracle-PythonCLI/3.42.0", "code": "InvalidParameter",
"logging_tips": "Please run the OCI CLI command using --debug flag to find more debug information.",
"message": "Cannot access Object Storage using the subnet with the following OCID: ocid1.subnet.oc1.ap-tokyo-1.aaa.... Review your VCN configuration. If you need further assistance, contact Oracle Support.",
"opc-request-id": "XXXXX...",
"operation_name": "launch_db_system",
"request_endpoint": "POST https://database.ap-tokyo-1.oraclecloud.com/20160918/dbSystems",
"status": 400,
"target_service": "database",
"timestamp": "2024-06-07T07:30:03.950188+00:00",
"troubleshooting_tips": "See [https://docs.oracle.com/iaas/Content/API/References/apierrors.htm] for more information about resolving this error. If you are unable to resolve this issue, run this CLI command with --debug option and contact Oracle support and provide them the full error message."
}

2-2-2)作業リクエストの進捗確認

データベースインスタンス作成時の作業リクエストの進捗を確認するには、「06_check_create_db_progress.sh」を実行します。
まずは作成直後に実行してみます。

# 実行結果
xxxxxxxxxx@cloudshell:03_create_paas (ap-tokyo-1)$ . 06_check_create_db_progress.sh | tee 06_check_create_db_progress_`date "+%Y_%m_%d_%H_%M_%S"`.log
########################################
# 06.1.作業リクエストの進捗
########################################
2024/06/13 02:39:28
+------------------+------------------+-------------+----------------------------------+-------------+
| 01_Operation | 02_Progress_Rate | 03_Status | 04_Started | 05_Finished |
+------------------+------------------+-------------+----------------------------------+-------------+
| Create DB System | 2.0 | IN_PROGRESS | 2024-06-11T01:06:34.199000+00:00 | None |
+------------------+------------------+-------------+----------------------------------+-------------+
########################################
# 06.2.OCID確認
########################################
2024/06/13 02:39:29
+--------------+-------------+-------------------------------------------------------------------------------------------------+
| 01_Operation | 02_Status | 03_Entity-URL |
+--------------+-------------+-------------------------------------------------------------------------------------------------+
| dbSystem | IN_PROGRESS | /20160918/dbSystems/ocid1.dbsystem.oc1.ap-tokyo-1.anx... | ocid1.dbsystem.oc1.ap-tokyo-1.anx... |
| node | IN_PROGRESS | /20160918/dbNodes/ocid1.dbnode.oc1.ap-tokyo-1.anx... | ocid1.dbnode.oc1.ap-tokyo-1.anx... |

| dbHome | IN_PROGRESS | /20160918/dbHomes/ocid1.dbhome.oc1.ap-tokyo-1.anx... | ocid1.dbhome.oc1.ap-tokyo-1.anx... |
| database | IN_PROGRESS | /20160918/databases/ocid1.database.oc1.ap-tokyo-1.anx... | ocid1.database.oc1.ap-tokyo-1.anx... |
+--------------+-------------+-------------------------------------------------------------------------------------------------+

実行結果より、全体の進捗としては2%となっています。

作成から10分後にもう一度実行してみます。

# 実行結果
xxxxxxxxxx@cloudshell:03_create_paas (ap-tokyo-1)$ . 06_check_create_db_progress.sh | tee 06_check_create_db_progress_`date "+%Y_%m_%d_%H_%M_%S"`.log
########################################
# 06.1.作業リクエストの進捗
########################################
2024/06/13 02:49:34
+------------------+------------------+-------------+----------------------------------+-------------+
| 01_Operation | 02_Progress_Rate | 03_Status | 04_Started | 05_Finished |
+------------------+------------------+-------------+----------------------------------+-------------+
| Create DB System | 42.0 | IN_PROGRESS | 2024-06-11T01:06:34.199000+00:00 | None |
+------------------+------------------+-------------+----------------------------------+-------------+
########################################
# 06.2.OCID確認
########################################
2024/06/13 02:49:35
+--------------+-------------+----------------------------------------------------------+--------------------------------------+
| 01_Operation | 02_Status | 03_Entity-URL | 04_OCID |
+--------------+-------------+----------------------------------------------------------+--------------------------------------+
| dbSystem | IN_PROGRESS | /20160918/dbSystems/ocid1.dbsystem.oc1.ap-tokyo-1.anx... | ocid1.dbsystem.oc1.ap-tokyo-1.anx... |
| node | IN_PROGRESS | /20160918/dbNodes/ocid1.dbnode.oc1.ap-tokyo-1.anx... | ocid1.dbnode.oc1.ap-tokyo-1.anx... |

| dbHome | IN_PROGRESS | /20160918/dbHomes/ocid1.dbhome.oc1.ap-tokyo-1.anx... | ocid1.dbhome.oc1.ap-tokyo-1.anx... |
| database | IN_PROGRESS | /20160918/databases/ocid1.database.oc1.ap-tokyo-1.anx... | ocid1.database.oc1.ap-tokyo-1.anx... |
+--------------+-------------+----------------------------------------------------------+--------------------------------------+

実行結果より、全体の進捗は42%まで進みました。

作成から1時間後にもう一度実行してみます。

# 実行結果
xxxxxxxxxx@cloudshell:03_create_paas (ap-tokyo-1)$ . 06_check_create_db_progress.sh | tee 06_check_create_db_progress_`date "+%Y_%m_%d_%H_%M_%S"`.log
########################################
# 06.1.作業リクエストの進捗
########################################
2024/06/13 03:44:04
+------------------+------------------+-----------+----------------------------------+----------------------------------+
| 01_Operation | 02_Progress_Rate | 03_Status | 04_Started | 05_Finished |
+------------------+------------------+-----------+----------------------------------+----------------------------------+
| Create DB System | 100.0 | SUCCEEDED | 2024-06-11T01:06:34.199000+00:00 | 2024-06-11T02:08:49.070000+00:00 |
+------------------+------------------+-----------+----------------------------------+----------------------------------+
########################################
# 06.2.OCID確認
########################################
2024/06/13 03:44:05
+--------------+-------------+----------------------------------------------------------+--------------------------------------+
| 01_Operation | 02_Status | 03_Entity-URL | 04_OCID
|
+--------------+-------------+----------------------------------------------------------+--------------------------------------+
| dbSystem | IN_PROGRESS | /20160918/dbSystems/ocid1.dbsystem.oc1.ap-tokyo-1.anx... | ocid1.dbsystem.oc1.ap-tokyo-1.anx... |
| node | IN_PROGRESS | /20160918/dbNodes/ocid1.dbnode.oc1.ap-tokyo-1.anx... | ocid1.dbnode.oc1.ap-tokyo-1.anx... |

| dbHome | IN_PROGRESS | /20160918/dbHomes/ocid1.dbhome.oc1.ap-tokyo-1.anx... | ocid1.dbhome.oc1.ap-tokyo-1.anx... |
| database | IN_PROGRESS | /20160918/databases/ocid1.database.oc1.ap-tokyo-1.anx... | ocid1.database.oc1.ap-tokyo-1.anx... |
+--------------+-------------+----------------------------------------------------------+--------------------------------------+

実行結果より、全体の進捗が100%となり、”03_Status”の項目が”SUCCEEDED”となったことを確認できます。”04_Started”と”05_Finished”を比較すると1時間程度で作成が完了しています。

次のステップで、作成が完了したデータベースのパラメーター確認と起動停止に使用するため、以下のOCIDをエディタにメモしておきます。
・データベースシステムのOCID
・データベースノードのOCID

2-2-3)データベースインスタンスの確認

データベースインスタンスを確認するには「07_check_database.sh」を実行します。
実行の前に「2-2-2)作業リクエストの進捗確認」で確認したデータベースシステムのOCIDを「07_check_database.sh」に追記します。

# 実行結果
xxxxxxxxxx@cloudshell:03_create_paas (ap-tokyo-1)$ . 07_check_database.sh | tee 07_check_database.log
########################################
# 07.1.データベースインスタンスの詳細確認
########################################
2024/06/13 03:47:27
{
"data": {
"availability-domain": "xxxx:AP-TOKYO-1-AD-1",
"backup-network-nsg-ids": null,
"backup-subnet-id": null,
"cluster-name": null,
"compartment-id": "ocid1.compartment.oc1..aaa...",
"cpu-core-count": 2,
"data-collection-options": {
"is-diagnostics-events-enabled": false,
"is-health-monitoring-enabled": false,
"is-incident-logs-enabled": false
},
"data-storage-percentage": 80,
"data-storage-size-in-gbs": 512,
"database-edition": "STANDARD_EDITION",

"db-system-options": {
"storage-management": "ASM"
},
"defined-tags": {
"Oracle-Tags": {
"CreatedBy": "xxxxxxxxxx",
"CreatedOn": "2024-06-11T01:06:08.364Z"
}
},
"disk-redundancy": "HIGH",
"display-name": "ocicli_test_db",
"domain": "ociclitestpri.ociclitest1.oraclevcn.com",
"fault-domains": [
"FAULT-DOMAIN-1"
],
"freeform-tags": {},
"gi-software-image-id": null,
"hostname": "ociclitestdb",
"id": "ocid1.dbsystem.oc1.ap-tokyo-1.anx...",
"iorm-config-cache": null,
"kms-key-id": null,
"last-maintenance-run-id": null,
"last-patch-history-entry-id": null,
"license-model": "BRING_YOUR_OWN_LICENSE",
"lifecycle-details": null,
"lifecycle-state": "AVAILABLE",
"listener-port": 1521,
"maintenance-window": null,
"memory-size-in-gbs": 32,
"next-maintenance-run-id": null,
"node-count": 1,
"nsg-ids": null,
"os-version": null,
"point-in-time-data-disk-clone-timestamp": null,
"reco-storage-size-in-gb": 256,
"scan-dns-name": "ociclitestdb-scan.ociclitestpri.ociclitest1.oraclevcn.com",
"scan-dns-record-id": "ocid1.vcndnsrecord.oc1.ap-tokyo-1.abx...",
"scan-ip-ids": null,
"shape": "VM.Standard.E4.Flex",
"source-db-system-id": null,
"sparse-diskgroup": null,
"ssh-public-keys": [
"ssh-rsa AAA..."
],
"storage-volume-performance-mode": "BALANCED",
"subnet-id": "ocid1.subnet.oc1.ap-tokyo-1.aaa...",
"time-created": "2024-06-11T01:06:08.728000+00:00",
"time-zone": "UTC",
"version": "19.22.0.0.0",
"vip-ids": null,
"zone-id": "ocid1.dns-zone.oc1.ap-tokyo-1.aaa..."
},
"etag": "xxxxxxxx--gzip"
}

実行結果より、”lifecycle-state”の項目が”AVAILABLE”であり、データベースインスタンスの作成が完了したことを確認できます。
データベースインスタンス作成時の実行結果と比較すると、DNS関連の設定とデータベースのバージョンの項目に値が入っていることも確認できます。

以上で指定したパラメーターが全て反映され、データベースインスタンスの作成が完了したことを確認できました。

2-3)データベースノードの起動停止

最後に、作成したデータベースノードの落とし上げの動作確認をします。

データベースノードを停止するには「08_stop_database_node.sh」を実行、起動するには「09_start_database_node.sh」を実行します。

実行の前に「2-2-2)作業リクエストの進捗確認」で確認したデータベースノードのOCIDを「08_stop_database_node.sh」と「09_start_database_node.sh」に追記します。

2-3-1)データベースノードの停止

はじめに、現在起動しているデータベースノードを停止します。

# 実行結果
xxxxxxxxxx@cloudshell:03_create_paas (ap-tokyo-1)$ . 08_stop_database_node.sh | tee 08_stop_database_node_`date "+%Y_%m_%d_%H_%M_%S"`.log
########################################
# 08.1.データベースノードの起動状態確認
########################################
2024/06/13 03:47:34
etag: xxxxxxxx--gzip
+--------------+-----------+------------------------------------+----------------------------------+
| 01_Hostname | 02_Status | 03_OCID | 04_Created |
+--------------+-----------+------------------------------------+----------------------------------+
| ociclitestdb | AVAILABLE | ocid1.dbnode.oc1.ap-tokyo-1.anx... | 2024-06-11T01:06:08.732000+00:00 |
+--------------+-----------+------------------------------------+----------------------------------+
########################################
# 08.2.データベースノードの停止
########################################
2024/06/13 03:47:36
Action completed. Waiting until the resource has entered state: ('STOPPED',)
{
"data": {
"additional-details": null,
"backup-ip-id": null,
"backup-vnic-id": null,
"backup-vnic2-id": null,
"cpu-core-count": 2,
"db-node-storage-size-in-gbs": null,
"db-server-id": null,
"db-system-id": "ocid1.dbsystem.oc1.ap-tokyo-1.anx...",
"defined-tags": null,
"fault-domain": "FAULT-DOMAIN-1",
"freeform-tags": null,
"host-ip-id": null,
"hostname": "ociclitestdb",
"id": "ocid1.dbnode.oc1.ap-tokyo-1.anx...",
"lifecycle-details": null,
"lifecycle-state": "STOPPED",
"maintenance-type": null,
"memory-size-in-gbs": null,
"software-storage-size-in-gb": 200,
"time-created": "2024-06-11T01:06:08.732000+00:00",
"time-maintenance-window-end": null,
"time-maintenance-window-start": null,
"vnic-id": "ocid1.vnic.oc1.ap-tokyo-1.abx...",
"vnic2-id": null
},
"etag": "xxxxxxxx--gzip"
}

実行結果より、起動していたデータベースノードが停止したことが分かります。

2-3-2)データベースノードの起動

次に、ノードを起動します。

# 実行結果
xxxxxxxxxx@cloudshell:03_create_paas (ap-tokyo-1)$ . 09_start_database_node.sh | tee 09_start_database_node_`date "+%Y_%m_%d_%H_%M_%S"`.log
########################################
# 09.1.データベースノードの起動状態確認
########################################
2024/06/13 03:50:20
etag: 9e9a1f0c--gzip
+--------------+-----------+------------------------------------+----------------------------------+
| 01_Hostname | 02_Status | 03_OCID | 04_Created |
+--------------+-----------+------------------------------------+----------------------------------+
| ociclitestdb | STOPPED | ocid1.dbnode.oc1.ap-tokyo-1.anx... | 2024-06-11T01:06:08.732000+00:00 |
+--------------+-----------+------------------------------------+----------------------------------+
########################################
# 09.2.データベースノードの起動
########################################
2024/06/13 03:50:21
Action completed. Waiting until the resource has entered state: ('AVAILABLE',)
{
"data": {
"additional-details": null,
"backup-ip-id": null,
"backup-vnic-id": null,
"backup-vnic2-id": null,
"cpu-core-count": 2,
"db-node-storage-size-in-gbs": null,
"db-server-id": null,
"db-system-id": "ocid1.dbsystem.oc1.ap-tokyo-1.anx...",
"defined-tags": null,
"fault-domain": "FAULT-DOMAIN-1",
"freeform-tags": null,
"host-ip-id": null,
"hostname": "ociclitestdb",
"id": "ocid1.dbnode.oc1.ap-tokyo-1.anx...",
"lifecycle-details": null,
"lifecycle-state": "AVAILABLE",
"maintenance-type": null,
"memory-size-in-gbs": null,
"software-storage-size-in-gb": 200,
"time-created": "2024-06-11T01:06:08.732000+00:00",
"time-maintenance-window-end": null,
"time-maintenance-window-start": null,
"vnic-id": "ocid1.vnic.oc1.ap-tokyo-1.abx...",
"vnic2-id": null
},
"etag": "xxxxxxxx--gzip"
}

実行結果より、停止していたデータベースノードが起動したことが分かります。
データベースノードの起動、停止も確認できました。

最後に作業ログの確認をします。

# 実行結果
xxxxxxxxxx@cloudshell:03_create_paas (ap-tokyo-1)$ ls -l
total 88
-rw-r--r--. 1 xxxxxxxxxx oci 4046 Jun 13 02:37 01_check_vcn_before.log
-rw-r--r--. 1 xxxxxxxxxx oci 1756 Jun 13 02:22 01_check_vcn_before.sh
-rw-r--r--. 1 xxxxxxxxxx oci 3794 Jun 13 02:37 02_update_routerule.log
-rw-r--r--. 1 xxxxxxxxxx oci 1675 Jun 13 02:26 02_update_routerule.sh
-rw-r--r--. 1 xxxxxxxxxx oci 8653 Jun 13 02:37 03_update_securityrule.log
-rw-r--r--. 1 xxxxxxxxxx oci 3719 Jun 13 02:29 03_update_securityrule.sh
-rw-r--r--. 1 xxxxxxxxxx oci 4046 Jun 13 02:37 04_check_vcn_after.log
-rw-r--r--. 1 xxxxxxxxxx oci 1756 Jun 13 02:30 04_check_vcn_after.sh
-rw-r--r--. 1 xxxxxxxxxx oci 2977 Jun 13 02:38 05_create_database.log
-rw-r--r--. 1 xxxxxxxxxx oci 1144 Jun 13 02:31 05_create_database.sh
-rw-r--r--. 1 xxxxxxxxxx oci 2667 Jun 13 02:39 06_check_create_db_progress_2024_06_13_02_39_28.log
-rw-r--r--. 1 xxxxxxxxxx oci 2667 Jun 13 02:49 06_check_create_db_progress_2024_06_13_02_49_34.log
-rw-r--r--. 1 xxxxxxxxxx oci 2746 Jun 13 03:44 06_check_create_db_progress_2024_06_13_03_44_04.log
-rw-r--r--. 1 xxxxxxxxxx oci 1001 Jun 13 02:39 06_check_create_db_progress.sh
-rw-r--r--. 1 xxxxxxxxxx oci 3096 Jun 13 03:47 07_check_database.log
-rw-r--r--. 1 xxxxxxxxxx oci 326 Jun 13 03:46 07_check_database.sh
-rw-r--r--. 1 xxxxxxxxxx oci 2126 Jun 13 03:49 08_stop_database_node_2024_06_13_03_47_34.log
-rw-r--r--. 1 xxxxxxxxxx oci 777 Jun 13 03:46 08_stop_database_node.sh
-rw-r--r--. 1 xxxxxxxxxx oci 2128 Jun 13 03:52 09_start_database_node_2024_06_13_03_50_20.log
-rw-r--r--. 1 xxxxxxxxxx oci 780 Jun 13 03:47 09_start_database_node.sh
drwxr-xr-x. 2 xxxxxxxxxx oci 40 Jun 7 01:45 sshkey

xxxxxxxxxx@cloudshell:03_create_paas (ap-tokyo-1)$ more *log
-- 割愛

コンソールに出力された実行結果がファイルに出力されて、正常にログが取得できていることも確認できました。

3)あとがき

今回はOCI CLIを用いたデータベースインスタンスの作成方法についてご紹介しました。

データベースインスタンスは、コンピュートインスタンスやネットワークリソースと比べて、指定する項目や検討する項目が大幅に増えています。
シェル化することで、作業時の工数を削減し、実行結果の確認や管理を簡易化できています。
これにより、CLIのメリットが得られているのではないでしょうか。

今後は、作成したインスタンスへの接続設定や確認方法などをご紹介する予定です。

執筆者情報

ふかやけんじ プロフィール画像

2024年に中途入社。前職では主にOracleのオンプレミス環境の設計構築から運用保守と幅広い業務を経験。現在はOCIのポストセールス業務を中心に担当。趣味はパフェ巡り。


■本記事の内容について
 本記事に示した定義及び条件は変更される場合があります。あらかじめご了承ください。

■商標に関して
 ・Oracle®、Java、MySQL及びNetSuiteは、Oracle、その子会社及び関連会社の米国及びその他の国における登録商標です。
 ・Amazon Web Services、AWS、Powered by AWS ロゴ、[およびかかる資料で使用されるその他の AWS 商標] は、Amazon.com, Inc. またはその関連会社の商標です。
  文中の社名、商品名等は各社の商標または登録商標である場合があります。

関連している記事

  • Oracle Cloud
  • Exadata
  • Oracle Database
2025.02.07

OCIに待望のPaaSサービスがリリース!特徴やメリットを解説

「Oracle CloudWorld 2024」にてリリースされたOracle Cloudの注目のPaaSサービス「Oracle Exadata Database Service on Exascale Infrastructure(ExaDB-XS)」の特徴をまとめてみました!

  • AWS
  • Oracle Cloud
  • Oracle Database
  • Exadata
2025.01.23

アーキテクチャ解説&予想!Oracle Database@AWS解析白書②

2024年12月1日、ついにOracle Database@AWSがLimited Previewにて提供されました!今回は現時点で判明している情報について、ドキュメントを読み解きながらOracle Database@AWSのアーキテクチャの予想も交えてお伝えします。

  • Oracle Database
  • Oracle Cloud
2024.12.23

Autonomous Database 23ai 新機能!Select AIでSQLやデータを自動生成!

Oracle Database 23aiでは生成AIに関連する新機能が多く追加。特にAutonomous Database 23aiの「Select AI」機能は大規模言語モデル(LLM)を使用して、自然言語による問い合わせやテストデータの自動生成が可能に。本記事では、Select AIの機能について検証結果を交えて紹介します。

ページの先頭へ戻る