2 Configuring Oracle REST Data Services (Advanced)
This section explains how to configure Oracle REST Data Services for connecting to multiple databases for routing requests, and it refers to other documentation sources for other configuration information.
Note:
Oracle REST Data Services must be restarted after making configuration changes. See your application server documentation for information on how to restart applications.
Topics:
2.1 Configuring Multiple Databases
Oracle REST Data Services supports the ability to connect to more than one database. This section describes different strategies for routing requests to the appropriate database.
Topics:
2.1.1 About the Request URL
Oracle REST Data Services supports a number of different strategies for routing requests to the appropriate database. All of these strategies rely on examining the request URL and choosing the database based on some kind of match against the URL. It is useful to recap the pertinent portions of a request URL. Consider the following URL:
https://www.example.com/ords/sales/f?p=1:1
This URL consists of the following sections:
-
Protocol:
https
-
Host Name:
www.example.com
-
Context Root:
/ords
The context root is the location at which Oracle REST Data Services is deployed on the application server.
-
Request Path:
/sales/f?p=1.1
This is the portion of the request URL relative to the context root.
For different applications, it may be important to route requests based on certain prefixes in the request path or certain prefixes in the full request URL.
There are two steps to configuring multiple databases:
-
Configuring the database connection information
-
Configuring which requests are routed to which database
2.1.2 Configuring Additional Databases
When you first configure Oracle REST Data Services, you configure a default database connection named: apex
. You can create additional database connections using the setup
command.
Tip:
To see full help for the setup
command type:
java -jar ords.war help setup
To create a database connection type the following:
java -jar ords.war setup --database <database name>
Where:
-
<database name>
is the name you want to give the database connection.
You are prompted to enter the information required to configure the database. After you have configured the additional databases, define the rules for how requests are routed to the appropriate database.
2.1.3 Routing Based on the Request Path Prefix
You create request routing rules using the map-url
command.
Tip:
To see full help for the map-url
command type:
java -jar ords.war help map-url
If you want to route requests based just on matching a prefix in the request path portion of the URL, use the map-url
command as follows:
java -jar ords.war map-url --type base-path --workspace-id <workspace name> <path prefix> <database name>
Where:
-
<workspace name>
is the name of the Oracle Application Express workspace where RESTful services for this connection are defined. This may be omitted if RESTful Services are not being used. -
<path prefix>
is the prefix that must occur at the start of the request path. -
<database name>
is the name of the database connection configured in the previous step.
Related Topics
2.1.3.1 Example of Routing Based on the Request Path Prefix
Assuming Oracle REST Data Services is deployed on a system named example.com
at the context path /ords
, then create the following rule:
java -jar ords.war map-url --type base-path --workspace-id sales_rest /sales sales_db
This rule means that any requests matching https://example.com/ords/sales/...
are routed to the sales_db
database connection. The sales_rest
workspace defined within the sales_db
database is searched for RESTful Services definitions.
The previous rule matches all of the following requests:
https://example.com/ords/sales/f?p=1:1
https://example.com/ords/sales/leads/
https://www.example.com/ords/sales/forecasting.report?month=jan (If www.example.com resolves to the same system as example.com.)
The previous rule does not match of any of the following requests:
http://example.com/ords/sales/f?p=1:1 (The protocol is wrong.) https://example.com:8080/ords/sales/f?p=1:1 (The port is wrong: 443 is default for https, but don't specify if using default.) https://example.com/ords/f?p=1:1 (Missing the /sales prefix.) https://example.com/pls/sales/leads/ (The context path is wrong.)
2.1.4 Routing Based on the Request URL Prefix
If you want to route requests based on a match of the request URL prefix, use the map-url
command as follows:
java -jar ords.war map-url --type base-url --workspace-id <workspace name> <url prefix> <database name>
Where:
-
<workspace name>
is the name of the Oracle Application Express workspace where RESTful services for this connection are defined. This may be omitted if RESTful Services are not being used. -
<url prefix>
is the prefix with which the request URL must start. -
<database name>
is the name of the database connection.
2.1.4.1 Example of Routing Based on the Request URL Prefix
Assuming Oracle REST Data Services is deployed on a system named example.com
at the context path /ords
, then create the following rule:
java -jar ords.war map-url --type base-url --workspace-id sales_rest https://example.com/ords/sales sales_db
This rule means that any requests matching https://example.com/ords/sales/...
are routed to the sales_db
database connection. The sales_rest
workspace defined within the sales_db
database is searched for RESTful Services definitions.
The previous rule matches all of the following requests:
https://example.com/ords/sales/f?p=1:1 https://example.com/ords/sales/leads/ https://example.com/ords/sales/forecasting.report?month=jan
The previous rule does not match of any of the following requests:
http://example.com/ords/sales/f?p=1:1 (The protocol is wrong.) https://example.com:8080/ords/sales/f?p=1:1 (The port is wrong: 443 is default for https, but don't specify if using default.) https://example.com/ords/f?p=1:1 (Missing the /sales segment of the base URL.) https://example.com/pls/sales/leads/ (The context path is wrong.) https://www.example.com/ords/sales/forecasting.report?month=jan (The host name is wrong.)
2.2 Using the Multitenant Architecture with Oracle REST Data Services
This section outlines installing, configuring, upgrading and uninstalling Oracle REST Data Services in a multitenant container database.
2.2.1 Installing Oracle REST Data Services in a CDB Environment
This section describes installing Oracle REST Data Services into a multitenant container database (CDB) environment.
Oracle Database 12c Release 1 (12.1) introduced the multitenant architecture. This database architecture has a multitenant container database (CDB) that includes a root container, CDB$ROOT
, a seed database, PDB$SEED
, and multiple pluggable databases (PDBs). A PDB appears to users and applications as if it were a non-CDB. Each PDB is equivalent to a separate database instance in Oracle Database Release 11g.
The root container, CDB$ROOT
, holds common objects that are accessible to every PDB utilizing metadata links or object links. The seed database, PDB$SEED
, is used when you create a new PDB to seed the new pluggable database. The key benefit of the Oracle Database 12c multitenant architecture is that the database resources, such as CPU and memory, can be shared across all of the PDBs. This architecture also enables many databases to be treated as one for tasks such as upgrades or patches, and backups.
Note:
If you want to install directly into a PDB (not connected to Root during installation), see Advanced Installation Using Command-Line Prompts for more information.Preinstallation Tasks for Oracle REST Data Services CDB Installation
-
Ensure that the PDBs are open (not mounted/closed) in read/write mode (except for
PDB$SEED
, which remains in read-only mode). For more information, see Oracle Multitenant Administrator’s Guide -
Ensure that the default and temporary tablespaces to be used by the
ORDS_METADATA
schema and theORDS_PUBLIC_USER
user exist and that you know the tablespace names. The installation procedure creates those users, but it does not create the tablespaces.
Note:
ORDS_METADATA
and ORDS_PUBLIC_USER
are installed in the seed container, and the default and temporary tablespaces exist in PDB$SEED
. If these tablespaces do not already exist, then you must create the tablespaces in PDB$SEED
. For more information, see Oracle Multitenant Administrator’s Guide2.2.1.1 Installation Enabling Multiple Releases
This section describes the installation process when you have multiple releases of Oracle REST Data Services and patch sets in the PDBs in a multitenant environment.
When Oracle REST Data Services is installed into a CDB, the proxy user, Oracle REST Data Services public user (ORDS_PUBLIC_USER
) is installed in the root container and is a common user. The ORDS_METADATA
schema is a local user that contains the metadata for Oracle REST Data Services. Both the ORDS_METADATA
schema and the ORDS_PUBLIC_USER
are installed in the seed container (PDB$SEED
) and all of the pluggable databases.
Since the ORDS_METADATA
is installed as a local user, this provides you the flexibility of installing multiple Oracle REST Data Services releases in the pluggable databases.
2.2.1.1.1 Command Line Installation
You must provide the SYS AS SYSDBA
credentials in the Root (CDB$ROOT
) container to perform the installation.
2.2.1.1.2 Advanced Installation
This section describes the advanced installation prompts for installing Oracle REST Data Services into a CDB to enable multiple Oracle REST Data Services releases.
-
Navigate to the folder where you unzipped the Oracle REST Data Services installation kit.
-
Enter the following command:
java -jar ords.war install advanced
-
When prompted, enter the database connection information for your CDB.
Enter the name of the database server[localhost]: Enter the database listen port [1521]: Enter 1 to specify the database service name, or 2 to specify the database SID [1]: Enter the database service name:(for example, cdb.example.com)
-
Verify the Oracle REST Data Services installation.
Enter 1 if you want to verify/install Oracle REST Data Services schema or 2 to skip this step [1]:
-
Accept or enter 1 (the default) to install Oracle REST Data Services into the CDB and all of its PDBs.
Enter the database password for ORDS_PUBLIC_USER: Confirm password: Requires to login with administrator privileges to verify Oracle REST Data Services schema. Enter the administrator username: SYS Enter the database password for SYS AS SYSDBA: Confirm password:
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 18.2.0.<JulianDay.Time> (mode is READ ONLY, open for READ/WRITE) PDB PDBName1 - install ORDS 18.2.0.<JulianDay.Time> PDB PDBName2 - install ORDS 18.2.0.<JulianDay.Time>
Enter 1 if you want to install ORDS or 2 to skip this step [1]:
-
Press enter to continue with the installation.
-
When prompted, enter additional information as needed. See Advanced Installation Using Command-Line Prompts for more information.
Note:
To use the pluggable mapping feature, see Making All PDBs Addressable by Oracle REST Data Services (Pluggable Mapping) for more information.2.2.2 Upgrading Oracle REST Data Services in a CDB Environment
When you use a new release of Oracle REST Data Services, upgrading its schema in the CDB and its pluggable databases (PDBs) will occur automatically when you perform a simple or advanced installation.
For example:
java -jar ords.war
If Oracle REST Data Services is already installed or upgraded, a message displays the Oracle REST Data Services schema version, and you will not be prompted for information.
2.2.2.1 Migrating Oracle REST Data Services in the CDB to Enable Multiple Releases
This section describes how to migrate Oracle REST Data Services in the CDB to enable multiple releases.
Starting with release 18.2.0 and later, if you have an Oracle REST Data Services schema and ORDS_METADATA
that is installed in the CDB$ROOT
container, then during upgrade it will migrate the common ORDS_METADATA
schema to your PDBs as a local schema. Oracle database 12.1.0.2 and later releases support this change.
2.2.3 Making All PDBs Addressable by Oracle REST Data Services (Pluggable Mapping)
Pluggable mapping refers to the ability to make all PDBs in a CDB addressable by Oracle REST Data Services. To use this feature, follow the instructions in this topic.
If the Oracle REST Data Services configuration file includes the db.serviceNameSuffix
parameter, this indicates that the Oracle REST Data Services pool points to a CDB, and that the PDBs connected to that CDB should be made addressable by Oracle REST Data Services.
The value of the db.serviceNameSuffix
parameter must match the value of the DB_DOMAIN
database initialization parameter, and it must start with a period (.). To set the value of the db.serviceNameSuffix
parameter:
-
In SQL*Plus, connect to the root as a user with SYSDBA privileges.
-
Check the value of the
DB_DOMAIN
database initialization parameter.SQL> show parameter DB_DOMAIN
-
Exit SQL*Plus.
SQL> exit
-
If the
DB_DOMAIN
value was not empty, then on the command line enter the command to create the key and value for the db.serviceNameSuffix
parameter and itsDB_DOMAIN
. This will be used to add this entry to the Oracle REST Data Services configuration file.echo db.serviceNameSuffix=.value-of-DB_DOMAIN > snsuffix.properties
For example, if
DB_DOMAIN
is set toexample.com
, enter the following:echo db.serviceNameSuffix=.example.com > snsuffix.properties
-
If the
db.serviceNameSuffix
parameter value is not defined, enter a command in the following format to add an entry to the configuration file:java -jar ords.war set-properties --conf pool-name snsuffix.properties
Where pool-name is one of the following:
-
poolName
for a PL/SQL Gateway configuration -
poolName_pu
for an Oracle REST Data Services RESTful Services configuration -
poolName_rt
for an Application Express RESTful Services configuration
Example 1: You want to make PDBs in a CDB addressable globally. Specify
defaults
by entering the following command:java -jar ords.war set-properties --conf defaults snsuffix.properties
Note:
The approach shown in Example 1 (setting the property for all pools through the
defaults.xml
file) is best for most use cases.Example 2: You want to make PDBs in a CDB addressable for your PL/SQL Gateway, and your pool name is
apex
. Enter the following command:java -jar ords.war set-properties --conf apex snsuffix.properties
For example, if the database pointed to by apex has a
DB_DOMAIN
value ofexample.com
and contains the two PDBspdb1.example.com
andpdb2.example.com
, the first PDB will be mapped to URLs whose path starts with/ords/pdb1/
, and the second PDB will be mapped to URLs whose path starts with/ords/pdb2/
.Example 3: You want to make PDBs in a CDB addressable for your Oracle REST Data Services RESTful Services, and your pool name is
apex_pu
. Enter the following command:java -jar ords.war set-properties --conf apex_pu snsuffix.properties
Example 4: You want to make PDBs in a CDB addressable for your Application Express RESTful Services and your pool name is
apex_rt
. Enter the following command:java -jar ords.war set-properties --conf apex_rt snsuffix.properties
-
Related Topics
2.3 Support for Oracle RAC Fast Connection Failover
Oracle REST Data Services support the Fast Connection Failover (FCF) feature of Oracle Real Application Clusters (Oracle RAC).
Oracle REST Data Services runs with the Universal Connection Pool (UCP) in all the
Application Server environments that it supports, such as WebLogic, Tomcat. UCP in turn
supports Fast Connection Failover . To enable FCF, Oracle Notification Service (ONS)
must to be enabled. To enable ONS, add entries to the list of properties in the Oracle
REST Data Services defaults.xml
configuration file as shown in the
following code snippet:
<entry key="jdbc.enableONS">true</entry>
<entry key= "jdbc.ONSConfig">nodes=racnode1:4200,racnode2:4200\nwalletfile=/oracle11/onswalletfile</entry>
<entry key="db.connectionType">customurl</entry>
<entry key="db.customURL">jdbc:oracle:thin:@(DESCRIPTION=(FAILOVER=ON)(ADDRESS_LIST=
(LOAD_BALANCE=ON)(ADDRESS=(PROTOCOL=TCP)(HOST=prod_scan.example.com)(PORT=1521)))
(CONNECT_DATA=(SERVICE_NAME=ISPRD)))|</entry>
After updating the defaults.xml
configuration file, Oracle REST Data Services need to be restarted for the changes to take effect.
-
Unplanned outages: When RAC detects an instance failure, it generates a FAN Down event which FCF picks up. FCF then terminates all connections to the failed instance and directs all future requests to the surviving RAC instances.
-
Planned outages: For instance, when a Database Administrator (DBA) wants to gracefully shut down a RAC instance for performing some maintenance activity. The instance shutdown generates a FAN Planned Down event which FCF picks up. FCF then directs all new requests to other RAC instances and drains or allows currently active transactions to complete.
Note:
Long running transactions may need to be terminated forcefully.2.4 Configuring Security, Caching, Pre- and Post Processing, Environment, and Excel Settings
To configure security, caching, pre- and post- processing, environment, and Excel settings, see Using SQL Developer Oracle REST Data Services Administration (Optional).
2.5 Configuring REST-Enabled SQL Service Settings
This section explains how to configure the REST- Enabled SQL service.
Note:
Enabling the REST- Enabled SQL service enables authentication against the Oracle REST Data Service enabled database schemas. This makes the database schemas accessible over HTTPS, using the database password. Oracle highly recommends that you provide strong secure database passwords-
Locate the folder where the Oracle REST Data Services configuration file is stored.
-
Open the
defaults.xml
file and add:<entry key="restEnabledSql.active">true</entry>
. -
Save the file.
-
Restart Oracle REST Data Services.
2.6 Configuring the Maximum Number of Rows Returned from a Query
-
Locate the folder where the Oracle REST Data Services configuration file is stored.
-
Open the
defaults.xml
file and update the value of themisc.pagination.maxRows
parameter:<entry key=”misc.pagination.maxRows”>1500</entry>
Note:
The default value formisc.pagination.maxRows
is 500. -
Save the file.
-
Restart Oracle REST Data Services.
2.7 Configuring the Custom Error Pages
This section explains how to configure a custom error page instead of the error page generated by Oracle REST Data Services.
To configure a custom error page, perform the following steps:
-
Locate the folder where the Oracle REST Data Services configuration file is stored.
-
Open the
defaults.xml
file and update the value of theerror.externalPath
parameter:<entry key=”error.externalPath">/path/to/error/pages/folder/</entry>
Where:
-
/path/to/error/pages/folder
is the path to a folder containing files that define the error pages. The files are stored in{status}.html
format.Where,
{status}
is the HTTP status code for which you want to create a custom error page.
-
-
Save the file.
-
Restart Oracle REST Data Services.
Example 2-1 Configuring custom error page for “HTTP 404” status code
To configure a custom error page for the “HTTP 404 – Not Found” status, perform the following steps:
-
Create a file named
404.html
. -
Save it under
/usr/local/share/ords/error-pages/
folder. -
Configure the
error.externalPath
parameter to point to/usr/local/share/ords/errro-pages/
folder. -
Save the file.
-
Restart Oracle REST Data Services.
2.8 Developing RESTful Services for Use with Oracle REST Data Services
For more information on how to develop RESTful Services for use with Oracle REST Data Services, see Developing Oracle REST Data Services Applications.