2022年11月22日火曜日

Oracle APEXの環境作成(7) - 仮想マシンのOCIエクスポート対応

更新: 2026年2月5日

作成した仮想マシンをOracle Cloud Infrastructureのコンピュート・インスタンスとして実行できるように変更します。

シリアル・コンソールの構成



/etc/default/grubを編集し、シリアル・コンソールで接続できるようにします。

GRUB_TERMINAL_OUTPUTの行を削除します。

以下の2行を追加します。

GRUB_TERMINAL="serial console"
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200"

最終的な/etc/default/grubの内容は、以下のようになります。

ARM 64-bit:
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=ol/root rd.lvm.lv=ol/swap rhgb quiet numa=off transparent_hugepage=madvise"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true
GRUB_TERMINAL="serial console"
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200"
x86_64:
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_CMDLINE_LINUX="crashkernel=1G-64G:448M,64G-:512M resume=/dev/mapper/ol-swap rd.lvm.lv=ol/root rd.lvm.lv=ol/swap numa=off transparent_hugepage=madvise"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true
GRUB_TERMINAL="serial console"
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200"
GRUBの構成ファイルを生成します。生成後は動作を確認するため、一旦仮想マシンを停止します。

grub2-mkconfig -o /boot/grub2/grub.cfg

[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg

Generating grub configuration file ...

Adding boot menu entry for EFI firmware configuration

done

[root@localhost ~]# 


ARM 64-bitではttyAMA0x86_64ではttyS0をシリアル・コンソールとして設定します。

ARM 64-bit: grubby --update-kernel=ALL --args="console=tty1 console=ttyAMA0,115200n8"
x86_64: grubby --update-kernel=ALL --args="console=tty1 console=ttyS0,115200n8"

以下はARM 64-bitでの実行例です。

[root@localhost ~]# grubby --update-kernel=ALL --args="console=tty1 console=ttyAMA0,115200n8"

[root@localhost ~]# 


ターミナルttyS0またはttyAMA0のgettyサービスを有効にします。

ARM 64-bit: systemctl enable serial-getty@ttyAMA0.service
x86_64: systemctl enable serial-getty@ttyS0.service

以下はARM 64-bitでの実行例です。

[root@localhost ~]# systemctl enable serial-getty@ttyAMA0.service

Created symlink /etc/systemd/system/getty.target.wants/serial-getty@ttyAMA0.service → /usr/lib/systemd/system/serial-getty@.service.

[root@localhost ~]# 


仮想マシンを停止します。

shutdown -h now

[root@localhost ~]# shutdown -h now

[root@localhost ~]# Connection to localhost closed by remote host.

Connection to localhost closed.

~ % 


仮想マシンのシリアル・ポートを有効にします。

ARMの仮想マシンの場合、現在のVirtualBox 7.2.4ではシリアル・ポートを有効にできません。シリアルポートへ出力はできますが、キーボード・イベントが無視されるため、シリアルポートからログインできません。それでも、ARMの仮想マシンのシリアルポートは構成します。

仮想マシンの一般を開きます。


シリアルポートの設定は高度に含まれます。

シリアルポートの中のポート1を選択します。

シリアルポートを有効化チェックを入れます

x86_64の仮想マシンの場合、ポート番号COM1にします。

ポートモードTCPにします。存在するパイプ/ソケットに接続チェックを外しパス/アドレスとしてホストで使用していないTCPのポート番号を指定します。以下の例では10023を指定しています。

以上を設定し、OKをクリックします。


ARM 64-bitの仮想マシンの場合、ポート番号ユーザー定義を選択し、IRQ12を設定します。ARMの仮想マシンにシリアルポートは無くUSBだと思うので、ポート番号ユーザー定義と考えられるのですが、現行のVirtualBoxで設定できるかどうかも含めて、正常に動作する設定は不明です。


仮想マシンを起動し、シリアル・ポートに接続します。ホスト・マシンからTCPで接続するため、telnetまたはncコマンドを使用します。

以下はncコマンドを使用して接続した例です。

nc localhost 10023

% nc localhost 10023


[メッセージ省略]


[  OK  ] Started Session c2 of User oracle.

[  OK  ] Started Session c3 of User oracle.

[  OK  ] Finished Crash recovery kernel arming.


Oracle Linux Server 9.7

Kernel 6.12.0-107.59.3.3.el9uek.x86_64 on an x86_64


localhost login: 


コンソールよりログイン・プロンプトが返ってきたら、構成完了です。

ARMのコンピュート・インスタンスでシリアルポートを有効にするため、cockpitをインストールします。これはARM限定の作業です。

dnf -y install cockpit-ws-310.6-1.0.1.el8_10 cockpit-system-310.6-1.0.1.el8_10 cockpit-storaged-310.3-3.0.1.el8_10 cockpit-packagekit-310.3-3.0.1.el8_10 cockpit-310.6-1.0.1.el8_10 cockpit-bridge-310.6-1.0.1.el8_10

[root@localhost ~]# dnf -y install cockpit-ws-310.6-1.0.1.el8_10 cockpit-system-310.6-1.0.1.el8_10 cockpit-storaged-310.3-3.0.1.el8_10 cockpit-packagekit-310.3-3.0.1.el8_10 cockpit-310.6-1.0.1.el8_10 cockpit-bridge-310.6-1.0.1.el8_10

Failed to set locale, defaulting to C.UTF-8

Last metadata expiration check: 4:51:01 ago on Tue Jan 27 12:22:25 2026.

Dependencies resolved.

================================================================================

 Package                   Arch    Version              Repository         Size

================================================================================

Installing:

 cockpit                   aarch64 310.6-1.0.1.el8_10   ol8_baseos_latest  90 k

 cockpit-bridge            aarch64 310.6-1.0.1.el8_10   ol8_baseos_latest 485 k

 cockpit-packagekit        noarch  310.3-3.0.1.el8_10   ol8_appstream     977 k

 cockpit-storaged          noarch  310.3-3.0.1.el8_10   ol8_appstream     902 k

 cockpit-system            noarch  310.6-1.0.1.el8_10   ol8_baseos_latest 5.2 M

 cockpit-ws                aarch64 310.6-1.0.1.el8_10   ol8_baseos_latest 974 k

Installing dependencies:


[中略]


  sos-4.10.1-2.0.1.el8_10.noarch                                                

  sscg-3.0.0-7.el8.aarch64                                                      

  tpm2-tools-4.1.1-5.el8.aarch64                                                

  tracer-common-1.1-1.el8.noarch                                                

  udisks2-iscsi-2.9.0-16.el8_10.1.aarch64                                       

  udisks2-lvm2-2.9.0-16.el8_10.1.aarch64                                        


Complete!

[root@localhost ~]# 


cockpitを自動起動させます。

systemctl enable cockpit.socket

[root@localhost ~]# systemctl enable cockpit.socket

Created symlink /etc/systemd/system/sockets.target.wants/cockpit.socket → /usr/lib/systemd/system/cockpit.socket.

[root@localhost ~]# 


以上でシリアル・コンソールの構成は完了です。


準仮想化ドライバの追加



スーパーユーザーで作業を実施します。

準仮想化ドライバを組み込みます。ARM 64-bitでは、Oracle CloudのネイティブのARMインスタンスに組み込まれている準仮想化ドライバを組み込んでいます。

以下はARMでの実行例です。

dracut --logfile /var/log/dracut.log --force --add-drivers "virtio_blk virtio-rng virtio_console virtio_crypto virtio_net virtio_scsi virtio_pci virtio_pci_legacy_dev virtio_pci_modern_dev virtio_vdpa virtiofs 9pnet_virtio"

[root@localhost ~]# dracut --logfile /var/log/dracut.log --force --add-drivers "virtio_blk virtio-rng virtio_console virtio_crypto virtio_net virtio_scsi virtio_pci virtio_pci_legacy_dev virtio_pci_modern_dev virtio_vdpa virtiofs 9pnet_virtio"

[root@localhost ~]# 


x86_64での実行例です。ログファイルのエラーは無視できます。

dracut --logfile /var/log/dracut.log --force --add qemu

[root@localhost ~]# dracut --logfile /var/log/dracut.log --force --add qemu

dracut: touch /var/log/dracut.log failed.

[root@localhost ~]# 


組み込まれた準仮想化ドライバを確認します。

lsinitrd | grep virtio

ARM 64-bitでの確認結果です。

[root@localhost ~]# lsinitrd | grep virtio

Arguments: --logfile --force --add-drivers 'virtio_blk virtio-rng virtio_console virtio_crypto virtio_net virtio_scsi virtio_pci virtio_pci_legacy_dev virtio_pci_modern_dev virtio_vdpa virtiofs 9pnet_virtio'

-rw-r--r--   1 root     root        16668 Dec 18 14:04 usr/lib/modules/5.15.0-316.196.4.1.el8uek.aarch64/kernel/drivers/block/virtio_blk.ko.xz

-rw-r--r--   1 root     root         8280 Dec 18 14:04 usr/lib/modules/5.15.0-316.196.4.1.el8uek.aarch64/kernel/drivers/char/hw_random/virtio-rng.ko.xz

-rw-r--r--   1 root     root        23164 Dec 18 14:04 usr/lib/modules/5.15.0-316.196.4.1.el8uek.aarch64/kernel/drivers/char/virtio_console.ko.xz

drwxr-xr-x   2 root     root            0 Dec 18 14:04 usr/lib/modules/5.15.0-316.196.4.1.el8uek.aarch64/kernel/drivers/crypto/virtio

-rw-r--r--   1 root     root        18796 Dec 18 14:04 usr/lib/modules/5.15.0-316.196.4.1.el8uek.aarch64/kernel/drivers/crypto/virtio/virtio_crypto.ko.xz

-rw-r--r--   1 root     root        54160 Dec 18 14:04 usr/lib/modules/5.15.0-316.196.4.1.el8uek.aarch64/kernel/drivers/net/virtio_net.ko.xz

-rw-r--r--   1 root     root        16044 Dec 18 14:04 usr/lib/modules/5.15.0-316.196.4.1.el8uek.aarch64/kernel/drivers/scsi/virtio_scsi.ko.xz

drwxr-xr-x   2 root     root            0 Dec 18 14:04 usr/lib/modules/5.15.0-316.196.4.1.el8uek.aarch64/kernel/drivers/virtio

-rw-r--r--   1 root     root        16092 Dec 18 14:04 usr/lib/modules/5.15.0-316.196.4.1.el8uek.aarch64/kernel/drivers/virtio/virtio_pci.ko.xz

-rw-r--r--   1 root     root         6896 Dec 18 14:04 usr/lib/modules/5.15.0-316.196.4.1.el8uek.aarch64/kernel/drivers/virtio/virtio_pci_legacy_dev.ko.xz

-rw-r--r--   1 root     root         9636 Dec 18 14:04 usr/lib/modules/5.15.0-316.196.4.1.el8uek.aarch64/kernel/drivers/virtio/virtio_pci_modern_dev.ko.xz

-rw-r--r--   1 root     root        28124 Dec 18 14:04 usr/lib/modules/5.15.0-316.196.4.1.el8uek.aarch64/kernel/drivers/virtio/virtio_vdpa.ko.xz

-rw-r--r--   1 root     root        28820 Dec 18 14:04 usr/lib/modules/5.15.0-316.196.4.1.el8uek.aarch64/kernel/fs/fuse/virtiofs.ko.xz

-rw-r--r--   1 root     root        29700 Dec 18 14:04 usr/lib/modules/5.15.0-316.196.4.1.el8uek.aarch64/kernel/net/9p/9pnet_virtio.ko.xz

[root@localhost ~]# 


x86_64での確認結果です。

[root@localhost ~]# lsinitrd | grep virtio

-rw-r--r--   1 root     root        16700 Dec 18 22:51 usr/lib/modules/6.12.0-107.59.3.3.el9uek.x86_64/kernel/drivers/block/virtio_blk.ko.xz

-rw-r--r--   1 root     root         4904 Dec 18 22:51 usr/lib/modules/6.12.0-107.59.3.3.el9uek.x86_64/kernel/drivers/char/hw_random/virtio-rng.ko.xz

-rw-r--r--   1 root     root        19888 Dec 18 22:51 usr/lib/modules/6.12.0-107.59.3.3.el9uek.x86_64/kernel/drivers/char/virtio_console.ko.xz

-rw-r--r--   1 root     root        12608 Dec 18 22:51 usr/lib/modules/6.12.0-107.59.3.3.el9uek.x86_64/kernel/drivers/scsi/virtio_scsi.ko.xz

drwxr-xr-x   2 root     root            0 Dec 18 22:51 usr/lib/modules/6.12.0-107.59.3.3.el9uek.x86_64/kernel/drivers/virtio

-rw-r--r--   1 root     root        22292 Dec 18 22:51 usr/lib/modules/6.12.0-107.59.3.3.el9uek.x86_64/kernel/drivers/virtio/virtio_mem.ko.xz

-rw-r--r--   1 root     root        19732 Dec 18 22:51 usr/lib/modules/6.12.0-107.59.3.3.el9uek.x86_64/kernel/drivers/virtio/virtio_pci.ko.xz

-rw-r--r--   1 root     root         4300 Dec 18 22:51 usr/lib/modules/6.12.0-107.59.3.3.el9uek.x86_64/kernel/drivers/virtio/virtio_pci_legacy_dev.ko.xz

-rw-r--r--   1 root     root         8156 Dec 18 22:51 usr/lib/modules/6.12.0-107.59.3.3.el9uek.x86_64/kernel/drivers/virtio/virtio_pci_modern_dev.ko.xz

[root@localhost ~]# 


以上で準仮想化ドライバの追加は完了です。


ova形式でのエクスポートの前に



仮想マシンをova形式でエクスポートする前に以下の作業を実施し、インポート後の構成作業を省略します。
以下の記事に従って、SQL Developer WebにユーザーPDBADMINで接続できるようにします。
ローカル環境のSQL Developer Webの管理者ユーザーを作成する

作成済みの仮想マシンにrootで接続し、ユーザーoracleに切り替えます。

su - oracle

[root@localhost ~]# su - oracle

Last login: Fri Jan 30 15:24:30 JST 2026

[oracle@localhost ~]$ 


ユーザーsysでfreepdb1に接続し、以下のスクリプトを実行します。


[oracle@localhost ~]$ . oraenv

ORACLE_SID = [oracle] ? FREE

The Oracle base has been set to /opt/oracle

[oracle@localhost ~]$ sqlplus sys/oracle@localhost/freepdb1 as sysdba


SQL*Plus: Release 23.26.0.0.0 - Production on Fri Jan 30 15:27:28 2026

Version 23.26.0.0.0


Copyright (c) 1982, 2025, Oracle.  All rights reserved.



Connected to:

Oracle AI Database 26ai Free Release 23.26.0.0.0 - Develop, Learn, and Run for Free

Version 23.26.0.0.0


SQL> set serveroutput on

begin

  for r in (select * from dba_role_privs)

  loop

    if r.grantee <> 'SYS' and r.grantee in ('ADMIN','PDBADMIN') then

      ords_admin.enable_schema(

        p_enabled => true,

        p_schema => r.grantee,

        p_url_mapping_type => 'BASE_PATH',

        p_url_mapping_pattern => lower(r.grantee),

        p_auto_rest_auth => true

      );

      dbms_output.put_line('Schema ' || r.grantee || ' is allowed to connect to SQL Developer Web.');

    end if;

  end loop;

  commit;

end;

/SQL>   2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17  

Schema PDBADMIN is allowed to connect to SQL Developer Web.


PL/SQL procedure successfully completed.


SQL> exit

Disconnected from Oracle AI Database 26ai Free Release 23.26.0.0.0 - Develop, Learn, and Run for Free

Version 23.26.0.0.0

[oracle@localhost ~]$ 


検証作業については、元記事を参照してください。

次に、以下の記事にそってDBMS_CLOUDファミリーのパッケージをインストールします。
Oracle Database Free 23ai 23.7にDBMS_CLOUDファミリーのパッケージをインストールする

catcon.plを使って、catclouduser.sqlを実行します。your-passwordの部分はsysのパスワードに置き換えます。
$ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u sys/your-password -force_pdb_mode 'READ WRITE' -b dbms_cloud_install -d $ORACLE_HOME/rdbms/admin/ -l /tmp catclouduser.sql

[oracle@localhost ~]$ $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u sys/oracle -force_pdb_mode 'READ WRITE' -b dbms_cloud_install -d $ORACLE_HOME/rdbms/admin/ -l /tmp catclouduser.sql

catcon::set_log_file_base_path: ALL catcon-related output will be written to [/tmp/dbms_cloud_install_catcon_3256.lst]


catcon::set_log_file_base_path: catcon: See [/tmp/dbms_cloud_install*.log] files for output generated by scripts


catcon::set_log_file_base_path: catcon: See [/tmp/dbms_cloud_install_*.lst] files for spool files, if any


catcon.pl: completed successfully

[oracle@localhost ~]$ 


続けて、catcon.plを使って、dbms_cloud_install.sqlを実行します。your-passwordの部分はsysのパスワードに置き換えます。
$ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u sys/your-password -force_pdb_mode 'READ WRITE' -b dbms_cloud_install -d $ORACLE_HOME/rdbms/admin/ -l /tmp dbms_cloud_install.sql

[oracle@localhost ~]$ $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u sys/oracle -force_pdb_mode 'READ WRITE' -b dbms_cloud_install -d $ORACLE_HOME/rdbms/admin/ -l /tmp dbms_cloud_install.sql

catcon::set_log_file_base_path: ALL catcon-related output will be written to [/tmp/dbms_cloud_install_catcon_3393.lst]


catcon::set_log_file_base_path: catcon: See [/tmp/dbms_cloud_install*.log] files for output generated by scripts


catcon::set_log_file_base_path: catcon: See [/tmp/dbms_cloud_install_*.lst] files for spool files, if any


catcon.pl: completed successfully

[oracle@localhost ~]$ 


検証作業については、元記事を参照してください。

主にCertbotをインストールするため、EPELのリポジトリを追加します。クラウドのコンピュート・インスタンスとして作成したOracle Linuxの環境の場合、EPELはデフォルトで構成されているため、不要な作業です。

dnf -y install epel-release

[root@localhost ~]# dnf -y install epel-release

Failed to set locale, defaulting to C.UTF-8

Last metadata expiration check: 1:22:46 ago on Fri Jan 30 14:16:01 2026.

Dependencies resolved.

===================================================================================================

 Package                       Architecture  Version                 Repository               Size

===================================================================================================

Installing:

 oracle-epel-release-el8       aarch64       1.0-5.el8               ol8_baseos_latest        15 k

Installing dependencies:

 yum-utils                     noarch        4.0.21-25.0.1.el8       ol8_baseos_latest        75 k


Transaction Summary

===================================================================================================

Install  2 Packages


Total download size: 90 k

Installed size: 41 k

Downloading Packages:

(1/2): oracle-epel-release-el8-1.0-5.el8.aarch64.rpm               2.9 kB/s |  15 kB     00:05    

(2/2): yum-utils-4.0.21-25.0.1.el8.noarch.rpm                       14 kB/s |  75 kB     00:05    

---------------------------------------------------------------------------------------------------

Total                                                               17 kB/s |  90 kB     00:05     

Running transaction check

Transaction check succeeded.

Running transaction test

Transaction test succeeded.

Running transaction

  Preparing        :                                                                           1/1 

  Installing       : yum-utils-4.0.21-25.0.1.el8.noarch                                        1/2 

  Installing       : oracle-epel-release-el8-1.0-5.el8.aarch64                                 2/2 

  Running scriptlet: oracle-epel-release-el8-1.0-5.el8.aarch64                                 2/2 

  Verifying        : oracle-epel-release-el8-1.0-5.el8.aarch64                                 1/2 

  Verifying        : yum-utils-4.0.21-25.0.1.el8.noarch                                        2/2 


Installed:

  oracle-epel-release-el8-1.0-5.el8.aarch64           yum-utils-4.0.21-25.0.1.el8.noarch          


Complete!

[root@localhost ~]# 


追加の構成作業は以上になります。


cloud-initの構成



作成したカスタム・イメージよりコンピュート・インスタンスを生成する際に、ユーザーopcが作成されるようcloud-initのスクリプトを準備しておきます。

dnf -y install cloud-init

[root@localhost ~]# dnf -y install cloud-init

Failed to set locale, defaulting to C.UTF-8

Last metadata expiration check: 0:16:04 ago on Tue Jan 27 17:16:19 2026.

Dependencies resolved.

================================================================================

 Package              Arch     Version                 Repository          Size

================================================================================

Installing:

 cloud-init           noarch   23.4-7.0.2.el8_10.11    ol8_appstream      1.3 M

Installing dependencies:

 bind-export-libs     aarch64  32:9.11.36-16.el8_10.6  ol8_baseos_latest  1.1 M

 dhcp-client          aarch64  12:4.3.6-50.el8_10      ol8_baseos_latest  306 k

 dhcp-common          noarch   12:4.3.6-50.el8_10      ol8_baseos_latest  207 k

 dhcp-libs            aarch64  12:4.3.6-50.el8_10      ol8_baseos_latest  145 k

 ipcalc               aarch64  0.2.4-4.el8             ol8_baseos_latest   38 k


[中略]

 

Installed:

  bind-export-libs-32:9.11.36-16.el8_10.6.aarch64                               

  cloud-init-23.4-7.0.2.el8_10.11.noarch                                        

  dhcp-client-12:4.3.6-50.el8_10.aarch64                                        

  dhcp-common-12:4.3.6-50.el8_10.noarch                                         

  dhcp-libs-12:4.3.6-50.el8_10.aarch64                                          

  ipcalc-0.2.4-4.el8.aarch64                                                    

  python3-babel-2.5.1-7.el8.noarch                                              

  python3-configobj-5.0.6-11.el8.noarch                                         

  python3-jinja2-2.10.1-7.el8_10.noarch                                         

  python3-jsonpatch-1.21-2.el8.noarch                                           

  python3-jsonpointer-1.10-11.el8.noarch                                        

  python3-jsonschema-2.6.0-4.el8.noarch                                         

  python3-jwt-1.6.1-2.el8.noarch                                                

  python3-markupsafe-0.23-19.el8.aarch64                                        

  python3-oauthlib-2.1.0-1.el8.noarch                                           

  python3-prettytable-0.7.2-14.el8.noarch                                       

  python3-pyserial-3.1.1-9.el8.noarch                                           

  python3-pytz-2017.2-11.0.1.el8.noarch                                         


Complete!

[root@localhost ~]# 


cloud-initのインストール後に作成されるディレクトリ/etc/cloud/cloud.cfg.dに、スクリプト99_oci.cfgをアップロードします。これは、OCIのコンピュート・インスタンスに標準で作成されているファイルです。
https://github.com/ujnak/apexapps/blob/master/cloud-init/99_oci.cfg

実際にはネイティブのインスタンスに含まれている99_oci.cfgを取り出して作成することを推奨します。

Rawファイルのリンクは以下です。
https://raw.githubusercontent.com/ujnak/apexapps/refs/heads/master/cloud-init/99_oci.cfg

cd /etc/cloud/cloud.cfg.d
curl -OL https://raw.githubusercontent.com/ujnak/apexapps/refs/heads/master/cloud-init/99_oci.cfg

[root@localhost ~]# cd /etc/cloud/cloud.cfg.d

[root@localhost cloud.cfg.d]# curl -OL https://raw.githubusercontent.com/ujnak/apexapps/refs/heads/master/cloud-init/99_oci.cfg

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

100  1661  100  1661        0    311      0  0:00:05  0:00:05 --:--:--   408

[root@localhost cloud.cfg.d]# 


VirtualBox向けのエクスポートを作成する場合、オペレーティング・システムの起動時にcloud-initが実行されないように、すべて無効にします。

systemctl disable cloud-init.service
systemctl disable cloud-config.service
systemctl disable cloud-final.service
systemctl disable cloud-init-local.service

[root@localhost ~]# systemctl disable cloud-init.service

Removed "/etc/systemd/system/cloud-init.target.wants/cloud-init.service".

[root@localhost ~]# systemctl disable cloud-config.service

Removed "/etc/systemd/system/cloud-init.target.wants/cloud-config.service".

[root@localhost ~]# systemctl disable cloud-final.service

Removed "/etc/systemd/system/cloud-init.target.wants/cloud-final.service".

[root@localhost ~]# systemctl disable cloud-init-local.service

Removed "/etc/systemd/system/cloud-init.target.wants/cloud-init-local.service".

[root@localhost ~]#


VMDKとしてエクスポートし、Oracle Cloudのカスタム・イメージの作成に使用する場合は、エクスポート前に、cloud-initのサービスをすべて有効にします。

systemctl enable cloud-init.service
systemctl enable cloud-config.service
systemctl enable cloud-final.service
systemctl enable cloud-init-local.service

[root@localhost ~]# systemctl enable cloud-init.service

Created symlink /etc/systemd/system/cloud-init.target.wants/cloud-init.service → /usr/lib/systemd/system/cloud-init.service.

[root@localhost ~]# systemctl enable cloud-config.service

Created symlink /etc/systemd/system/cloud-init.target.wants/cloud-config.service → /usr/lib/systemd/system/cloud-config.service.

[root@localhost ~]# systemctl enable cloud-final.service

Created symlink /etc/systemd/system/cloud-init.target.wants/cloud-final.service → /usr/lib/systemd/system/cloud-final.service.

[root@localhost ~]# systemctl enable cloud-init-local.service

Created symlink /etc/systemd/system/cloud-init.target.wants/cloud-init-local.service → /usr/lib/systemd/system/cloud-init-local.service.

[root@localhost ~]# 


以上で、仮想マシンをOracle Cloud Infrastructureへエクスポートする準備ができました。


サンプル・スキーマのインストール



Oracle AI Database 26ai Freeが使えるディスク容量には限りがあるため、仮想マシンのエクスポートにサンプル・スキーマを含める必要はありません。

Oracle CorporationよりOracle AI Database Developer VMとして、Oracle AI Database 26ai FreeにOracle APEXやOracle REST Data Servicesが構成済みのVirtualBox Applianceが提供されています。このVirtualBox ApplianceにはARM版がなく、APEXの日本語リソースもインストールされていません。ただし、VirtualBox Applianceから仮想マシンを作成後、すぐに例題に取り組めるようにサンプル・スキーマHRとAPEXワークスペースHR_DEVが作成されています。

今まで作業してきた仮想マシンを、Oracle Corporationが提供しているOracle AI Database Developer VMの代わりに使用できるように、サンプル・スキーマHRのインストールとAPEXワークスペースHR_DEVを作成します。作業はホスト・コンピュータでSQLclを使って実施します。ワークスペース名や管理者ユーザーの設定は、オリジナルのOracle AI Database Developer VMに合わせます。

仮想マシンのネットワークポート・フォワーディングの設定に、以下のようにnet8を追加します。ホストポートゲストポート共に、1521を設定します。


2026年2月2日現在での、オラクル・データベースのサンプル・スキーマの最新リリースは23.3です。以下のコマンドで、GitHubからVirtualBoxを実行しているホストに、サンプル・スキーマのZIPファイルをダウンロードします。

curl -OL https://github.com/oracle-samples/db-sample-schemas/archive/refs/tags/v23.3.zip

% curl -OL https://github.com/oracle-samples/db-sample-schemas/archive/refs/tags/v23.3.zip

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

100 11.6M    0 11.6M    0     0  3706k      0 --:--:--  0:00:03 --:--:-- 4987k

% 


ダウンロードしたZIPファイルを解凍します。

unzip -q v23.3.zip
ls db-sample-schemas-23.3


% unzip -q v23.3.zip 

% ls db-sample-schemas-23.3 

customer_orders LICENSE.txt product_media README.txt SECURITY.md

human_resources order_entry README.md sales_history

%


human_resourcesのディレクトリに移動します。ユーザーsystemでデータベースに接続しhr_install.sqlを実行して、サンプル・スキーマHRをインストールします。

cd db-sample-schemas-23.3/human_resources
sql system@localhost/freepdb1


ユーザーHRパスワードを設定し、続いて確認される表領域名についてはOracle AI Database 26ai Freeにデフォルトで作成されているUSERSを指定します。

% cd db-sample-schemas-23.3/human_resources 

human_resources % sql system@localhost/freepdb1



SQLcl: 月 2月 02 12:44:29 2026のリリース25.3 Production


Copyright (c) 1982, 2026, Oracle.  All rights reserved.


パスワード (**********?) ******

Last Successful login time: 月 2月  02 2026 12:44:31 +09:00


接続先:

Oracle AI Database 26ai Free Release 23.26.0.0.0 - Develop, Learn, and Run for Free

Version 23.26.0.0.0


SQL> @hr_install


Thank you for installing the Oracle Human Resources Sample Schema.

This installation script will automatically exit your database session

at the end of the installation or if any error is encountered.

The entire installation will be logged into the 'hr_install.log' log file.


Enter a password for the user HR: ******



Enter a tablespace for HR [USERS]: 

Do you want to overwrite the schema, if it already exists? [YES|no]: 

******  Creating REGIONS table ....


Table REGIONSは作成されました。



INDEX REG_ID_PKは作成されました。



Table REGIONSが変更されました。


[中略]


Trigger UPDATE_JOB_HISTORYがコンパイルされました


エラーはありません。


コミットが完了しました。



Installation verification    

____________________________ 

Verification:                


Table             provided    actual 

______________ ___________ _________ 

regions                  5         5 

countries               25        25 

departments             27        27 

locations               23        23 

employees              107       107 

jobs                    19        19 

job_history             10        10 


Thank you!                                                  

___________________________________________________________ 

The installation of the sample schema is now finished.      

Please check the installation verification output above.    

You will now be disconnected from the database.             

Thank you for using Oracle Database!                        

Oracle AI Database 26ai Free Release 23.26.0.0.0 - Develop, Learn, and Run for Free

Version 23.26.0.0.0から切断されました

human_resources %


以上でhuman_resourcesのサンプル・スキーマのインストールは完了です。

作成したスキーマHRをデフォルト・パーシング・スキーマとした、APEXワークスペースHR_DEVを作成します。管理者ユーザーはHR_ADMINです。

以下のスクリプトをダウンロードし、ファイルcreate_dbuser_and_workspace.sqlを作成します。


sql sys@localhost/freepdb1 as sysdba
@create_dbuser_and_workspace.sql
APEX workspace name: hr_dev
Database Username: hr
Administrator name for the APEX workspace: hr_admin
Administrator password: ******
Administrator email: 管理者のメール・アドレス

% sql sys@localhost/freepdb1 as sysdba



SQLcl: 月 2月 02 12:57:50 2026のリリース25.3 Production


Copyright (c) 1982, 2026, Oracle.  All rights reserved.


パスワード (**********?) ******

接続先:

Oracle AI Database 26ai Free Release 23.26.0.0.0 - Develop, Learn, and Run for Free

Version 23.26.0.0.0


SQL> @create_dbuser_and_workspace.sql

APEX workspace name: hr_dev

Database Username: hr

Administrator name for the APEX workspace: hr_admin

Administrator password: ******

Administrator email: noreply@example.com

旧:declare

    l_exist pls_integer;

begin

    select 1 into l_exist from apex_workspaces where workspace = upper('&WKSPNAME');

    if l_exist > 0 then

        raise_application_error(-20001, 'APEX workspace &WKSPNAME exist');

    end if;    

exception

    when no_data_found then

        null; -- no workspace created;

end;


新:declare

    l_exist pls_integer;

begin

    select 1 into l_exist from apex_workspaces where workspace = upper('hr_dev');

    if l_exist > 0 then

        raise_application_error(-20001, 'APEX workspace hr_dev exist');

    end if;    

exception

    when no_data_found then

        null; -- no workspace created;

end;


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


旧:declare

    l_exist pls_integer;

    l_sql   varchar2(32767);

begin

    select 1 into l_exist from all_users where username = upper('&DBUSER');

exception

    when no_data_found then

        -- Assuming Oracle AI Database 26ai Free, specify the USERS and TEMP tablespaces.

        l_sql := 'create user &DBUSER default tablespace users temporary tablespace temp quota unlimited on users';

        execute immediate l_sql;

end;


新:declare

    l_exist pls_integer;

    l_sql   varchar2(32767);

begin

    select 1 into l_exist from all_users where username = upper('hr');

exception

    when no_data_found then

        -- Assuming Oracle AI Database 26ai Free, specify the USERS and TEMP tablespaces.

        l_sql := 'create user hr default tablespace users temporary tablespace temp quota unlimited on users';

        execute immediate l_sql;

end;


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


旧:begin

    for c1 in (

        select privilege from sys.dba_sys_privs

        where grantee = 'APEX_GRANTS_FOR_NEW_USERS_ROLE'

    )

    loop

        execute immediate 'grant ' || c1.privilege || ' to &DBUSER';

    end loop;

end;


新:begin

    for c1 in (

        select privilege from sys.dba_sys_privs

        where grantee = 'APEX_GRANTS_FOR_NEW_USERS_ROLE'

    )

    loop

        execute immediate 'grant ' || c1.privilege || ' to hr';

    end loop;

end;


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


旧:begin

    apex_instance_admin.add_workspace(

        -- To treat workspaces across different instances as identical,

        -- assign the same workspace ID to each workspaces on the instance.

        -- p_workspace_id => <workspace_id>,

        p_workspace =>      upper('&WKSPNAME'),

        p_primary_schema => upper('&DBUSER')

    );

end;


新:begin

    apex_instance_admin.add_workspace(

        -- To treat workspaces across different instances as identical,

        -- assign the same workspace ID to each workspaces on the instance.

        -- p_workspace_id => <workspace_id>,

        p_workspace =>      upper('hr_dev'),

        p_primary_schema => upper('hr')

    );

end;


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


旧:begin

    apex_util.set_workspace('&WKSPNAME');

    apex_util.create_user(

        p_user_name                    => '&ADMINNAME',

        p_web_password                 => '&ADMINPASS',

        p_developer_privs              => 'ADMIN:CREATE:DATA_LOADER:EDIT:HELP:MONITOR:SQL',

        p_email_address                => '&ADMINMAIL',

        p_default_schema               => '&DBUSER',

        p_change_password_on_first_use => 'N'

    );

end;


新:begin

    apex_util.set_workspace('hr_dev');

    apex_util.create_user(

        p_user_name                    => 'hr_admin',

        p_web_password                 => 'oracle',

        p_developer_privs              => 'ADMIN:CREATE:DATA_LOADER:EDIT:HELP:MONITOR:SQL',

        p_email_address                => 'noreply@example.com',

        p_default_schema               => 'hr',

        p_change_password_on_first_use => 'N'

    );

end;


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


Oracle AI Database 26ai Free Release 23.26.0.0.0 - Develop, Learn, and Run for Free

Version 23.26.0.0.0から切断されました

ynakakoshi@Ns-Macbook apex-arm % 


以上で、Oracle AI Database Developer VMとほぼ同じAPEXワークスペースHR_DEVとデータベース・ユーザーHRが作成できました。

続く