Oracle REST Data Services 22.3を使ってCustomer Managed ORDSを構成してみます。22.3以前のバージョンと比較すると、インストール手順が大幅に簡素化されています。
以下が前提条件になります。
- Autonomous Databaseが作成済み(今回はAlways FreeのATPを使っています)。
- インスタンス・ウォレットがダウンロード済み(今回はWallet_APEX.zipとします)。
- 仮想クラウド・ネットワークが構成済み。
- コンピュート・インスタンスが作成済み。
- コンピュート・インスタンスがパブリック・ネットワークに配置され、パブリックIPアドレスが割り当てられている。
- パブリック・ネットワークのイングレス・ルールとしてポート80と443の通信が許可されている。
CDNの設定
begin
dbms_output.put_line(
apex_instance_admin.get_parameter(
p_parameter => 'IMAGE_PREFIX'
)
);
end;
https://static.oracle.com/cdn/apex/22.2.0/
begin
apex_instance_admin.set_parameter(
p_parameter => 'IMAGE_PREFIX'
, p_value => 'https://static.oracle.com/cdn/apex/22.2.0/'
);
end;
firewalldの構成
firewall-cmd --add-forward-port=port=443:proto=tcp:toport=8443
firewall-cmd --runtime-to-permanent
firewall-cmd --reload
firewall-cmd --list-all
Customer Managed ORDSを構成するコンピュート・インスタンスにログインし、ユーザーrootで上記のコマンドを実行します。
[root@cmords ~]# firewall-cmd --add-service=https
success
[root@cmords ~]# firewall-cmd --add-forward-port=port=443:proto=tcp:toport=8443
success
[root@cmords ~]# firewall-cmd --runtime-to-permanent
success
[root@cmords ~]# firewall-cmd --reload
success
[root@cmords ~]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: enp0s3
sources:
services: dhcpv6-client https ssh
ports:
protocols:
forward: no
masquerade: no
forward-ports:
port=443:proto=tcp:toport=8443:toaddr=
source-ports:
icmp-blocks:
rich rules:
[root@cmords ~]#
Java Development Kitのインストール
JDK 17をインストールします。Oracle Cloudのコンピュート・インスタンスにはあらかじめJDK-17を含むリポジトリが登録済み(Intel、ARMともに)です。以下のコマンドを実行すると、JDK-17のインストールは完了します。
dnf -y install jdk-17[root@cmords ~]# dnf -y install jdk-17
Failed to set locale, defaulting to C.UTF-8
Ksplice for Oracle Linux 8 (aarch64) 1.1 MB/s | 470 kB 00:00
MySQL 8.0 for Oracle Linux 8 (aarch64) 27 MB/s | 2.6 MB 00:00
MySQL 8.0 Tools Community for Oracle Linux 8 (aarch64) 2.9 MB/s | 235 kB 00:00
MySQL 8.0 Connectors Community for Oracle Linux 8 (aarch64) 375 kB/s | 23 kB 00:00
Oracle Software for OCI users on Oracle Linux 8 (aarch64) 38 MB/s | 54 MB 00:01
Oracle Linux 8 BaseOS Latest (aarch64) 64 MB/s | 66 MB 00:01
Oracle Linux 8 Application Stream (aarch64) 62 MB/s | 36 MB 00:00
Oracle Linux 8 Addons (aarch64) 11 MB/s | 4.8 MB 00:00
Dependencies resolved.
=======================================================================================================
Package Architecture Version Repository Size
=======================================================================================================
Installing:
jdk-17 aarch64 2000:17.0.5-ga ol8_oci_included 154 M
Transaction Summary
=======================================================================================================
Install 1 Package
Total download size: 154 M
Installed size: 304 M
Downloading Packages:
jdk-17.0.5_linux-aarch64_bin.rpm 30 MB/s | 154 MB 00:05
-------------------------------------------------------------------------------------------------------
Total 30 MB/s | 154 MB 00:05
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : jdk-17-2000:17.0.5-ga.aarch64 1/1
Running scriptlet: jdk-17-2000:17.0.5-ga.aarch64 1/1
Verifying : jdk-17-2000:17.0.5-ga.aarch64 1/1
Installed:
jdk-17-2000:17.0.5-ga.aarch64
Complete!
[root@cmords ~]#
インストールされたJavaのバージョンを確認します。
java -version
[root@cmords ~]# java -version
java version "17.0.5" 2022-10-18 LTS
Java(TM) SE Runtime Environment (build 17.0.5+9-LTS-191)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.5+9-LTS-191, mixed mode, sharing)
[root@cmords ~]#
バージョンが17であればJDKのインストールは完了です。
Oracle REST Data Servicesのインストール
IntelとARMでインストールのために実行するコマンドが異なります。Intelの場合は、ORDSを含むリポジトリが構成済みであるため、以下のコマンドを実行するとORDSがインストールされます。
dnf -y install ords
ARMの場合は、以下のコマンドを実行します。x86_64のリポジトリを指定していますが、ORDS自体はCPUアーキテクチャに依存しないため、問題なくインストールできます。dnf -y --repofrompath ol8_oracle_software,http://yum.oracle.com/repo/OracleLinux/OL8/oracle/software/x86_64 install ords
dnf -y --repofrompath ol9_oracle_software,https://yum.oracle.com/repo/OracleLinux/OL9/oracle/software/x86_64/ install ords
[root@cmords ~]# dnf -y --repofrompath ol8_oracle_software,http://yum.oracle.com/repo/OracleLinux/OL8/oracle/software/x86_64 install ords
Failed to set locale, defaulting to C.UTF-8
Added ol8_oracle_software repo from http://yum.oracle.com/repo/OracleLinux/OL8/oracle/software/x86_64
ol8_oracle_software 814 kB/s | 58 kB 00:00
Dependencies resolved.
=======================================================================================================
Package Architecture Version Repository Size
=======================================================================================================
Installing:
ords noarch 22.3.3-1.el8 ol8_oracle_software 87 M
Transaction Summary
=======================================================================================================
Install 1 Package
Total download size: 87 M
Installed size: 91 M
Downloading Packages:
ords-22.3.3-1.el8.noarch.rpm 6.2 MB/s | 87 MB 00:14
-------------------------------------------------------------------------------------------------------
Total 6.2 MB/s | 87 MB 00:14
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: ords-22.3.3-1.el8.noarch 1/1
Installing : ords-22.3.3-1.el8.noarch 1/1
Running scriptlet: ords-22.3.3-1.el8.noarch 1/1
INFO: Before starting ORDS service, run the below command as user oracle:
ords --config /etc/ords/config install
INFO: To enable the ORDS service during startup, run the below command:
sudo systemctl enable ords
Verifying : ords-22.3.3-1.el8.noarch 1/1
Installed:
ords-22.3.3-1.el8.noarch
Complete!
[root@cmords ~]#
以上でORDSのインストールは完了です。ORDSをRPMからインストールすると、ユーザーoracleも同時に作成されます。
Oracle REST Data Servicesの構成
su - oracle
cd /etc/ords/config
[root@cmords ~]# su - oracle
Last login: Fri Nov 25 05:54:54 GMT 2022 on pts/0
[oracle@cmords ~]$ cd /etc/ords/config
[oracle@cmords config]$
データベースへの接続に使用するウォレットを/etc/ords/config以下にコピーしておきます。リモート・コピーのツール(sftpなど)を使って、ウォレット・ファイルをアップロードします。今回はウォレット・ファイルとしてWallet_APEX.zipをアップロードしています。
[oracle@cmords config]$ ls -l Wallet_APEX.zip
-rw-r--r--. 1 oracle oinstall 26412 Nov 25 06:00 Wallet_APEX.zip
[oracle@cmords config]$
ords install adb --interactive --prompt-password
[oracle@cmords config]$ ords install adb --interactive --prompt-password
ORDS: Release 22.3 Production on Fri Nov 25 06:06:12 2022
Copyright (c) 2010, 2022, Oracle.
Configuration:
/etc/ords/config/
The configuration folder /etc/ords/config does not contain any configuration files.
Oracle REST Data Services - Interactive Customer Managed ORDS for Autonomous Database
Enter the Autonomous Database Wallet path: /etc/ords/config/Wallet_APEX.zip
Enter a number to select the TNS Network alias to use
[1] APEX_LOW ...service_name=bp9nc*******4p_apex_low.adb.oraclecloud....
[2] APEX_MEDIUM ...service_name=bp9nc*******4p_apex_medium.adb.oracleclo...
[3] APEX_HIGH ...service_name=bp9nc*******4p_apex_high.adb.oraclecloud...
[4] APEX_TP ...service_name=bp9nc*******4p_apex_tp.adb.oraclecloud.c...
[5] APEX_TPURGENT ...service_name=bp9ncf74sqibu4p_apex_tpurgent.adb.oraclec...
Choose [1]:
Provide database user name with administrator privileges.
Enter the administrator username [ADMIN]:
Enter the database password for ADMIN: ********
Enter the ORDS runtime database username [ORDS_PUBLIC_USER2]:
Enter the database password for ORDS_PUBLIC_USER2: ********
Confirm password: ********
Enter the PL/SQL Gateway database username: ORDS_PLSQL_GATEWAY2
Enter the database password for ORDS_PLSQL_GATEWAY2: ********
Confirm password: ********
Connecting to Autonomous database user: ADMIN TNS Service: APEX_LOW
Retrieving information
Enter a number to select additional feature(s) to enable:
[1] Database Actions (Enables all features)
[2] REST Enabled SQL and Database API
[3] REST Enabled SQL
[4] Database API
[5] None
Choose [1]: 3
Enter a number to configure and start ORDS in standalone mode
[1] Configure and start ORDS in standalone mode
[2] Skip
Choose [1]:
Enter a number to select the protocol
[1] HTTP
[2] HTTPS
Choose [1]: 2
Enter the HTTPS port [8443]:
The setting named: db.wallet.zip.path was set to: /etc/ords/config/Wallet_APEX.zip in configuration: default
The setting named: db.wallet.zip.service was set to: APEX_LOW in configuration: default
The setting named: db.username was set to: ORDS_PUBLIC_USER2 in configuration: default
The setting named: db.password was set to: ****** in configuration: default
The setting named: plsql.gateway.mode was set to: proxied in configuration: default
The setting named: feature.sdw was set to: false in configuration: default
The global setting named: database.api.enabled was set to: false
The setting named: restEnabledSql.active was set to: true in configuration: default
The setting named: security.requestValidationFunction was set to: ords_util.authorize_plsql_gateway in configuration: default
The global setting named: standalone.https.port was set to: 8443
The global setting named: standalone.context.path was set to: /ords
The global setting named: standalone.doc.root was set to: /etc/ords/config/global/doc_root
2022-11-25T06:07:44.005Z INFO Connecting to Autonomous database user: ADMIN TNS Service: APEX_LOW
------------------------------------------------------------
Date : 25 Nov 2022 06:07:44
Release : Oracle REST Data Services 22.3.3.r3111929
Database : Oracle Database 19c Enterprise Edition
DB Version : 19.17.0.1.0
------------------------------------------------------------
Container Name: BP9NCF74SQIBU4P_APEX
------------------------------------------------------------
[*** script: ords_runtime_user.sql]
[中略]
2022-11-25T06:07:53.759Z WARNING *** jdbc.MaxLimit in configuration |default|lo| is using a value of 10, this setting may not be sized adequately for a production environment ***
2022-11-25T06:07:53.760Z WARNING *** jdbc.InitialLimit in configuration |default|lo| is using a value of 3, this setting may not be sized adequately for a production environment ***
2022-11-25T06:07:57.754Z INFO Oracle REST Data Services initialized
Oracle REST Data Services version : 22.3.3.r3111929
Oracle REST Data Services server info: jetty/10.0.12
Oracle REST Data Services java info: Java HotSpot(TM) 64-Bit Server VM 17.0.5+9-LTS-191
まだ設定は完了していないため、CTRL+Cを入力し処理を中断します。
自己署名証明書によるHTTPS化
http://apexugj.blogspot.com/2022/11/building-oracle-apex-environment-10-https.html
systemctl start ords
[root@cmords ~]# systemctl enable ords
Synchronizing state of ords.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable ords
Created symlink /etc/systemd/system/multi-user.target.wants/ords.service → /etc/systemd/system/ords.service.
Created symlink /etc/systemd/system/graphical.target.wants/ords.service → /etc/systemd/system/ords.service.
[root@cmords ~]# systemctl start ords
[root@cmords ~]#
PL/SQL Gateway Userについて
connect ords_public_user2[ords_plsql_gateway2]/[ords_public_user2のパスワード]@apex_low
実際にAutonomous Databaseに標準で作成されているユーザーORDS_PLSQL_GATEWAYのAUTHENTICATION_TYPEはPASSWORDではなくNONEになっており、パスワードは設定されていません。