ORDS就是Oracle REST Data Services。
环境如下:
- Oracle Linux 8
- Oracle Database 19c
- IP地址为A.B.C.D
要安装最新版本的ORDS,当前为24.1.1。
全程参考文档:Installing and Configuring Oracle REST Data Services
安装ORDS
添加repository到yum配置中
## 如果是Linux 7
sudo yum-config-manager --add-repo=http://yum.oracle.com/repo/OracleLinux/OL7/oracle/software/x86_64
## 如果是Linux 8
sudo yum-config-manager --add-repo=https://yum.oracle.com/repo/OracleLinux/OL8/oracle/software/x86_64/
yum安装,速度很快,就115M:
$ yum info ords
Last metadata expiration check: 0:00:21 ago on Wed 29 May 2024 07:45:32 AM GMT.
Available Packages
Name : ords
Version : 24.1.1
Release : 4.el8
Architecture : noarch
Size : 115 M
Source : ords-24.1.1-4.el8.src.rpm
Repository : ol8_oci_included
Summary : Oracle REST Data Services
URL : https://www.oracle.com/database/technologies/appdev/rest.html
License : Oracle Free Use Terms and Conditions.
Description : Oracle REST Data Services (ORDS) makes it easy to develop modern REST
: interfaces for relational data in the Oracle Database
Name : ords
Version : 24.1.1
Release : 4.el8
Architecture : noarch
Size : 115 M
Source : ords-24.1.1-4.el8.src.rpm
Repository : yum.oracle.com_repo_OracleLinux_OL8_oracle_software_x86_64_
Summary : Oracle REST Data Services
URL : https://www.oracle.com/database/technologies/appdev/rest.html
License : Oracle Free Use Terms and Conditions.
Description : Oracle REST Data Services (ORDS) makes it easy to develop modern REST
: interfaces for relational data in the Oracle Database
$ sudo yum install ords
created by dnf config-manager from https://yum.oracle.com/repo/OracleLinux/OL8/oracle/software/x86_64/ 3.2 MB/s | 119 kB 00:00
Dependencies resolved.
=======================================================================================================================================
Package Architecture Version Repository Size
=======================================================================================================================================
Installing:
ords noarch 24.1.1-4.el8 ol8_oci_included 115 M
Transaction Summary
=======================================================================================================================================
Install 1 Package
Total download size: 115 M
Installed size: 119 M
Is this ok [y/N]: y
Downloading Packages:
ords-24.1.1-4.el8.noarch.rpm 59 MB/s | 115 MB 00:01
---------------------------------------------------------------------------------------------------------------------------------------
Total 58 MB/s | 115 MB 00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: ords-24.1.1-4.el8.noarch 1/1
Installing : ords-24.1.1-4.el8.noarch 1/1
Running scriptlet: ords-24.1.1-4.el8.noarch 1/1
WARN: ORDS requires Java 11 or 17.
You can install Oracle Java at https://www.oracle.com/java/technologies/downloads/#java11.
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.1.1-4.el8.noarch 1/1
Installed:
ords-24.1.1-4.el8.noarch
Complete!
安装尾部有重要的信息,给出了后续配置的命令和启动服务的命令:
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
配置ORDS
虽然我已经有Java 8,ORDS需要Java 11或以上才能运行。
$ ords --config /etc/ords/config install
Error: ORDS requires Java 11 and above to run.
Found Java version 1.8.0_341.
Please set JAVA_HOME to appropriate version and update PATH if necessary.
从官网下载JDK并安装:
$ sudo rpm -ivh jdk-11.0.23_linux-x64_bin.rpm
不小心下载了个低版本的,没关系,也能用。
配置其实就1个命令:
ords --config /etc/ords/config install
但这个命令实际在配置成功后,还会运行ORDS。所以这是个前台命令,不要傻傻的等他结束。看到下面的信息,就表示安装成功了。
...
2024-05-29T07:59:25.535Z INFO Oracle REST Data Services initialized
Oracle REST Data Services version : 24.1.1.r1201228
Oracle REST Data Services server info: jetty/10.0.20
Oracle REST Data Services java info: Java HotSpot(TM) 64-Bit Server VM 11.0.23+7-LTS-222
第一次安装失败,因为有个PDB:ORCLPDB2没有打开。你可以打开或者删除他,我选择了后者。
$ ords --config /etc/ords/config install
ORDS: Release 24.1 Production on Wed May 29 07:56:06 2024
Copyright (c) 2010, 2024, 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/19c/dbhome_1/network/admin/tnsnames.ora or specify the database connection
[1] ORCL SERVICE_NAME=orcl
[2] ORCLPDB1 SERVICE_NAME=orclpdb1
[3] VAGRANT SERVICE_NAME=orclpdb1
[S] Specify the database connection
Choose [1]: 1
Provide database user name with administrator privileges.
Enter the administrator username: sys
Enter the database password for SYS AS SYSDBA:
Error cannot install/upgrade ORDS into the CDB because the container requires to be in READ WRITE mode.
PDB ORCLPDB2 - MOUNTED
这是安装成功的那次:
$ ords --config /etc/ords/config install
ORDS: Release 24.1 Production on Wed May 29 07:58:02 2024
Copyright (c) 2010, 2024, 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/19c/dbhome_1/network/admin/tnsnames.ora or specify the database connection
[1] ORCL SERVICE_NAME=orcl
[2] ORCLPDB1 SERVICE_NAME=orclpdb1
[3] VAGRANT SERVICE_NAME=orclpdb1
[S] Specify the database connection
Choose [1]: 1
Provide database user name with administrator privileges.
Enter the administrator username: sys
Enter the database password for SYS AS SYSDBA:
Retrieving information...
Your database connection is to a CDB. ORDS common user ORDS_PUBLIC_USER will be created in the CDB. ORDS schema will be installed in the PDBs.
Root CDB$ROOT - create ORDS common user
PDB PDB$SEED - install ORDS 24.1.1.r1201228 (mode is READ ONLY, open for READ/WRITE)
PDB ORCLPDB1 - install ORDS 24.1.1.r1201228
Install ORDS in the database
[1] Yes
[2] No
Choose [1]: 1
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=ORCL TNS_FOLDER=/u01/app/oracle/product/19c/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]: A
The setting named: db.connectionType was set to: tns in configuration: default
The setting named: db.tnsAliasName was set to: ORCL in configuration: default
The setting named: db.tnsDirectory was set to: /u01/app/oracle/product/19c/dbhome_1/network/admin in configuration: default
The setting named: db.serviceNameSuffix was set to: 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.static.context.path was set to: /ords
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
2024-05-29T07:58:37.755Z INFO Created folder /home/oracle/logs
2024-05-29T07:58:37.756Z INFO The log file is defaulted to the current working directory located at /home/oracle/logs
2024-05-29T07:58:37.834Z INFO Installing Oracle REST Data Services version 24.1.1.r1201228 in CDB$ROOT
2024-05-29T07:58:39.837Z INFO ... Verified database prerequisites
2024-05-29T07:58:40.387Z INFO ... Created Oracle REST Data Services proxy user
2024-05-29T07:58:40.508Z INFO Completed installation for Oracle REST Data Services version 24.1.1.r1201228. Elapsed time: 00:00:02.642
2024-05-29T07:58:40.831Z INFO Installing Oracle REST Data Services version 24.1.1.r1201228 in PDB$SEED
2024-05-29T07:58:41.093Z INFO ... Verified database prerequisites
2024-05-29T07:58:41.864Z INFO ... Created Oracle REST Data Services proxy user
2024-05-29T07:58:42.713Z INFO ... Created Oracle REST Data Services schema
2024-05-29T07:58:43.691Z INFO ... Granted privileges to Oracle REST Data Services
2024-05-29T07:58:46.575Z INFO ... Created Oracle REST Data Services database objects
2024-05-29T07:58:58.928Z INFO Completed installation for Oracle REST Data Services version 24.1.1.r1201228. Elapsed time: 00:00:18.94
2024-05-29T07:58:59.322Z INFO Installing Oracle REST Data Services version 24.1.1.r1201228 in ORCLPDB1
2024-05-29T07:58:59.452Z INFO ... Verified database prerequisites
2024-05-29T07:58:59.894Z INFO ... Created Oracle REST Data Services proxy user
2024-05-29T07:59:00.306Z INFO ... Created Oracle REST Data Services schema
2024-05-29T07:59:01.064Z INFO ... Granted privileges to Oracle REST Data Services
2024-05-29T07:59:03.723Z INFO ... Created Oracle REST Data Services database objects
2024-05-29T07:59:13.574Z INFO Completed installation for Oracle REST Data Services version 24.1.1.r1201228. Elapsed time: 00:00:14.250
2024-05-29T07:59:13.575Z INFO Completed CDB installation for Oracle REST Data Services version 24.1.1.r1201228. Total elapsed time: 00:00:35.748
2024-05-29T07:59:13.577Z INFO Log file written to /home/oracle/logs/ords_cdb_install_2024-05-29_075837_75683.log
2024-05-29T07:59:13.716Z INFO HTTP and HTTP/2 cleartext listening on host: 0.0.0.0 port: 8080
2024-05-29T07:59:13.739Z INFO Disabling document root because the specified folder does not exist: /etc/ords/config/global/doc_root
2024-05-29T07:59:13.740Z INFO Default forwarding from / to contextRoot configured.
2024-05-29T07:59:17.828Z INFO Configuration properties for: |default|lo|
db.password=******
db.serviceNameSuffix=
db.tnsAliasName=ORCL
conf.use.wallet=true
security.requestValidationFunction=ords_util.authorize_plsql_gateway
standalone.static.context.path=/ords
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/19c/dbhome_1/network/admin
2024-05-29T07:59:17.831Z WARNING *** jdbc.MaxLimit in configuration |default|lo| is using a value of 10, this setting may not be sized adequately for a production environment ***
2024-05-29T07:59:17.831Z WARNING *** jdbc.InitialLimit in configuration |default|lo| is using a value of 10, this setting may not be sized adequately for a production environment ***
2024-05-29T07:59:25.437Z INFO
Mapped local pools from /etc/ords/config/databases:
/ords/ => default => VALID
2024-05-29T07:59:25.535Z INFO Oracle REST Data Services initialized
Oracle REST Data Services version : 24.1.1.r1201228
Oracle REST Data Services server info: jetty/10.0.20
Oracle REST Data Services java info: Java HotSpot(TM) 64-Bit Server VM 11.0.23+7-LTS-222
此安装可以选择协议(本例为HTTP),端口(默认8080),还有安装在CDB还是PDB(本例为前者)。
然后我们看到服务有了,端口也起了:
$ netstat -an|grep 8080
tcp6 0 0 :::8080 :::* LISTEN
$ systemctl status ords
● ords.service - Oracle REST Data Services
Loaded: loaded (/etc/systemd/system/ords.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2024-05-30 00:47:59 GMT; 49min ago
Process: 53329 ExecStart=/usr/bin/bash -c /etc/init.d/ords start (code=exited, status=0/SUCCESS)
Main PID: 53458 (java)
Tasks: 0 (limit: 202282)
Memory: 452.0K
CGroup: /system.slice/ords.service
‣ 53458 java -Doracle.dbtools.cmdline.home=/opt/oracle/ords -Duser.language=en -Duser.region=US -Dfile.encoding=UTF-8 -Djav>
然后浏览器访问http://A.B.C.D:8080
:
完美。
看下上面那段话:
Oracle REST Data Services (ORDS) 是用于 Oracle 数据库的 HTTPS Web 网关。功能包括 SQL Developer Web、Oracle APEX 访问、用于数据和数据库的 REST API 以及 Oracle Database API for MongoDB 等。
SQL Developer Web就是SQL Developer的网页版。其实他最新的名称是Oracle Database Actions。后续我们再探索。