4
1

More than 1 year has passed since last update.

読取り専用のOracleホームを理解する(Oracle Database 19c)

Last updated at Posted at 2021-08-17

「Oracleホーム」とは

一般的に「Oracleホーム」は Oracle Database ソフトウェアや Oracle Grid Infrastructure ソフトウェアがインストールされるディレクトリを指します。通常環境変数の ORACLE_HOME に指定されています。以下は従来の Oracle ホームに指定されたディレクトリの例です。

$ printenv ORACLE_HOME
/u01/app/oracle/product/19.0.0/dbhome_1

$ ls $ORACLE_HOME
addnode      dbs            jdbc     OPatch.org   R              sqldeveloper
apex         deinstall      jdk      opmn         racg           sqlj
assistants   demo           jlib     oracore      rdbms          sqlpatch
bin          diagnostics    ldap     oraInst.loc  relnotes       sqlplus
cfgtoollogs  drdaas         lib      ord          root.sh        srvm
client       dv             log      ords         root.sh.old    suptools
clone        env.ora        md       oss          root.sh.old.1  ucp
crs          has            mgw      oui          root.sh.old.2  usm
css          hs             network  owm          root.sh.old.3  utl
ctx          install        nls      perl         runInstaller   wwg
cv           instantclient  odbc     plsql        schagent.conf  xdk
data         inventory      olap     precomp      sdk
dbjava       javavm         OPatch   QOpatch      slax

読取り専用のOracleホーム

Oracle Database 18c より前のバージョンでは、Oracle ホーム・ディレクトリにはインストールされるソフトウェアと、設定ファイルやログファイルが混在しており、ソフトウェアのパッチ適用や移行の妨げになっていました。Oracle Database 18c から、「読取り専用のOracleホーム」とよばれる機能が利用できるようになりました。英語版のマニュアルでは「Read-Only Oracle Homes」とされています。
 「読取り専用のOracleホーム」は言葉の通り、Oracle ホームにインストールされるソフトウェア部分を読み取り専用とし、各種設定ファイル群を分離する機能です。この機能を有効化すると、設定ファイルは以下のいずれかのディレクトリに配置されることになります。

名前 ディレクトリ 設定ファイル
ORACLE_BASE_HOME ${ORACLE_BASE}/homes/{Oracleホーム名} リスナー設定、ログ /u01/app/oracle/homes/OraDB19Home1
ORACLE_BASE_CONFIG ${ORACLE_BASE} 初期化パラメーター、パスワード・ファイル /u01/app/oracle/

Oracle Database 21c 以降は「読取り専用のOracleホーム」がデフォルト設定となります。

設定方法

 「読取り専用のOracleホーム」の機能を有効にするには、データベースやリスナーが従来の Oracle ホームを使用する「前に」実行する必要があります。設定コマンドは oracle 管理ユーザーの権限で「roohctl -enable」を実行します(RAC 環境ではノードを指定するパラメーターあり)。以下の例ではデータベース O19A と O19M が既に利用され、リスナー LISTENER, LISTENER2 が作成されている環境で実行しているためコマンドが失敗しています。

$ roohctl -enable
Enabling Read-Only Oracle home.
Cannot enable Read-Only Oracle home in a configured Oracle home.
The Oracle Home is configured with databases 'O19A,O19M'.
The Oracle Home is configured with listeners 'LISTENER2,LISTENER'.

マニュアルには記述が無いため確かではありませんが、roohctl コマンドは /etc/oratab ファイルからデータベースを、$ORACLE_HOME/network/admin/listener.ora ファイルからリスナーを見つけているようです。oratab ファイルの内容をコメント化し、listener.ora ファイルの名前を変更すると roohctl コマンドは成功します。

$ roohctl -enable
Enabling Read-Only Oracle home.
Update orabasetab file to enable Read-Only Oracle home.
Orabasetab file has been updated successfully.
Create bootstrap directories for Read-Only Oracle home.
Bootstrap directories have been created successfully.
Bootstrap files have been processed successfully.
Read-Only Oracle home has been enabled successfully.
Check the log file /u01/app/oracle/cfgtoollogs/roohctl/roohctl-210817PM053034.log for more details.

設定後の状況

設定後は以下のディレクトリが使用されることになります。設定ファイルのファイル名は変更されません。

ファイル ディレクトリ
初期化パラメーターファイル(PFILE, SPFILE) ORA_BASE_CONFIG/dbs
パスワード・ファイル ORA_BASE_CONFIG/dbs
リスナー設定ファイル ORA_BASE_HOME/network/admin/listener.ora
ローカル・ネーミング・パラメータ・ファイル ORA_BASE_HOME/network/admin/tnsnames.ora

環境変数 ORACLE_HOME から上記ディレクトリを検索するパスは「$ORACLE_HOME/install/orabasetab」ファイルが参照されます。このファイルはソフトウェアのインストール直後に作成され、roohctl コマンド実行時に変化します。

roohctl コマンド実行前

$ cd $ORACLE_HOME/install
$ cat orabasetab
#orabasetab file is used to track Oracle Home associated with Oracle Base
/u01/app/oracle/product/19.0.0/dbhome_1:/u01/app/oracle:OraDB19Home1:N:

roohctl コマンド実行後(行末のNがYに変化しています)

$ cat orabasetab
#orabasetab file is used to track Oracle Home associated with Oracle Base
/u01/app/oracle/product/19.0.0/dbhome_1:/u01/app/oracle:OraDB19Home1:Y:

現状の確認

現状を確認するためのコマンドが提供されています。orabasehome, orabaseconfig, orabase です。orabasehome コマンドを実行して、環境変数 ORACLE_HOME と同じディレクトリが出力されれば従来の Oracle ホームを利用しています。

$ orabase
/u01/app/oracle

$ orabaseconfig
/u01/app/oracle

$ orabasehome
/u01/app/oracle/homes/OraDB19Home1

元に戻す

roohctl -helpコマンドの出力にもありませんが、元に戻す場合はroohctl -disableコマンドを実行します。サポートされているかは不明です。Oracle Database 19c on Windowsのマニュアルには-disableオプションは使用しないようにと記載されています。

$ roohctl -help
Usage:  roohctl [<flag>] [<command> <option>]
Following are the possible flags:
        -help

Following are the possible commands:
        -enable Enable Read-only Oracle Home
                [-nodeList List of nodes in a cluster environment]
$
$ roohctl -disable
Disabling Read-Only Oracle home.
Update orabasetab file to disable Read-Only Oracle home.
Orabasetab file has been updated successfully.
Read-Only Oracle home has been disabled successfully.
Check the log file /u01/app/oracle/cfgtoollogs/roohctl/roohctl-210908PM045902.log for more details.
4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1