5 ExadataへのOML4Pyのインストール

次のトピックでは、ExadataでのOML4Pyについてと、DCLIを構成してExadata全体でpythonおよびOML4Pyをインストールする方法について説明します。

5.1 ExadataでのOracle Machine Learning for Pythonについて

ExadataはOML4Pyに最も適したプラットフォームです。OML4PyのPython計算の並列リソースは、Exadataの大規模なパラレル・グリッド・インフラストラクチャを活用します。

ノート:

OML4Pyのバージョンは、サーバーと各クライアント・コンピュータで同じである必要があります。また、Pythonのバージョンは、サーバーと各クライアント・コンピュータで同じである必要があります。サポートされている構成は、「オンプレミスのOML4Pyのシステム要件」の表3-2を参照してください。

OML4PyをExadataにインストールするには:

  1. すべてのコンピュート・ノードで、次のようにします。

    • Pythonのインストール

    • 環境の確認および構成

    • OML4Pyサポート・パッケージのインストール

    • OML4Pyサーバー・コンポーネントのインストール

  2. 最初のノードでのみ、次のようにします。

    • データベース構成を含め、OML4Pyサーバー・コンポーネントをインストールします。

    • 必要に応じて、OML4Pyユーザーを作成します。または、OML4Pyを使用するように既存のデータベース・ユーザーを構成します。「オンプレミスOracle Database用の新しいユーザーの作成」を参照してください。

分散コマンドライン・インタフェース(DCLI)を使用すると、ExadataへのPythonのインストールを簡略化できます。

5.2 Exadataコンピュート・ノード全体にPythonをインストールするためのDCLIの構成

分散コマンドライン・インタフェース(DCLI)を使用すると、ExadataへのOML4Pyのインストールを簡略化できます。

DCLIを使用することで、1つのコマンドを使用して、複数のExadataコンピュート・ノードにPythonをインストールできます。次の例に、このユーティリティの基本構文を説明する、DCLIのヘルプ・オプションの出力を示します。

例5-1 DCLIのヘルプ・オプションの出力

$ dcli -h

Distributed Shell for Oracle Storage

This script executes commands on multiple cells in parallel threads.
The cells are referenced by their domain name or ip address.
Local files can be copied to cells and executed on cells.
This tool does not support interactive sessions with host applications.
Use of this tool assumes ssh is running on local host and cells.
The -k option should be used initially to perform key exchange with
cells.  User may be prompted to acknowledge cell authenticity, and
may be prompted for the remote user password.  This -k step is serialized
to prevent overlayed prompts.  After -k option is used once, then
subsequent commands to the same cells do not require -k and will not require
passwords for that user from the host.
Command output (stdout and stderr) is collected and displayed after the
copy and command execution has finished on all cells.
Options allow this command output to be abbreviated.

Return values:
 0 -- file or command was copied and executed successfully on all cells
 1 -- one or more cells could not be reached or remote execution
      returned non-zero status.
 2 -- An error prevented any command execution

Examples:
 dcli -g mycells -k
 dcli -c stsd2s2,stsd2s3 vmstat
 dcli -g mycells cellcli -e alter iormplan active
 dcli -g mycells -x reConfig.scl

Usage: dcli [options] [command]

Options:
  --version             show program's version number and exit
  --batchsize=MAXTHDS   limit the number of target cells on which to run the
                        command or file copy in parallel
  -c CELLS              comma-separated list of cells
  --ctimeout=CTIMEOUT   Maximum time in seconds for initial cell connect
  -d DESTFILE           destination directory or file
  -f FILE               files to be copied
  -g GROUPFILE          file containing list of cells
  -h, --help            show help message and exit
  --hidestderr          hide stderr for remotely executed commands in ssh
  -k                    push ssh key to cell's authorized_keys file
  --key-with-one-password
                        apply one credential for pushing ssh key to
                        authorized_keys files
  -l USERID             user to login as on remote cells (default: celladmin)
  --root-exadatatmp     root user login using directory /var/log/exadatatmp/
  --maxlines=MAXLINES   limit output lines from a cell when in parallel
                        execution over multiple cells (default: 100000)
  -n                    abbreviate non-error output
  -r REGEXP             abbreviate output lines matching a regular expression
  -s SSHOPTIONS         string of options passed through to ssh
  --scp=SCPOPTIONS      string of options passed through to scp if different
                        from sshoptions
  --serial              serialize execution over the cells
  --showbanner          show banner of the remote node in ssh
  -t                    list target cells
  --unkey               drop keys from target cells' authorized_keys file
  -v                    print extra messages to stdout
  --vmstat=VMSTATOPS    vmstat command options
  -x EXECFILE           file to be copied and executed

各計算ノードでDCLIに対する自動認証を有効化するようにExadata環境を構成します。

  1. rootユーザーのSSH公開キー-秘密キーを生成します。任意のノードで次のコマンドをrootで実行します。

    $ ssh-keygen -N '' -f /.ssh/id_dsa -t dsa

    このコマンドによって、rootユーザーのホーム・ディレクトリの.sshサブディレクトリに公開キーおよび秘密キーのファイルが生成されます。

  2. テキスト・エディタで、ラック内のすべての計算ノードの名前を含むファイルを作成します。1行に1つのノード名を指定します。たとえば、2ノード・クラスタのnodesファイルには、次のようなエントリが含まれます。

    $ cat nodes
    exadb01
    exadb02
  3. 全ノードでSSH信頼を確立するために、-kオプションを使用してDCLIコマンドを実行します。-kオプションによって、DCLIが各ノードに順に(並行にではなく)接触し、各ノードのパスワードの入力が求められます。

    $ dcli -t -g nodes -l root -k -s "\-o StrictHostkeyChecking=no"

    -kを使用したDCLIは、SSH信頼およびユーザー等価関係を確立します。この後のDCLIコマンドではパスワードの入力は求められません。

5.2.1 DCLIを使用したExadataコンピュート・ノード全体へのPythonのインストール

DCLIを使用してExadataコンピュート・ノード全体にPythonをインストールする手順です。

次のステップでは、Exadata用のPythonのビルドおよびインストールについて説明します。

  1. Python Webサイトにアクセスし、Python 3.12.0XZ compressed source tarballをダウンロードし、それを解凍します。ダウンロードされるファイル名はPython-3.12.0.tgzです

    $ wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz
    $ tar xvf Python-3.12.0.tgz
  2. OML4Pyには、perl-Env libffi-developensslopenssl-develtk-develxz-develzlib-develbzip2-develreadline-develおよびlibuuid-develの各ライブラリが存在する必要があります。次のコマンドを使用して、これらのライブラリをインストールします。

    # dcli -t -g nodes -l root "yum -y install perl-Env libffi-devel openssl openssl-devel tk-devel xz-devel zlib-devel bzip2-devel readline-devel libuuid-devel"
    
  3. 各ノードで、PYTHONHOME環境を設定します。

    # dcli -t -g nodes -l oracle "export PYTHONHOME=$ORACLE_HOME/python; export PATH=$ORACLE_HOME/python/bin$PATH; export LD_LIBRARY_PATH=$ORACLE_HOME/python/lib:$LD_LIBRARY_PATH; export PIP_REQUIRE_VIRTUALENV=false"
    
    # dcli -t -g nodes -l oracle "tar xvfz $ORACLE_HOME/Python-3.12.0.tgz -C $ORACLE_HOME/python"
    
    # dcli -t -g nodes -l oracle "cd $ORACLE_HOME/python; ./configure --enable-shared --prefix=$ORACLE_HOME/python"
    
    # dcli -t -g nodes -l oracle "cd $ORACLE_HOME/python; make clean; make"
    
    # dcli -t -g nodes -l oracle "cd $ORACLE_HOME/python; make altinstall"
  4. $PYTHONHOME/binディレクトリにシンボリック・リンクを作成します。これをPython-3.12実行可能ファイルにリンクする必要があります。これは、次のコマンドを使用して実行できます:

    # dcli -t -g nodes -l oracle "cd $PYTHONHOME/bin"
    # dcli -t -g nodes -l oracle "ln -s python3.12 python3"
  5. 環境変数PYTHONHOMEを設定してPATHに追加し、環境変数LD_LIBRARY_PATHを設定します。

    # dcli -t -g nodes -l oracle "export PYTHONHOME=$ORACLE_HOME/python"
    # dcli -t -g nodes -l oracle "export PATH=$PYTHONHOME/bin:$PATH"
    # dcli -t -g nodes -l oracle "export LD_LIBRARY_PATH=$PYTHONHOME/lib:$LD_LIBRARY_PATH"
    # dcli -t -g nodes -l oracle "export PIP_REQUIRE_VIRTUALENV=false"
  6. これで、コマンドpython3を実行してPythonを起動できます。次に例を示します。

    # dcli -t -g nodes -l oracle "python3"
    exadb01: Python 3.12.0 (default, Feb 10 2022, 14:38:12)         
        [GCC 4.8.5 20150623 (Red Hat 4.8.5-44.0.3)] on linux             
        Type "help", "copyright", "credits" or "license" for more information.
    
    exadb02: Python 3.12.0 (default, Feb 10 2022, 14:38:12)         
        [GCC 4.8.5 20150623 (Red Hat 4.8.5-44.0.3)] on linux  
        Type "help", "copyright", "credits" or "license" for more information.

5.2.2 DCLIを使用したExadataコンピュート・ノード全体へのOML4Pyのインストール

DCLIを使用してExadataコンピュート・ノード全体にOML4Pyをインストールする手順です。

DCLIを使用してExadataにOML4Pyをインストールするには、次のステップを実行します。

  1. まず、OML4Pyサポート・パッケージを各ノードの$ORACLE_HOME/oml4py/modulesにインストールします。OML4Pyサポート・パッケージは、各コンピュート・ノードに個別にインストールする必要があります。DCLIは、システム・デフォルトのPythonを使用し、OML4Pyで使用するためにインストールされたPythonと競合するため、使用できません。

    $ pip3.12 install pandas==2.1.1 --target=$ORACLE_HOME/oml4py/modules
    $ pip3.12 install scipy==1.11.3 --target=$ORACLE_HOME/oml4py/modules
    $ pip3.12 install matplotlib==3.7.2 --target=$ORACLE_HOME/oml4py/modules
    $ pip3.12 install python-oracledb==1.4.0 --target=$ORACLE_HOME/oml4py/modules
    $ pip3.12 install scikit-learn==1.2.1 --no-deps --target=$ORACLE_HOME/oml4py/modules
    $ pip3.12 install numpy==1.26.0 --target=$ORACLE_HOME/oml4py/modules
  2. PYTHONPATH環境変数をOML4Pyモジュールの場所に設定します。

    $ export PYTHONPATH=$ORACLE_HOME/oml4py/modules
  3. システムのインストール・ファイルをダウンロードします。

    1. Oracle Technology Networkの「Oracle Machine Learning for Python Downloads」ページにアクセスします。

    2. ライセンス契約に同意し、Oracle Machine Learning for Python Downloads (v2.0)を選択します。

    3. Oracle Machine Learning for Python Server Install for Oracle Database on Linux 64 bitを選択します。

    4. ファイルを$ORACLE_HOME/oml4pyディレクトリに保存します。

    インストール・ファイルを$ORACLE_HOME/oml4pyディレクトリに抽出するには、次のコマンドを使用します。

    $ unzip oml4py-server-linux-x86_64-2.0.zip -d $ORACLE_HOME/oml4py

    ファイルは、$ORACLE_HOME/oml4py/serverサブディレクトリに抽出されます。

  4. 1つ目のノードで、$ORACLE_HOME/oml4pyディレクトリからサーバー・インストール・スクリプトを実行します。次のコマンドは、スクリプトを対話モードで実行します。

    $ perl -Iserver server/server.pl

    サーバー・スクリプトを非対話モードで実行するには、プラガブル・データベース、永続表領域および一時表領域のパラメータをスクリプトに渡します。

    $ perl -Iserver server/server.pl -y --pdb PDB11 --perm SYSTEM --temp TEMP 

    残りのすべてのコンピュート・ノードで--no-dbフラグを指定してサーバー・スクリプトを実行します。これにより、OML4Pyサーバー構成が設定され、1つ目のノードですでに実行されているデータベース構成のステップがスキップされます。

    $ perl -Iserver server/server.pl --no-db