5 ExadataへのOracle Machine Learning for Rのインストール

この章では、Oracle Exadataデータベース・マシンへのOracle R DistributionおよびOML4Rサーバーのインストール方法を説明します。この章の内容は、次のとおりです。

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

ExadataはOML4Rに最も適したプラットフォームです。

OML4RのR計算の並列リソースは、Exadataの大規模なパラレル・グリッド・インフラストラクチャを活用します。

ノート:

OML4Rのバージョンは、サーバーと各クライアント・コンピュータで同じである必要があります。また、Rのバージョンは、サーバーと各クライアント・コンピュータで同じである必要があります。サポートされている構成については、「Oracle Machine Learning for Rのデータベース・ユーザーの作成」を参照してください。

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

  1. ノードで、次の手順を実行します。

    • Oracle R Distributionのインストール

    • 環境の確認および構成

    • OML4RサーバーおよびSupporting Packagesのインストール

  2. 最初のノードでのみ、必要に応じてOML4Rユーザーを作成します。または、OML4Rを使用するように既存のデータベース・ユーザーを構成します。次を参照してください。

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

5.2 DCLIを使用したExadataへのOracle Machine Learning for Rのインストール

DCLIを使用してExadataへのOML4Rのインストールを簡略化できます。

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

関連項目:

DCLIの詳細は、My Oracle SupportのWebサイトに移動し、カスタマ・サポートIDでログインして、検索ボックスに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
 -c CELLS            comma-separated list of cells
 -d DESTFILE         destination directory or file
 -f FILE             file to be copied
 -g GROUPFILE        file containing list of cells
 -h, --help          show help message and exit
 -k                  push ssh key to cell's authorized_keys file
 -l USERID           user to login as on remote cells (default: celladmin)
 -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
 -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を使用したOML4Rコンポーネントのインストールについて説明しています。

5.2.1 DCLIを使用したExadataコンピュート・ノードへのOracle R Distributionのインストール

複数のExadata Linuxコンピュート・ノードにOracle R DistributionをインストールするためのDCLIの実行方法。

コマンドは、ExadataへのOracle R Distributionインストール用のDCLIコマンドのサマリーにまとめられています。

重要:

インストールを開始する前に、Oracle Machine Learning for R向けのRのインストールでOracle R Distributionのインストール手順を確認してください。

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

  1. 各計算ノードで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コマンドではパスワードの入力は求められません。

  2. インターネット接続が使用できる場合はyumを使用してOracle R Distributionをインストールします。それ以外の場合は、Oracle R Distributionおよびオペレーティング・システムの依存関係を手動でインストールします。ord-linux-x86_64-Rversion-Exadataversion.tar.gzファイルをOracle Supportにリクエストします。ここでのRversionは、インストールするOracle R Distributionのバージョンであり、Exadataversionは、imageinfoコマンドの実行によるExadataバージョンの出力です。

    1. My Oracle Supportにログインします。

    2. 問合せをクリックします。

    3. yumおよびインターネット・アクセスを使用できない場合は、My Oracle Supportからこのファイルへのアクセスをリクエストします。

      ord-linux-x86_64-Rversion-Exadataversion.tar.gz
      
    4. 権限が付与されたら、rootとして任意の計算ノードにログインし、ファイルをダウンロードします。

  3. ディレクトリを作成し、このディレクトリにダウンロードしたファイルをすべてのノードにレプリケートします。たとえば、次のコマンドは、ディレクトリ/home/oracle/ORDを作成し、ファイルord-linux-x86_64-Rversion-Exadataversion.tar.gzをこのディレクトリにレプリケートします。

    $ dcli -t -g nodes -l root mkdir -p /home/oracle/ORD
    $ dcli -t -g nodes -l root -f 
            ord-linux-x86_64-Rversion-Exadataversion.tar.gz -d
            /home/oracle/ORD/ord-linux-x86_64-Rversion-Exadataversion.tar.gz
    
  4. このファイルを圧縮解除およびuntarして、全ノードに依存RPMをレプリケートします。

    $ dcli -t -g nodes -l root tar xvfz 
            /home/oracle/ORD/ord-linux-x86_64-Rversion-Exadataversion.tar.gz
            -C /home/oracle/ORD
    $ ls /home/oracle/ORD/ord-linux-x86_64-Rversion-Exadataversion.tar.gz
    

    または、Oracle Public YumサーバーからこれらのRPMをダウンロードすることもできます。RPMの場所は、RPMを使用したOracle LinuxへのOracle R Distributionのインストールにリストされています。

  5. 新しいRPMをインストールし、全ノードの既存のRPMを更新するには、次のRPMコマンドを実行します。

    $ dcli -t -g nodes -l root rpm -i --force 
            /home/oracle/ORD/ord-linux-x86_64-Rversion-Exadataversion/*.rpm
    

    --forceフラグによって、循環依存のエラーが発生しません。

  6. Rがインストールされている場所に戻ってからRを開始することによって、各ノードでRインストールを確認します。

    $ dcli -g nodes -l oracle R RHOME
    exadb01: /usr/lib64/R
    exadb02: /usr/lib64/R
    

    ノードごとに、次のコマンドは示されている出力を返します。

    $ dcli -g nodes -l oracle R --vanilla
    ...
    exadb01: R is free software and comes with ABSOLUTELY NO WARRANTY.
    exadb01: You are welcome to redistribute it under certain conditions.
    exadb01: Type 'license()' or 'licence()' for distribution details.
    exadb01:
    exadb01: Natural language support but running in an English locale
    exadb01:
    exadb01: R is a collaborative project with many contributors.
    exadb01: Type 'contributors()' for more information and
    exadb01: 'citation()' on how to cite R or R packages in publications.
    exadb01:
    exadb01: Type 'demo()' for some demos, 'help()' for on-line help, or
    exadb01: 'help.start()' for an HTML browser interface to help.
    exadb01: Type 'q()' to quit R.
    exadb01:
    exadb01: You are using Oracle's distribution of R. Please contact
    exadb01: Oracle Support for any problems you encounter with this
    exadb01: distribution.
5.2.1.1 ExadataへのOracle R Distributionインストール用のDCLIコマンドのサマリー

次の例に、Linux ExadataシステムへのOracle R Distributionのインストールで使用するDCLIコマンドをリストします。

versionを、ご使用のOracle R Distributionのバージョン番号に置き換えます。

例5-2 Oracle R Distribution用のDCLIコマンドのサマリー

ssh-keygen -N " -f ~/.ssh/id_dsa -t dsa
vi nodes # enter node names
dcli -t -g nodes -l root -k -s "\-o StrictHostkeyChecking=no" 
dcli -t -g nodes -l root mkdir -p /home/oracle/ORD
dcli -t -g nodes -l root -f ord-linux-x86_64-version.tar.gz -d
           /home/oracle/ORD/ord-linux-x86_64-version.tar.gz 
dcli -t -g nodes -l root tar xvfz /home/oracle/ORD
           /ord-linux-x86_64-version.tar.gz -C /home/oracle/ORD
dcli -t -g nodes -l root rpm -i --force
           /home/oracle/ORD/ord-linux-x86_64-version/*.rpm
dcli -g nodes -l root R RHOME
dcli -g nodes -l root R --vanilla

5.2.2 12c以前のDCLIを使用したExadataコンピュート・ノードへのOML4Rサーバーのインストール

DCLIを使用してOracle Database 12c以前の複数のExadata Linuxコンピュート・ノードにOML4Rサーバーをインストールする方法。

DCLIコマンドは、Oracle Machine Learning for Rサーバー用のDCLIコマンドのサマリーにまとめられています。

ノート:

インストールを開始する前に、Oracle Machine Learning for RサーバーのインストールOML4Rサーバーのインストール手順を確認してください。

Oracle Database 12c以前でDCLIを使用してExadataにOML4Rサーバーをインストールするには、次のステップに従います。

  1. ORACLE_HOMEORACLE_SIDR_HOMEPATHおよびLD_LIBRARY_PATHを、各ノードに適切に設定し、DCLIスクリプトを実行するシェルと同じシェルに定義します。たとえば、bashrcファイルで次のように値を指定できます。

    export ORACLE_HOME=/hostname/app/oracle/product/release_number/dbhome_1
    export ORACLE_SID=ORCL
    export R_HOME=/usr/lib64/R
    export PATH=$PATH:$R_HOME/bin:$ORACLE_HOME/bin
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:$RHOME_lib:$R_HOME/port/Linux-X64/lib
    
  2. Oracle Machine Learning for R DownloadsのWebサイトに移動します。

    Downloadsページの「Linux 64-bit」の行で、「Server」を選択し、ライセンス契約に同意して、ファイルをダウンロードします。Supporting Packagesをダウンロードするには、「Supporting」を選択し、ライセンス契約に同意して、ファイルをダウンロードします。次のファイルがOML4Rに対してダウンロードされます。versionは、OML4Rのリリース番号です。

    ore-server-linux-x86-64-version.zip
    ore-supporting-linux-x86-64-version.zip
    
  3. rootとしてログインし、OML4RサーバーおよびSupporting Packagesのインストーラを全ノードにコピーします。次に例を示します。

    $ dcli -g nodes -l oracle mkdir -p /home/oracle/OML4R
    $ dcli -g nodes -l oracle -f ore-server-linux-x86-64-version.zip -d 
         /home/oracle/OML4R/ore-server-linux-x86-64-version.zip
    $ dcli -g nodes -l oracle -f ore-supporting-linux-x86-64-version.zip -d 
         /home/oracle/OML4R/ore-supporting-linux-x86-64-version.zip
    
  4. OML4Rサーバー・バンドルを各ノードで解凍します。

    $ dcli -t -g nodes -l oracle unzip
         /home/oracle/OML4R/ore-server-linux-x86-64-version.zip -d
         /my_destination_directory/
  5. 各ノードでSupporting Packagesを解凍します。

    $ dcli -t -g nodes -l oracle unzip   
         /home/oracle/OML4R/ore-supporting-linux-x86-64-version.zip -d 
         /my_destination_directory/
    
  6. OML4R Serverコンポーネントをインストールします。

    $ dcli -t -g nodes -l oracle "cd /my_destination_directory; ./server.sh -y
          --perm permtablespace --temp temptablespace 
          --user-perm usertablespace --user-temp usertemptablespace
          --user OML_USER"

    ノート:

    serverスクリプトによって、OML4Rのユーザーが作成されます。デフォルトでは、ユーザーにRQADMINロールは付与されません

    すべてのOML4Rユーザーは埋込みRを実行できますが、データベースのRスクリプトを作成および削除できるのはRQADMINロールを持つユーザーのみです。RQADMINロールを付与する場合は注意が必要です。

    このロールの詳細は、RQADMINロールについてを参照してください。

  7. OML4Rのロードを確認します。

    > library(ORE)
    Loading required package: OREbase
    Attaching package: OREbase
    The following objects are masked from âpackage:baseâ:
        cbind, data.frame, eval, interaction, order, paste, pmax, pmin,
        rbind, table
    Loading required package: OREembed
    Loading required package: OREstats
    Loading required package: MASS
    Loading required package: OREgraphics
    Loading required package: OREeda
    Loading required package: OREmodels
    Loading required package: OREdm
    Loading required package: lattice
    Loading required package: OREpredict
    Loading required package: ORExml 

5.2.3 18c以降のDCLIを使用したExadataコンピュート・ノードへのOML4Rサーバーのインストール

DCLIを使用してOracle Database 18c以降の複数のExadata Linuxコンピュート・ノードにOML4Rサーバーをインストールする方法。

Oracle Database 18c以降でDCLIを使用してExadataにOML4Rサーバーをインストールするには、次のステップに従います。
  1. ラック内のコンピュート・ノードのリストを取得します。

    次の例では、cat nodesコマンドによって、2ノード・クラスタのノードがリストされます。

    $ cat nodes
    exadb01
    exadb02
  2. テキスト・エディタで、ラック内のすべてのコンピュート・ノードの名前を含むファイルを作成します。1行に1つのノード名を指定します。たとえば、2ノード・クラスタのnodesファイルには、次のようなエントリが含まれます。
    exadb01
    exadb02
  3. ORACLE_HOMEORACLE_SIDR_HOMEPATHおよびLD_LIBRARY_PATHを、各ノードに適切に設定し、DCLIスクリプトを実行するシェルと同じシェルに定義します。たとえば、bashrcファイルで次のように値を指定できます。
    export ORACLE_HOME=/u01/app/oraclecle/product/release_number/dbhome_1
    export ORACLE_SID=ORCL
    export R_HOME=/usr/lib64/R
    export PATH=$PATH:$R_HOME/bin:$ORACLE_HOME/bin
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:$RHOME_lib:$R_HOME/port/Linux-X64/lib
  4. オプション1: 最初のデータベース・ノードのみで、sysdbaとしてPDBからrqcfg.sqlスクリプトを実行します。
    $ sqlplus / as sysdba;
    SQL> alter session set container=PDBNAME;
    SQL> @$ORACLE_HOME/R/server/rqcfg.sql

    ノート:

    rqcfg.sqlスクリプトはOracle Database 18c以降に付属しており、$ORACLE_HOME/R/serverディレクトリにあります。このスクリプトはOML4R Serverコンポーネントをデータベースにインストールします。1回のみ実行する必要があります。

    rqcfg.sqlスクリプトによって、次の入力パラメータを求めるプロンプトが表示されます。

    define permtbl = permanent tablespace name for RQSYS schema
    define temptbl = temporary tablespace name for RQSYS schema
    define orahome = ORACLE_HOME path
    define rhome = R_HOME path

    オプション2: Linuxコマンドラインからrqcfg.sqlスクリプトを実行します。

    この例では、ユーザーはsystemでパスワードはapassword、RQSYSスキーマはSYSAUXにあり、SYSAUXに一時表領域TEMPが割り当てられています。ORACLE_HOMEの値は/u01/app/oracle/product/21.3.0.0/dbhome_1であり、R_HOMEの値はLinuxのデフォルト・パスである/usr/lib64/Rです。

    $ sqlplus -L -S system/apassword @$ORACLE_HOME/R/server/rqcfg.sql SYSAUX TEMP /u01/app/oracle/product/21.3.0.0/dbhome_1 /usr/lib64/R
  5. OML4R Supporting Packagesをダウンロードしてインストールします。

    Supporting Packagesをダウンロードするには、Oracle Machine Learning for R DownloadsのWebサイトに移動します。ご使用のバージョンのデータベースおよびRの列でSupportingを選択し、ライセンス契約に同意し、ore-supporting-linux-x86-64-version.zipファイルをダウンロードします。

    rootとしてログインし、Supporting Packagesのインストーラを全ノードにコピーします。次に例を示します。

    $ dcli -g nodes -l oracle mkdir -p /home/oracle/OML4R
    
    $ dcli -g nodes -l oracle -f ore-supporting-linux-x86-64-version.zip -d
         /home/oracle/OML4R/ore-supporting-linux-x86-64-version.zip

    各ノードでSupporting Packagesを解凍します。

    $ dcli -t -g nodes -l oracle unzip
         /home/oracle/OML4R/ore-supporting-linux-x86-64-version.zip -d
         /my_destination_directory/

    次の例のように、OML4R Supporting Packagesをインストールします。

    $ dcli -t -g nodes -l oracle R CMD INSTALL /my_destination_directory/supporting/* -l $ORACLE_HOME/R/library/

    ノート:

    rqcfg.sqlスクリプトによって、OML4Rユーザーが作成されます。デフォルトでは、ユーザーにRQADMINロールは付与されません。

    すべてのOML4Rユーザーは埋込みRの実行関数を使用できますが、データベースのOML4Rスクリプト・リポジトリでRスクリプトを作成および削除できるのはRQADMINロールを持つユーザーのみです。RQADMINロールを付与する場合は注意が必要です。

  6. OREスクリプトを使用してRを起動し、OML4Rがロードされていることを確認します。
    $ ORE
    
    > library(ORE)
    Loading required package: OREbase
    Attaching package: OREbase
    The following objects are masked from âpackage:baseâ:
        cbind, data.frame, eval, interaction, order, paste, pmax, pmin,
        rbind, table
    Loading required package: OREembed
    Loading required package: OREstats
    Loading required package: MASS
    Loading required package: OREgraphics
    Loading required package: OREeda
    Loading required package: OREmodels
    Loading required package: OREdm
    Loading required package: lattice
    Loading required package: OREpredict
    Loading required package: ORExml

5.2.4 Oracle Machine Learning for Rサーバー用のDCLIコマンドのサマリー

次の例に、Linux ExadataシステムへのOML4RおよびSupporting Packagesのインストールで使用するDCLIコマンドをリストします。

例5-3 OML4Rサーバー用のDCLIコマンドのサマリー

dcli -g nodes -l oracle mkdir -p /home/oracle/ORE
dcli -g nodes -l oracle -f ore-server-linux-x86-64-version.zip -d
     /home/oracle/ORE/ore-server-linux-x86-64-version.zip
dcli -g nodes -l oracle -f ore-supporting-linux-x86-64-version.zip -d
     /home/oracle/ORE/ore-supporting-linux-x86-64-version.zip
dcli -t -g nodes -l oracle unzip
     /home/oracle/ORE/ore-server-linux-x86-64-version.zip -d
     /home/oracle/ORE/
dcli -t -g nodes -l oracle /home/oracle/ORE/server.sh
sqlplus / as sysdba
grant RQADMIN to OML_USER;
exit;
dcli -t -g nodes -l oracle ORE -e "library(ORE)" 

5.3 DCLIを使用しないOracle Machine Learning for RのOracle RACへのインストール

DCLIを使用できない場合に、Oracle Real Application Clusters (Oracle RAC)データベースにOML4Rをインストールする方法。

分散コマンドライン・インタフェース(DCLI)を使用できない場合は、Oracle RACクラスタの各データベース・インスタンスに次のコンポーネントを個別にインストールする必要があります。

  • RまたはOracle R Distribution
  • OML4Rサーバー
  • OML4R Supporting Packages

最初の項では、Oracle Database 18c以降のインストール手順について説明します。2番目の項では、Oracle Database 12c以前の手順について説明します。

Oracle 18c以降のRAC環境でのOML4Rのインストール

次のステップに従って、Oracle R Distribution、OML4RおよびOML4R Supporting Packagesをインストールします。

  1. Oracle R DistributionのインストールOracle Machine Learning for R向けのRのインストールを参照してください。
  2. SQL*Plusを起動し、PDBに直接ログインしてrqcfg.sqlスクリプトを実行します。次の例では、PDB PDB1を使用し、スクリプト引数のサンプル値を指定します。
    SQL> sqlplus / as sysdba
    SQL> alter session set container=PDB1;
    SQL> ALTER PROFILE DEFAULT LIMIT PASSWORD_VERIFY_FUNCTION NULL;
    SQL> @$ORACLE_HOME/R/server/rqcfg.sql
    
    define permtbl = SYSAUX
    define temptbl = TEMP
    define orahome = /u01/app/oracle/product/21.3.0.0/dbhome_1
    define rhome = /usr/lib64/R
  3. オペレーティング・システム・プロンプトで、ORACLE_HOME/binディレクトリに移動し、すべてのユーザーにOREディレクトリに対する読取りおよび実行権限を付与します。
    cd  $ORACLE_HOME/bin
    chmod 755 ORE
  4. システムに適したOML4R 1.5.1 Supporting Packagesを格納するディレクトリを作成し、そのディレクトリに移動します。OML4R Supporting Packagesのインストールの説明に従って、そのディレクトリにSupporting Packagesのzipファイルをダウンロードします。
  5. Supporting Packagesを抽出します。
  6. パッケージごとに、オペレーティング・システム・コマンド・プロンプトで次のコマンドを実行します。
    ORE CMD INSTALL package

Oracle 12c以前のRAC環境でのOML4Rのインストール

次のステップに従って、Oracle R Distribution、OML4RおよびOML4R Supporting Packagesをインストールします。

ノート:

server.shスクリプトを実行するディレクトリと同じディレクトリで最初にOML4R Supporting Packagesのバンドルを抽出することで、ステップ2と3を同時に実行できます。(Microsoft Windowsの場合、スクリプトはserver.batです。)
  1. Oracle R DistributionのインストールOracle Machine Learning for R向けのRのインストールを参照してください。
  2. OML4Rサーバーのインストーラ・バンドルからserver.shスクリプトを実行します。Oracle Machine Learning for Rサーバーのインストールを参照してください
  3. OML4R Supporting Packagesをインストールします。Oracle Database 12c以前のOracle Machine Learning for Rサーバーのインストールを参照してください

server.shスクリプトをノード1で実行すると、OML4Rパッケージがオペレーティング・システムの$ORACLE_HOME/R/libraryディレクトリにインストールされます。また、OML4Rのデータベース・コンポーネントもインストールおよび構成されます。スクリプトの実行時に、プロンプトが表示された場合は新しいデータベース・ユーザーを作成できます。スクリプトの実行時にユーザーを作成できるのは、最初のノードでserver.shスクリプトを実行している間のみです。

後続の各ノードでserver.shスクリプトを実行すると、OML4Rパッケージのみがオペレーティング・システムにインストールされます。