先日のOracle CloudWorld 2023で発表された Oracle Autonomous Database Free Container Image が早速公開されてましたので、自分のラップトップPCにAutonomous Databaseを構築してみました。
Autonomous Database Free Container Imageを使うことで、本来ならOracle Cloud Infrastructure(OCI)上でしか使えないExadata上でのみ稼働するAutonomous Database(ADB)が手元のPCで動いちゃいます。
主な特徴は以下のマニュアルをご参照ください。
Oracle Autonomous Database Free Container Image Features
ざっくりと以下のような感じです。
- Autonomous Database Free Container ImageにはAutonomous Transaction Processing(ATP)とAutonomous Data Warehouse(ADW)の2つのDBが含まれる
- それぞれ4 ECPUと20GBのストレージが割り当てられ、最大30セッションの同時接続が可能
- 各ADBがサポートするコンシューマ・グループは以下の通り、通常のADBと同じ
- ATP:HIGH, MEDIUM, LOW, TP, TPURGENT
- ADW:HIGH, MEDIUM, LOW
- 以下の組込み済みツールが利用可能
- Database Actions
- Oracle REST Data Services (ORDS)
- Oracle APEX
- Oracle Database API for MongoDB
一方で以下にある通り、いくつかの機能制限もあります。
Restrictions for Autonomous Database Free Container Image
- 自動パッチ適用は使えない
- 本来ある以下の組込み済みツールは使えない
- Graph
- Oracle Machine Learning
- Data Transforms
- OCIと連携して使うような機能は使えない(ex:DBバックアップやData Safe連携など)
またAutonomous Database Free Container Imageの起動にあたり、そこそこのリソース消費が伴います。
Recommendations for Resource Allocation for the Autonomous Database Free Container Image
上記マニュアルから推奨スペックは次の通りです。
- 4 CPUs
- 8 GB memory
私は下記スペックのノートPCで試しましたが、CPUは余裕あったもののメモリが常時かつかつでした。。
またストレージも15GBくらい持ってかれます。。
- CPU: Intel Core i7-8665U
- メモリ: 16 GB
実際に構築してみる
以降はノートPCで実際に構築した手順とログを記載します。
なおOSはWindows 11です。
Linux向け手順ですが、マニュアルは以下が参考になります。
Container Registry Locations for Oracle Autonomous Database Free Container Image
Podmanのインストール
まずはノートPCにPodmanをインストールします。
以下サイトからインストーラーを取得してインストールしてください。
https://podman.io/
ちなみにPodman導入前に Windows Subsystem for Linux のインストールが必要です。
Podman Machine作成
Windows上でPodmanを使うにはPodman Machineを作成する必要があります。
以下のコマンドで作成します。
> podman machine init
Extracting compressed file
Importing operating system into WSL (this may take a few minutes on a new WSL install)...
インポート中です。この処理には数分かかることがあります。
この操作を正しく終了しました。
Configuring system...
Generating public/private ed25519 key pair.
Your identification has been saved in podman-machine-default
Your public key has been saved in podman-machine-default.pub
...略...
Machine init complete
To start your machine run:
podman machine start
初期化が終わったらPodman Machineを起動します。
> podman machine start
Starting machine "podman-machine-default"
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: npipe:////./pipe/docker_engine
Docker API clients default to this address. You do not need to set DOCKER_HOST.
Machine "podman-machine-default" started successfully
起動後の状態を確認します。
STATEがRunningになっています。
> wsl -l -v
NAME STATE VERSION
* podman-machine-default Running 2
Autonomous Database Free Container Imageの起動
まずはAutonomous Database Free Container Imageをダウンロードします。
NW帯域にも依りますが、それなりに時間が掛かります。
また本作業で約5GBのメモリー消費、約15GBのストレージ消費を確認しましたので、PCの負荷にはご注意ください。
> podman pull 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:d90c723bb5b704de7841a376debe3968f0f941aa1d3a547cf54fb9658a5c87e3
Copying blob sha256:5419febaece0ef181135ea07c48584f17d9de89e676042035c776a226e3c0b4b
Copying blob sha256:4ed24fbe9d8b4e7df9e531b3c622556d5efe4e60920e6aa2a67f5e2d8a9d1db5
Copying config sha256:8a4b5137f17908c197834417a994b5af73e28ff75233787c8ec12dea41b5dfc6
Writing manifest to image destination
8a4b5137f17908c197834417a994b5af73e28ff75233787c8ec12dea41b5dfc6
余りにもメモリ消費が激しかったので、コンテナ・イメージ取得完了後にPodman Machineを再起動しました。
> podman machine stop
Machine "podman-machine-default" stopped successfully
>podman machine start
Starting machine "podman-machine-default"
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: npipe:////./pipe/docker_engine
Docker API clients default to this address. You do not need to set DOCKER_HOST.
Machine "podman-machine-default" started successfully
再起動するとかなり解放され、ADBのコンテナ・イメージを起動する余裕が出来ました。
次にダウンロードしたADBのコンテナ・イメージを起動します。
コマンドの解説は下記マニュアルをご参照ください。
Start Autonomous Database Free Container Image
> podman run -d ^
-p 1521:1522 ^
-p 1522:1522 ^
-p 8443:8443 ^
-p 27017:27017 ^
--hostname localhost ^
--cap-add SYS_ADMIN ^
--device /dev/fuse ^
--name adb_container ^
container-registry.oracle.com/database/adb-free:latest
757724b113a3a1990dcf3e6764794b526605dc31200de7c706870e6c79d3558d
起動状態を確認します。
> podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
757724b113a3 container-registry.oracle.com/database/adb-free:latest 6 seconds ago Up 7 seconds (starting) 0.0.0.0:1521->1522/tcp, 0.0.0.0:1522->1522/tcp, 0.0.0.0:8443->8443/tcp, 0.0.0.0:27017->27017/tcp adb_container
接続に使用するWalletを取得
以下のコマンドで接続に必要なWalletを起動したADBのコンテナから取得します。
7577...と書いてあるコンテナIDの箇所は、直前のpodman ps
で確認したご自分のコンテナIDを入力します。
> podman cp 757724b113a3:/u01/app/oracle/wallets/tls_wallet tls_wallet
これでカレントディレクトリに tls_wallet というディレクトリを作成し、そこにWallet関連ファイルが格納されました。
sqlplusでADBに接続する場合、このWalletファイルが読み込まれるよう TNS_ADMIN を環境変数として登録します。
またsqlnet.ora内の変数 TNS_ADMIN がLinux向けの記述になっているため、Windows向けの%TNS_ADMIN%
に修正しておきます。
ATPに接続
ここまで出来たらsqlplusからATPやADWに接続できます。
今回はATPに接続してみます。
ADMINユーザのパスワードは Welcome_MY_ATP_1234 となっていますが、初回ログイン時にパスワード変更を求められます。
> sqlplus admin/Welcome_MY_ATP_1234@my_atp_low
SQL*Plus: Release 19.0.0.0.0 - Production on Mon Sep 25 10:52:10 2023
Version 19.8.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
ERROR:
ORA-28001: the password has expired
Changing password for admin
New password:
Retype new password:
Password changed
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.20.0.1.0
RU 19.20のADBがデプロイされているのを確認できます。
ADB特有のDB機能が使えるのかは後日確認したいと思います。
またAutonomous Database Free Container ImageにはDatabase ActionsやOracle APEXも組み込まれているということで、実際にアクセスしてみます。
URLは以下マニュアルが参考になります。
Start Autonomous Database Free Container Image
ATPのDatabase ActionsおよびOracle APEXは以下URLからアクセスできます。
- Database Actions: https://localhost:8443/ords/my_atp/sql-developer
- Oracle APEX: https://localhost:8443/ords/my_atp/
まずはDatabase ActionsにアクセスするとORDSのログイン画面が出てきます。
ADMINユーザのアカウント情報を入力してログインします。
するとOCIのADBと同じDatabase Actionsのトップ画面へ遷移します。
試しに左上のSQL Developer Webへアクセスすると、ちゃんと表示されました。
Oracle APEXの方も見てみます。
URLにアクセスすると以下のトップ画面が表示されますので、真ん中のOracle APEXを実行します。
ADMINユーザのパスワードでログインします。
Oracle APEXのワークスペース作成画面へ遷移しました。
以上、本来ならOCIにアカウント登録しないと使えないExadata上で稼働するADBが、手元のラップトップPCで使えるようになりました。
これによってADBの良さを以前より手軽に体験頂けるのでは、と思っています。
今回はAutonomous Database Free Container Imageの起動と接続だけ試しましたが、今後はこのコンテナ環境上でAutonomous Database特有のDB機能を実際に使ってみたいと思います。