2023年12月22日金曜日

Autonomous Database Free Container ImageをmacOS上で実行する

オラクル社よりOracle Autonomous Database Free Container Imageという、Always FreeのAutonomous Databaseと同等のインスタンスをDockerやPodmanで動かせるイメージが提供されています。

Oracle Container Registryにイメージや導入手順の説明があります。

Other Open Source Licensesの箇所に、このContainer ImageがOracle Free Use Terms and Conditionsの元で配布されていると記載されています。


Oracle APEXのアプリケーション開発に使えるかと考えたのですが、Oracle APEXに関していうと、英語以外の言語リソースがインストールされていないため、使用は難しいというのが結論です。構成がAutonomous DatabaseであるためAPEXのスキーマが保護されていて、言語リソースの追加インストールもできません。

Oracle APEXの追加言語は開発ツールを多言語に対応させるためのものです。日本語などを含む作成済みのアプリケーションは言語リソースがインストールされていなくても、そのまま各国語の言語で動作します。アプリケーションを実行する環境としてであれば、日本語のアプリケーションを実行することはできます。

とはいえ、macOS上でAutonomous Database Free Container Imageを動作させたので、その手順を記録しておきます。

PodmanをインストールしたMacのスペックは以下です。すでにIntelのMacを持っている方は少ない気はします。


Podmanをインストールします。

brew install podman

すでにインストールされていたので、そのようなメッセージが表示されています。

% brew install podman 

Warning: podman 4.8.2 is already installed and up-to-date.

To reinstall 4.8.2, run:

  brew reinstall podman

% 


Podmanの仮想マシンを作成します。

podman machine init

% podman machine init

Extracting compressed file: podman-machine-default_fedora-coreos-39.20231204.2…

Image resized.

Machine init complete

To start your machine run:


podman machine start


% 


前出のOracle Container Registryのページの以下のFAQにしたがって、最低限のCPUとメモリを設定します。

How can I start podman VM on x86_64 Mac with minimum memory/cpu requirements ?

podman machine set --cpus 4 --memory 8192

% podman machine set --cpus 4 --memory 8192

% 

 
仮想マシンを起動します。

podman machine start

% podman machine start

Starting machine "podman-machine-default"

Waiting for VM ...

Mounting volume... /Users:/Users

Mounting volume... /private:/private

Mounting volume... /var/folders:/var/folders


This machine is currently configured in rootless mode. If your containers

require root permissions (e.g. ports < 1024), or if you run into compatibility

issues with non-podman clients, you can switch using the following command:


        podman machine set --rootful


API forwarding listening on: /Users/*************/.local/share/containers/podman/machine/qemu/podman.sock


The system helper service is not installed; the default Docker API socket

address can't be used by podman. If you would like to install it, run the following commands:


        sudo /usr/local/Cellar/podman/4.8.2/bin/podman-mac-helper install

        podman machine stop; podman machine start


                You can still connect Docker API clients by setting DOCKER_HOST using the

following command in your terminal session:


        export DOCKER_HOST='unix:///Users/**********/.local/share/containers/podman/machine/qemu/podman.sock'


Machine "podman-machine-default" started successfully

% 


仮想マシンの起動を確認します。

podman machine ls

% podman machine ls

NAME                     VM TYPE     CREATED        LAST UP            CPUS        MEMORY      DISK SIZE

podman-machine-default*  qemu        6 minutes ago  Currently running  4           8GiB        100GiB

% 


Autonomous Database Free Containerを実行します。作成されるコンテナの名前はadb-freeになります。
podman run -d \
-p 1521:1522 \
-p 1522:1522 \
-p 8443:8443 \
-p 27017:27017 \
-e MY_ADB_WALLET_PASSWORD=[Walletのパスワード] \
-e MY_ADW_ADMIN_PASSWORD=[MY_ADWのADMINのパスワード] \
-e MY_ATP_ADMIN_PASSWORD=「MY_ATPのADMINのパスワード] \
--cap-add SYS_ADMIN \
--device /dev/fuse \
--name adb-free \
container-registry.oracle.com/database/adb-free:latest

% podman run -d \

> -p 1521:1522 \

> -p 1522:1522 \

> -p 8443:8443 \

> -p 27017:27017 \

> -e MY_ADB_WALLET_PASSWORD=********** \

> -e MY_ADW_ADMIN_PASSWORD=********** \

> -e MY_ATP_ADMIN_PASSWORD=********** \

> --cap-add SYS_ADMIN \

> --device /dev/fuse \

> --name adb-free \

> container-registry.oracle.com/database/adb-free:latest

Trying to pull container-registry.oracle.com/database/adb-free:latest...

Getting image source signatures

Copying blob sha256:c8561740d94bafef696bb9c6b78237b401496ffcf613f46a6f1726ff51654209

Copying blob sha256:e57ed71b58c6856f5f81cfc95958db8098bef51f05c972b865c22a6932c4c197

Copying blob sha256:7de4f82b8b29335fce701cefd64d017f80663afd90b9b4db3c5efb842a4b62c5

Copying config sha256:19e829581a93a2070fe4ab0917ae0778419f69505a10ba5bd1dbd33811f26722

Writing manifest to image destination

740dfefffaaab35d35c1a62626f7c08b6dcf41cc5691aacef4f2863f28d995bf

% 


コンテナの実行を確認します。

podman container ps

% podman container ps

CONTAINER ID  IMAGE                                                   COMMAND     CREATED        STATUS                  PORTS                                                                               NAMES

740dfefffaaa  container-registry.oracle.com/database/adb-free:latest              8 minutes ago  Up 8 minutes (healthy)  0.0.0.0:1521-1522->1522-1522/tcp, 0.0.0.0:8443->8443/tcp, 0.0.0.0:27017->27017/tcp  adb-free

% 


手元のブラウザよりATPのAPEXにアクセスします。


自己署名証明書なので、接続にあたって確認を求められます。


警告を無視して接続します。ORDSのランディング・ページが表示されます。

Oracle APEXを実行します。


APEXの管理サービスへの接続画面が開きます。言語のセレクタがありません

podman run実行時にMY_ATP_ADMIN_PASSWORDとして指定したパスワードを入力し、管理サービスにサインインします。


作成済みにワークスペースが存在しないため、Create Workspaceのボタンが表示されます。

Create Workspaceをクリックします。


ワークスペースとして使用できるスキーマも存在しないため、New Schemaを選択します。


Workspace NameWorkspace UsernameWorkspace Passwordを設定し、Create Workspaceを実行します。


ワークスペースが作成されます。成功メッセージに含まれるワークスペース名のリンクをクリックして、ワークスペースのサインイン画面を開きます。


ワークスペース管理者のパスワードを入力し、ワークスペースにサインインします。言語リソースがロードされていないため、英語以外の言語の選択がありません。


APEXの開発画面が開きます。ここまで、非常にすばやく開発環境の作成ができています。さらに言うと無料です。

言語リソースが含まれていないことが残念です。


コンテナadb-freeに接続してみます。

podman exec -it adb-free /bin/bash

 % podman exec -it adb-free /bin/bash

[oracle@740dfefffaaa /]$ 


PDBのMY_ATPに接続します。以下の環境変数を設定します。
export ORACLE_HOME=/u01/app/oracle/product/19.0.0.0/dbhome_1
export ORACLE_SID=POD1
export NLS_LANG=American_America.AL32UTF8
export PATH=$ORACLE_HOME/bin:$PATH
export TNS_ADMIN=/u01/app/oracle/wallets/tls_wallet

[oracle@740dfefffaaa /]$ export ORACLE_HOME=/u01/app/oracle/product/19.0.0.0/dbhome_1

[oracle@740dfefffaaa /]$ export ORACLE_SID=POD1

[oracle@740dfefffaaa /]$ export NLS_LANG=American_America.AL32UTF8

[oracle@740dfefffaaa /]$ export PATH=$ORACLE_HOME/bin:$PATH

[oracle@740dfefffaaa /]$ export TNS_ADMIN=/u01/app/oracle/wallets/tls_wallet

[oracle@740dfefffaaa /]$


ユーザーADMINで接続します。

sqlplus admin@my_atp_low

[oracle@740dfefffaaa /]$ sqlplus admin@my_atp_low


SQL*Plus: Release 19.0.0.0.0 - Production on Fri Dec 22 06:22:45 2023

Version 19.21.0.1.0


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


Enter password: *********

Last Successful login time: Fri Dec 22 2023 06:21:28 +00:00


Connected to:

Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.21.0.1.0


SQL> exit;

Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.21.0.1.0

[oracle@740dfefffaaa /]$ 


exitで切断します。

[oracle@740dfefffaaa /]$ exit

exit

% 


コンテナadb-freeを停止します。

podman container stop adb-free

% podman container stop adb-free

adb-free

% 


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

podman machine stop

% podman machine stop

Waiting for VM to exit...

Machine "podman-machine-default" stopped successfully

% 


Oracle Autonomous Database Free Container ImageをmacOS上で動かした作業履歴は以上になります。

かえすがえすも言語リソースが入っていないことが残念です。