はじめに
タイトルの通り、OCI Base Database ServiceのOracle Database 23aiにORDS 24.4をイントールしてOracle API for MongoDBを有効化し、mongoshからOracle Databaseに接続するまでの手順のメモです。
注意
こちらの記事の内容はあくまで個人の実験メモ的な内容のため、こちらの内容を利用した場合のトラブルには一切責任を負いません。
また、こちらの記事の内容を元にしたOracleサポートへの問い合わせはご遠慮ください。
1. tnsnames.oraの編集
BaseDBのDBシステム(ノード)にopcユーザとしてSSHで接続します。
oracleユーザにスイッチします。
[opc@basedb23ai ~]$ sudo su - oracle
Last login: Fri Apr 4 19:59:07 JST 2025
[oracle@basedb23ai ~]$
lsnrctl statusでpdbのサービス名を確認します。
[oracle@basedb23ai ~]$ lsnrctl status
LSNRCTL for Linux: Version 23.0.0.0.0 - for Oracle Cloud and Engineered Systems on 04-APR-2025 16:54:51
Copyright (c) 1991, 2024, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=basedb23ai.publicsubnet.vcn1.oraclevcn.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 23.0.0.0.0 - for Oracle Cloud and Engineered Systems
Start Date 04-APR-2025 16:42:05
Uptime 0 days 0 hr. 12 min. 46 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/23.0.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/basedb23ai/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=basedb23ai.publicsubnet.vcn1.oraclevcn.com)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "2bd45b2c420628bbe06337d35e643db0.publicsubnet.vcn1.oraclevcn.com" has 1 instance(s).
Instance "db23aihp", status READY, has 1 handler(s) for this service...
Service "2c0caa8eb9692668e0631704f40a7d8f.publicsubnet.vcn1.oraclevcn.com" has 1 instance(s).
Instance "db23aihp", status READY, has 1 handler(s) for this service...
Service "db23aihpXDB.publicsubnet.vcn1.oraclevcn.com" has 1 instance(s).
Instance "db23aihp", status READY, has 1 handler(s) for this service...
Service "db23aihp_pdb1.paas.oracle.com" has 1 instance(s).
Instance "db23aihp", status READY, has 1 handler(s) for this service...
Service "db23aihp_wh4_kix.publicsubnet.vcn1.oraclevcn.com" has 1 instance(s).
Instance "db23aihp", status READY, has 1 handler(s) for this service...
Service "pdb1.publicsubnet.vcn1.oraclevcn.com" has 1 instance(s).
Instance "db23aihp", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@basedb23ai ~]$
PDB(pdb1)のサービス名が、
pdb1.publicsubnet.vcn1.oraclevcn.com
であることが確認できました。
tnsnames.oraファイルを開きます。
[oracle@basedb23ai ~]$ vi $ORACLE_HOME/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/23.0.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
DB23AIHP_WH4_KIX =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = basedb23ai.publicsubnet.vcn1.oraclevcn.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = db23aihp_wh4_kix.publicsubnet.vcn1.oraclevcn.com)
)
)
CDBのネット・サービス名の設定を参考にして、PDB(pdb1)のネット・サービス名(DB23AIHP_PDB1)の設定を追加します
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/23.0.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
DB23AIHP_WH4_KIX =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = basedb23ai.publicsubnet.vcn1.oraclevcn.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = db23aihp_wh4_kix.publicsubnet.vcn1.oraclevcn.com)
)
)
DB23AIHP_PDB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = basedb23ai.publicsubnet.vcn1.oraclevcn.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdb1.publicsubnet.vcn1.oraclevcn.com)
)
)
2. Javaのインストール
ORDS 24.4を利用するにはJava 17以上が必要なので、yumでJava 17をインストールします。
[opc@basedb23ai ~]$ sudo yum install -y java-17
Last metadata expiration check: 0:01:15 ago on Fri 04 Apr 2025 04:51:00 PM JST.
Dependencies resolved.
=========================================================================================================================================================
Package Architecture Version Repository Size
=========================================================================================================================================================
Installing:
jdk-17-headful x86_64 2000:17.0.14-8.el8 ol8_oci_included 115 M
Installing dependencies:
jdk-17-headless x86_64 2000:17.0.14-8.el8 ol8_oci_included 59 M
Transaction Summary
=========================================================================================================================================================
Install 2 Packages
Total download size: 174 M
Installed size: 304 M
Downloading Packages:
(1/2): jdk-17-headless-17.0.14-8.el8.x86_64.rpm 61 MB/s | 59 MB 00:00
(2/2): jdk-17-headful-17.0.14-8.el8.x86_64.rpm 41 MB/s | 115 MB 00:02
---------------------------------------------------------------------------------------------------------------------------------------------------------
Total 62 MB/s | 174 MB 00:02
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : jdk-17-headless-2000:17.0.14-8.el8.x86_64 1/2
Running scriptlet: jdk-17-headless-2000:17.0.14-8.el8.x86_64 1/2
Installing : jdk-17-headful-2000:17.0.14-8.el8.x86_64 2/2
Running scriptlet: jdk-17-headful-2000:17.0.14-8.el8.x86_64 2/2
Running scriptlet: jdk-17-headless-2000:17.0.14-8.el8.x86_64 2/2
Running scriptlet: jdk-17-headful-2000:17.0.14-8.el8.x86_64 2/2
Verifying : jdk-17-headful-2000:17.0.14-8.el8.x86_64 1/2
Verifying : jdk-17-headless-2000:17.0.14-8.el8.x86_64 2/2
Installed:
jdk-17-headful-2000:17.0.14-8.el8.x86_64 jdk-17-headless-2000:17.0.14-8.el8.x86_64
Complete!
[opc@basedb23ai ~]$
3. ORDSのインストール
yumでORDSをインストールします。
[opc@basedb23ai ~]$ sudo yum install -y ords
Last metadata expiration check: 0:02:05 ago on Fri 04 Apr 2025 04:51:00 PM JST.
Dependencies resolved.
=========================================================================================================================================================
Package Architecture Version Repository Size
=========================================================================================================================================================
Installing:
ords noarch 24.4.0-6.el8 ol8_oci_included 139 M
Transaction Summary
=========================================================================================================================================================
Install 1 Package
Total download size: 139 M
Installed size: 144 M
Downloading Packages:
ords-24.4.0-6.el8.noarch.rpm 44 MB/s | 139 MB 00:03
---------------------------------------------------------------------------------------------------------------------------------------------------------
Total 44 MB/s | 139 MB 00:03
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: ords-24.4.0-6.el8.noarch 1/1
Installing : ords-24.4.0-6.el8.noarch 1/1
Running scriptlet: ords-24.4.0-6.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-24.4.0-6.el8.noarch 1/1
Installed:
ords-24.4.0-6.el8.noarch
Complete!
[opc@basedb23ai ~]$
4. データベースへのORDSのインストール
oracleユーザにスイッチします。
[opc@basedb23ai ~]$ sudo su - oracle
Last login: Fri Apr 4 16:54:06 JST 2025
[oracle@basedb23ai ~]$
データベースにORDSをインストールします。
[oracle@basedb23ai ~]$ ords --config /etc/ords/config install
Oracle API for MongoDBを使用するには、ORDSをPDBにインストールする必要があるため、PDBのサービス名が表示されている番号を入力してEnterキーを押します。
ORDS: Release 24.4 Production on Fri Apr 04 07:59:43 2025
Copyright (c) 2010, 2025, Oracle.
Configuration:
/etc/ords/config
The configuration folder /etc/ords/config does not contain any configuration files.
Oracle REST Data Services - Interactive Install
Enter a number to select the TNS net service name to use from /u01/app/oracle/product/23.0.0/dbhome_1/network/admin/tnsnames.ora or specify the database connection
[1] DB23AIHP_PDB1 SERVICE_NAME=pdb1.publicsubnet.vcn1.oraclevcn.com
[2] DB23AIHP_WH4_KIX SERVICE_NAME=db23aihp_wh4_kix.publicsubnet.vcn1.oraclevcn...
[S] Specify the database connection
Choose [1]: 1
管理者権限のあるDBユーザ名(ここではsys)を入力します。
Provide database user name with administrator privileges.
Enter the administrator username: sys
管理者権限のあるDBユーザ名(ここではsys)のパスワードを入力します。
Enter the database password for SYS AS SYSDBA:
インストールのオプションを設定します。
Retrieving information.
ORDS is not installed in the database. ORDS installation is required.
Enter a number to update the value or select option A to Accept and Continue
[1] Connection Type: TNS
[2] TNS Connection: TNS_NAME=DB23AIHP_PDB1 TNS_FOLDER=/u01/app/oracle/product/23.0.0/dbhome_1/network/admin
Administrator User: SYS AS SYSDBA
[3] Database password for ORDS runtime user (ORDS_PUBLIC_USER): <generate>
[4] ORDS runtime user and schema tablespaces: Default: SYSAUX Temporary TEMP
[5] Additional Feature: Database Actions
[6] Configure and start ORDS in Standalone Mode: Yes
[7] Protocol: HTTP
[8] HTTP Port: 8080
[A] Accept and Continue - Create configuration and Install ORDS in the database
[Q] Quit - Do not proceed. No changes
Choose [A]:
ORDS_PUBLIC_USERユーザのパスワードを設定するために、3を入力してEnterキーを押します。
Retrieving information.
ORDS is not installed in the database. ORDS installation is required.
Enter a number to update the value or select option A to Accept and Continue
[1] Connection Type: TNS
[2] TNS Connection: TNS_NAME=DB23AIHP_PDB1 TNS_FOLDER=/u01/app/oracle/product/23.0.0/dbhome_1/network/admin
Administrator User: SYS AS SYSDBA
[3] Database password for ORDS runtime user (ORDS_PUBLIC_USER): <generate>
[4] ORDS runtime user and schema tablespaces: Default: SYSAUX Temporary TEMP
[5] Additional Feature: Database Actions
[6] Configure and start ORDS in Standalone Mode: Yes
[7] Protocol: HTTP
[8] HTTP Port: 8080
[A] Accept and Continue - Create configuration and Install ORDS in the database
[Q] Quit - Do not proceed. No changes
Choose [A]: 3
Sを入力して、Enterキーを押します。
Enter your choice for the runtime user password (ORDS_PUBLIC_USER)
[S] Specify your own password
[G] Generate password
[C] Cancel - No Changes
Choose [G]:S
ORDS_PUBLIC_USERユーザのパスワードを入力し、Enterキーを押します。
Enter the database password for ORDS_PUBLIC_USER:
ORDS_PUBLIC_USERユーザのパスワードを再度入力し、Enterキーを押します。
Confirm password:
ORDS_PUBLIC_USERユーザのパスワードが設定できたら、その他の設定値を確認し、Aを入力してEnterキーを押します。
Enter a number to update the value or select option A to Accept and Continue
[1] Connection Type: TNS
[2] TNS Connection: TNS_NAME=DB23AIHP_PDB1 TNS_FOLDER=/u01/app/oracle/product/23.0.0/dbhome_1/network/admin
Administrator User: SYS AS SYSDBA
[3] Database password for ORDS runtime user (ORDS_PUBLIC_USER): <specified password>
[4] ORDS runtime user and schema tablespaces: Default: SYSAUX Temporary TEMP
[5] Additional Feature: Database Actions
[6] Configure and start ORDS in Standalone Mode: Yes
[7] Protocol: HTTP
[8] HTTP Port: 8080
[A] Accept and Continue - Create configuration and Install ORDS in the database
[Q] Quit - Do not proceed. No changes
Choose [A]: A
PDB(pdb1)へのORDSのインストールが始まります。
The setting named: db.connectionType was set to: tns in configuration: default
The setting named: db.tnsAliasName was set to: DB23AIHP_PDB1 in configuration: default
The setting named: db.tnsDirectory was set to: /u01/app/oracle/product/23.0.0/dbhome_1/network/admin in configuration: default
The setting named: db.username was set to: ORDS_PUBLIC_USER in configuration: default
The setting named: db.password was set to: ****** in configuration: default
The setting named: feature.sdw was set to: true in configuration: default
The global setting named: database.api.enabled was set to: true
The setting named: restEnabledSql.active was set to: true in configuration: default
The global setting named: standalone.http.port was set to: 8080
The global setting named: standalone.doc.root was set to: /etc/ords/config/global/doc_root
The setting named: security.requestValidationFunction was set to: ords_util.authorize_plsql_gateway in configuration: default
2025-04-04T08:04:41.348Z INFO Created folder /home/oracle/logs
2025-04-04T08:04:41.349Z INFO The log file is defaulted to the current working directory located at /home/oracle/logs
2025-04-04T08:04:41.483Z INFO Installing Oracle REST Data Services version 24.4.0.r3451601 in PDB1
2025-04-04T08:04:42.843Z INFO ... Verified database prerequisites
2025-04-04T08:04:43.295Z INFO ... Created Oracle REST Data Services proxy user
2025-04-04T08:04:44.024Z INFO ... Created Oracle REST Data Services schema
2025-04-04T08:04:44.634Z INFO ... Granted privileges to Oracle REST Data Services
2025-04-04T08:04:47.195Z INFO ... Created Oracle REST Data Services database objects
2025-04-04T08:04:57.419Z INFO Completed installation for Oracle REST Data Services version 24.4.0.r3451601. Elapsed time: 00:00:15.909
2025-04-04T08:04:57.421Z INFO Log file written to /home/oracle/logs/ords_install_2025-04-04_080441_34963.log
2025-04-04T08:04:57.633Z INFO HTTP and HTTP/2 cleartext listening on host: 0.0.0.0 port: 8080
2025-04-04T08:04:57.663Z INFO Disabling document root because the specified folder does not exist: /etc/ords/config/global/doc_root
2025-04-04T08:04:57.663Z INFO Default forwarding from / to contextRoot configured.
2025-04-04T08:05:00.660Z INFO Configuration properties for: |default|lo|
db.password=******
db.tnsAliasName=DB23AIHP_PDB1
conf.use.wallet=true
security.requestValidationFunction=ords_util.authorize_plsql_gateway
database.api.enabled=true
db.username=ORDS_PUBLIC_USER
standalone.http.port=8080
restEnabledSql.active=true
resource.templates.enabled=false
feature.sdw=true
config.required=true
db.connectionType=tns
standalone.doc.root=/etc/ords/config/global/doc_root
db.tnsDirectory=/u01/app/oracle/product/23.0.0/dbhome_1/network/admin
2025-04-04T08:05:00.662Z WARNING *** jdbc.MaxLimit in configuration |default|lo| is using a value of 10, this setting may not be sized adequately for a production environment ***
2025-04-04T08:05:00.944Z INFO
Mapped local pools from /etc/ords/config/databases:
/ords/ => default => VALID
2025-04-04T08:05:00.991Z INFO Oracle REST Data Services initialized
Oracle REST Data Services version : 24.4.0.r3451601
Oracle REST Data Services server info: jetty/12.0.13
Oracle REST Data Services java info: Java HotSpot(TM) 64-Bit Server VM (build: 17.0.14+8-LTS-191 mixed mode, sharing)
Ctl-Cで終了します。
5. Oracle API for MongoDBの有効化
Oracle API for MongoDBを有効化する設定を追加します。
[oracle@basedb23ai ~]$ ords config set mongo.enabled true
2025-04-04T08:06:11Z INFO ORDS has not detected the option '--config' and this will be set up to the default directory.
ORDS: Release 24.4 Production on Fri Apr 04 08:06:12 2025
Copyright (c) 2010, 2025, Oracle.
Configuration:
/etc/ords/config
The global setting named: mongo.enabled was set to: true
[oracle@basedb23ai ~]$
今回は検証のため、Oracle API for MongoDBのTLS接続を無効化する設定を追加します。
[oracle@basedb23ai ~]$ ords config set mongo.tls false
2025-04-04T08:09:43Z INFO ORDS has not detected the option '--config' and this will be set up to the default directory.
ORDS: Release 24.4 Production on Fri Apr 04 08:09:45 2025
Copyright (c) 2010, 2025, Oracle.
Configuration:
/etc/ords/config
The global setting named: mongo.tls was set to: false
[oracle@basedb23ai ~]$
6. Oracle API for MongoDBの接続文字列の確認
Oracle API for MongoDBに接続するための接続文字列を確認するため、一度ords serveコマンドでORDSを起動します。
[oracle@basedb23ai ~]$ ords serve
2025-04-04T08:35:00Z INFO ORDS has not detected the option '--config' and this will be set up to the default directory.
ORDS: Release 24.4 Production on Fri Apr 04 08:35:02 2025
Copyright (c) 2010, 2025, Oracle.
Configuration:
/etc/ords/config
2025-04-04T08:35:02.703Z INFO HTTP and HTTP/2 cleartext listening on host: 0.0.0.0 port: 8080
2025-04-04T08:35:02.732Z INFO Disabling document root because the specified folder does not exist: /etc/ords/config/global/doc_root
2025-04-04T08:35:02.733Z INFO Default forwarding from / to contextRoot configured.
2025-04-04T08:35:02.764Z WARNING
WARNING: mongo.tls is disabled
Disabling TLS for the MongoDB API is strongly discouraged.
Without TLS, usernames and passwords are transmitted in plain text by the MongoDB wire protocol.
This may allow a third-party to intercept and observe the transmitted credentials.
Additionally, when TLS is disabled, all requests will be routed to the default connection pool and any hostname mappings will be ignored.
2025-04-04T08:35:02.791Z SEVERE ORAMLVERSION null
2025-04-04T08:35:02.797Z INFO Oracle API for MongoDB listening on port: 27017
2025-04-04T08:35:02.797Z INFO The Oracle API for MongoDB connection string is:
mongodb://[{user}:{password}@]localhost:27017/{user}?authMechanism=PLAIN&authSource=$external&ssl=false&retryWrites=false&loadBalanced=true
2025-04-04T08:35:07.054Z INFO Configuration properties for: |default|lo|
db.tnsAliasName=DB23AIHP_PDB1
java.specification.version=17
conf.use.wallet=true
sun.jnu.encoding=UTF-8
user.region=US
java.class.path=/opt/oracle/ords/ords.war
java.vm.vendor=Oracle Corporation
sun.arch.data.model=64
nashorn.args=--no-deprecation-warning
mongo.enabled=true
java.vendor.url=https://java.oracle.com/
resource.templates.enabled=false
user.timezone=UTC
java.vm.specification.version=17
os.name=Linux
sun.java.launcher=SUN_STANDARD
user.country=US
sun.boot.library.path=/usr/lib/jvm/jdk-17.0.14-oracle-x64/lib
sun.java.command=/opt/oracle/ords/ords.war --config /etc/ords/config serve
jdk.debug=release
sun.cpu.endian=little
user.home=/home/oracle
oracle.dbtools.launcher.executable.jar.path=/opt/oracle/ords/ords.war
user.language=en
mongo.tls=false
sun.stderr.encoding=UTF-8
java.specification.vendor=Oracle Corporation
java.version.date=2025-01-21
database.api.enabled=true
java.home=/usr/lib/jvm/jdk-17.0.14-oracle-x64
db.username=ORDS_PUBLIC_USER
file.separator=/
java.vm.compressedOopsMode=Zero based
line.separator=
sun.stdout.encoding=UTF-8
restEnabledSql.active=true
java.specification.name=Java Platform API Specification
java.vm.specification.vendor=Oracle Corporation
feature.sdw=true
java.awt.headless=true
db.password=******
sun.management.compiler=HotSpot 64-Bit Tiered Compilers
security.requestValidationFunction=ords_util.authorize_plsql_gateway
java.runtime.version=17.0.14+8-LTS-191
user.name=oracle
path.separator=:
standalone.http.port=8080
os.version=5.4.17-2136.326.6.el8uek.x86_64
java.runtime.name=Java(TM) SE Runtime Environment
file.encoding=utf-8
java.vm.name=Java HotSpot(TM) 64-Bit Server VM
standalone.doc.root=/etc/ords/config/global/doc_root
db.tnsDirectory=/u01/app/oracle/product/23.0.0/dbhome_1/network/admin
java.vendor.url.bug=https://bugreport.java.com/bugreport/
java.io.tmpdir=/tmp
oracle.dbtools.cmdline.ShellCommand=ords
java.version=17.0.14
user.dir=/home/oracle
os.arch=amd64
java.vm.specification.name=Java Virtual Machine Specification
oracle.dbtools.cmdline.home=/opt/oracle/ords
native.encoding=UTF-8
java.library.path=/u01/app/oracle/product/23.0.0/dbhome_1/lib:/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib
java.vendor=Oracle Corporation
java.vm.info=mixed mode, sharing
java.vm.version=17.0.14+8-LTS-191
java.specification.maintenance.version=1
sun.io.unicode.encoding=UnicodeLittle
db.connectionType=tns
java.class.version=61.0
2025-04-04T08:35:07.056Z WARNING *** jdbc.MaxLimit in configuration |default|lo| is using a value of 10, this setting may not be sized adequately for a production environment ***
2025-04-04T08:35:07.374Z INFO
Mapped local pools from /etc/ords/config/databases:
/ords/ => default => VALID
2025-04-04T08:35:07.470Z INFO Oracle REST Data Services initialized
Oracle REST Data Services version : 24.4.0.r3451601
Oracle REST Data Services server info: jetty/12.0.13
Oracle REST Data Services java info: Java HotSpot(TM) 64-Bit Server VM (build: 17.0.14+8-LTS-191 mixed mode, sharing)
2025-04-04T08:35:07.537Z INFO RequestMonitor 1
2025-04-04T08:35:07.538Z INFO WatchdogMonitor 1
2025-04-04T08:35:07.538Z INFO AccessLogMonitor 1 0
2025-04-04T08:35:07.537Z INFO TransactionMonitor 1
2025-04-04T08:35:07.537Z INFO CursorMonitor 1
真ん中くらいに、以下のようなOracle API for MongoDBの接続文字列が記載されていますので、メモしておきます。
The Oracle API for MongoDB connection string is:
mongodb://[{user}:{password}@]localhost:27017/{user}?authMechanism=PLAIN&authSource=$external&ssl=false&retryWrites=false&loadBalanced=true
Ctrl-Cで終了します。
7. ORDSの自動起動の設定
oracleユーザからログアウトし、opcユーザにスイッチします
[oracle@basedb23ai ~]$ exit
logout
[opc@basedb23ai ~]$
systemctlコマンドでORDSを自動起動するように設定します。
[opc@basedb23ai ~]$ sudo 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.
[opc@basedb23ai ~]$
8. ORDSの起動
systemctlコマンドでORDSを起動します。
[opc@basedb23ai ~]$ sudo systemctl start ords
ORDSが起動していることを確認します。
[opc@basedb23ai ~]$ ps -ef | grep ords
oracle 46362 1 0 17:12 ? 00:00:00 /bin/bash /usr/local/bin/ords --config /etc/ords/config serve
oracle 46400 46362 99 17:12 ? 00:00:20 java -Doracle.dbtools.cmdline.home=/opt/oracle/ords -Duser.language=en -Duser.region=US -Dfile.encoding=UTF-8 -Djava.awt.headless=true -Dnashorn.args=--no-deprecation-warning -Doracle.dbtools.cmdline.ShellCommand=ords -Duser.timezone=UTC -jar /opt/oracle/ords/ords.war --config /etc/ords/config serve
opc 46539 18966 0 17:12 pts/0 00:00:00 grep --color=auto ords
[opc@basedb23ai ~]$
9. Oracle API for MongoDBで接続するユーザの作成とORDSの有効化
oracleユーザにスイッチします。
[opc@basedb23ai ~]$ sudo su - oracle
Last login: Fri Apr 4 17:18:02 JST 2025
[oracle@basedb23ai ~]$
SQL*PlusからsysユーザとしてPDB(pdb1)に接続します。
[oracle@basedb23ai ~]$ sqlplus sys@db23aihp_pdb1 as sysdba
SQL*Plus: Release 23.0.0.0.0 - for Oracle Cloud and Engineered Systems on Fri Apr 4 17:19:09 2025
Version 23.7.0.25.01
Copyright (c) 1982, 2024, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 23ai EE High Perf Release 23.0.0.0.0 - for Oracle Cloud and Engineered Systems
Version 23.7.0.25.01
SQL>
PDB(pdb1)に接続していることを確認します。
SQL> show con_name
CON_NAME
------------------------------
PDB1
SQL>
Oracle API for MongoDB経由で接続するユーザ(ここではtestuser)を作成します。
SQL> GRANT CONNECT, RESOURCE, UNLIMITED TABLESPACE TO testuser IDENTIFIED BY Demo#1Demo#1;
Grant succeeded.
SQL>
testuserユーザに対して、ORDSを有効化します。(ORDSからアクセス可能になります。)
SQL> GRANT inherit privileges on user sys to ORDS_METADATA;
Grant succeeded.
SQL> BEGIN
2 ORDS.ENABLE_SCHEMA(
3 p_enabled => TRUE,
4 p_schema => 'TESTUSER',
5 p_url_mapping_type => 'BASE_PATH',
6 p_url_mapping_pattern => 'testuser',
7 p_auto_rest_auth=> FALSE
8 );
9 COMMIT;
10 END;
11 /
PL/SQL procedure successfully completed.
SQL>
SQL*Plusを終了します。
SQL> exit
Disconnected from Oracle Database 23ai EE High Perf Release 23.0.0.0.0 - for Oracle Cloud and Engineered Systems
Version 23.7.0.25.01
[oracle@basedb23ai ~]$
10. mongoshのインストール
oracleユーザからログアウトし、opcユーザにスイッチします。
[oracle@basedb23ai ~]$ exit
logout
[opc@basedb23ai ~]$
yumコマンドでmongoshをインストールするために、repoファイルを作成します。
[opc@basedb23ai ~]$ sudo vi /etc/yum.repos.d/mongodb-org-8.0.repo
[mongodb-org-8.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/8.0/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-8.0.asc
yumコマンドでmongoshをインストールします。
[opc@basedb23ai ~]$ sudo yum install -y mongodb-mongosh
MongoDB Repository 26 kB/s | 25 kB 00:00
Dependencies resolved.
=========================================================================================================================================================
Package Architecture Version Repository Size
=========================================================================================================================================================
Installing:
mongodb-mongosh x86_64 2.4.2-1.el8 mongodb-org-8.0 56 M
Transaction Summary
=========================================================================================================================================================
Install 1 Package
Total download size: 56 M
Installed size: 251 M
Downloading Packages:
mongodb-mongosh-2.4.2.x86_64.rpm 59 MB/s | 56 MB 00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------
Total 59 MB/s | 56 MB 00:00
MongoDB Repository 1.0 kB/s | 1.6 kB 00:01
Importing GPG key 0x4E7DCA05:
Userid : "MongoDB 8.0 Release Signing Key <packaging@mongodb.com>"
Fingerprint: 4B07 52C1 BCA2 38C0 B4EE 14DC 41DE 058A 4E7D CA05
From : https://www.mongodb.org/static/pgp/server-8.0.asc
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : mongodb-mongosh-2.4.2-1.el8.x86_64 1/1
Running scriptlet: mongodb-mongosh-2.4.2-1.el8.x86_64 1/1
Verifying : mongodb-mongosh-2.4.2-1.el8.x86_64 1/1
Installed:
mongodb-mongosh-2.4.2-1.el8.x86_64
Complete!
[opc@basedb23ai ~]$
11. mongoshからOracle Database 23aiに接続
6.で確認したOracle API for MongoDBの接続文字列を使用して、mongoshからOracle Database 23aiに接続します。
[opc@basedb23ai ~]$ mongosh 'mongodb://testuser@localhost:27017/testuser?authMechanism=PLAIN&authSource=$external&ssl=false&retryWrites=false&loadBalanced=true'
Enter password: ************
Current Mongosh Log ID: 67efa5d5d7ddfb52806b140a
Connecting to: mongodb://<credentials>@localhost:27017/testuser?authMechanism=PLAIN&authSource=%24external&ssl=false&retryWrites=false&loadBalanced=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.4.2
Using MongoDB: 4.2.14
Using Mongosh: 2.4.2
For mongosh info see: https://www.mongodb.com/docs/mongodb-shell/
To help improve our products, anonymous usage data is collected and sent to MongoDB periodically (https://www.mongodb.com/legal/privacy-policy).
You can opt-out by running the disableTelemetry() command.
testuser>
Oracle API for MongoDBを使用して、mongoshからBaseDB 23aiに接続できました。