Wednesday, 20 September 2023

Configuring Multiple Databases in Single ORDS


Setup
Server A    oradbstg
             Aplication Name : appa
    http://oradbstg:8080/ords/servera/r/appa

Server B oradbdev                 Aplication Name : appb
    http://oradbdev:8088/ords/serverb/r/appb/

      Target is to run Application on Server B with ords on Server A

           REGISTER DATABASE of [ serverB : oradbdev ] with the ORDS on Server A

On Server - A

java -jar ords.war setup --database proddr		

Specify the database connection type to use.
Enter number for [1] Basic  [2] TNS  [3] Custom URL [1]:1
Enter the name of the database server [localhost]:oradbdev
Enter the database listen port [1521]:
Enter 1 to specify the database service name, or 2 to specify the database SID [1]:2
Enter the database SID [xe]:proddr
Enter 1 if you want to verify/install Oracle REST Data Services schema or 2 to skip this step [1]:
Enter the database password for ORDS_PUBLIC_USER:
Confirm password:
Passwords do not match, try again
Enter the database password for ORDS_PUBLIC_USER:
Confirm password:

Retrieving information.
Enter 1 if you want to use PL/SQL Gateway or 2 to skip this step.
If using Oracle Application Express or migrating from mod_plsql then you must enter 1 [1]:
Enter the PL/SQL Gateway database user name [APEX_PUBLIC_USER]:
Enter the database password for APEX_PUBLIC_USER:
Confirm password:
Passwords do not match, try again
Enter the database password for APEX_PUBLIC_USER:
Confirm password:
Enter 1 to specify passwords for Application Express RESTful Services database users (APEX_LISTENER, APEX_REST_PUBLIC_USER) or 2 to skip this step [1]:
Enter the database password for APEX_LISTENER:
Confirm password:
Enter the database password for APEX_REST_PUBLIC_USER:
Confirm password:
Enter a number to select a feature to enable:
   [1] SQL Developer Web  (Enables all features)
   [2] REST Enabled SQL
   [3] Database API
   [4] REST Enabled SQL and Database API
   [5] None
Choose [1]:1
reloaded pools: [|apex||, |apex|al|, |apex|pu|, |apex|rt|,
                 |proddr||, |proddr|pu|, |proddr|al|, |proddr|rt|]
Oracle REST Data Services schema version 21.1.3.r1531102 is installed.

Creates additional connection pools under ords/config directory.




URL Mapping for application running on Server B

On Server A : 
java -jar ords.war map-url --type base-path <path-prefix> <database name>

java -jar ords.war map-url --type base-path /serverb proddr
2023-09-21T10:25:37.019Z INFO        
Creating new mapping from: 
    [base-path,/serverb] to map to: [proddr, null, null]


After this on Server A - copy the ords.war folder from ORDS directory and replace with existing version under tomcat\webapps folder.

Access appB using below URL
http://oradbstg:8080/ords/serverb
http://oradbstg:8080/ords/serverb/serverb/r/appb
    *** serverb is the base-path-prefix we specified in above command

    Now we can access application from Server B, Server A using single ORDS
http://oradbstg:8080/ords/servera/r/appa/login?
http://oradbstg:8080/ords/serverb/serverb/r/appb/login?

Try stopping Tomcat services on Server B - application should still be accessible

No comments:

Post a Comment