This is an update to my older post Clone a pluggable Database with APEX and connect to ORDS, which is still valid for older ORDS-versions before 22.x.
---8<-----------------------------------------------------------------------------
Sometimes I quickly need another test/dev environment for Apex. There are several ways to get one: snapshot or clone the VM, create one with Liquibase or clone the PDB and link the ORDS to it as described below. This is meant as a short cookbook, find more detailed information on the sites from Jeff Smith or Oracle-Base.
Start by connecting to your CDB and create a clone of the PDB where Apex is installed.
create pluggable database apexpdb2 from apexpdb1 file_name_convert = ('/apexpdb1/', '/apexpdb2/'); alter pluggable database apexpdb2 open; sho pdbs alter session set container=apexpdb2; select * from apex_release;
Double check, that the new PDB has a valid APEX version installed. Add the newly created database in your $TNSADMIN/tnsnames.ora like
APEXPDB2 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = apexpdb2) ) )
So much for for the database. Now all we have to do is to tell ORDS about the 2nd PDB. There is a chapter in the documentation for this, so the setup is straight forward. For dealing with ORDS, some settings should be made in .bashrc
And there is also a second Database Actions / SQLDeveloper Web under that new URL pattern.
export ORDS_CONFIG=/u01/ords/config export ORDS_HOME=/u01/ords-22-2 export PATH=$ORDS_HOME/bin:$PATH
Stop ORDS if it is already running We need to add the DB with the following if we want to use the interactive mode
ords install -i
At the end, ORDS should be running in standalone mode. If you don't like interactive installations, you can do the same with one (loooong) command. First we need a text file with the passwords for the admin and proxy user:
[oracle@orcldevvm-ol8 ~]$ cat password.txt
oracle
oracle
Then run something like
ords install --db-pool apexpdb2 --db-hostname localhost --db-port 1521 --db-servicename apexpdb2 --feature-sdw true --feature-db-api true --feature-rest-enabled-sql true --admin-user sys --proxy-user --password-stdin < password.txt
Open the new URL with your browser, in my case:
vm:8080/ords/apexpdb2/apex
The difference between the first and all other databases for an ORDS is, that the first one is always accessible without an additional base-path (like vm:8080/ords/apex) whereas the others always need that base-path. If you want a base-path also for the first database, see this posting from Jeff Smith.
Apex for the second PDB should be available under that new URL.And there is also a second Database Actions / SQLDeveloper Web under that new URL pattern.
This is done in less than 5 minutes and depending on your environment, this might be faster than cloning the complete VM. And dropping it only takes seconds, what also might be faster than restoring a snapshot of your VM.