8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | 21c | 23c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Articles » 12c » Here

Multitenant : Remove APEX Installations from the CDB in Oracle Database 12c Release 1 (12.1)

Oracle's recommendation is to share the core of APEX between pluggable databases, by installing it in the CDB. This is done by default in 12cR1 multitenant installations. Despite the initial enthusiasm, this approach is impractical and in my opinion APEX should be removed from CDB from the outset. This decision is very important because the current documentation states the following.

"Oracle does not support uninstalling Application Express from the root container, or reinstalling Application Express into the root container, once any PDBs have been configured. This may invalidate or completely remove the meta data associated with the existing Application Express installation."

This article describes the process of uninstalling APEX from the CDB, leaving you free to install different versions of APEX into each PDB if required in future.

If you are providing a large APEX real estate, you may find the shared APEX method useful, but I think for most users it will probably cause more problems than it fixes.

Related articles.

12cR2 Update

From Oracle Database 12c Release 2 (12.2) onward APEX is not installed by default, so you no longer need to worry about uninstalling APEX before creating PDBs. The software is still shipped with the database ($ORACLE_HOME/apex), but not installed. In Oracle 12.2 you should always do the following.

Uninstall APEX from the Container Database (CDB)

Remember, you should only perform this on a CDB with no PDBs, so either drop existing PDBs, or unplug the PDBs and move them to another container before starting.

Navigate to the "$ORACLE_HOME/apex" directory and connect to the root container.

$ export ORACLE_SID=cdb1
$ cd $ORACLE_HOME/apex
$ sqlplus / as sysdba

If you are using the default APEX shipped with the database run the "apxremov_con.sql" script to remove APEX from the CDB. If you are using a later version of APEX you should use the "apxremov.sql" script.

SQL> --@apxremov.sql  --Later release of APEX.

SQL> @apxremov_con.sql

PL/SQL procedure successfully completed.

Performing installation in multitenant container database in the background.
The installation progress is spooled into apxremov*_con*.log files.

Please wait...

catcon: ALL catcon-related output will be written to apxremov1_con_catcon_22354.lst
catcon: See apxremov1_con*.log files for output generated by scripts
catcon: See apxremov1_con_*.lst files for spool files, if any
catcon.pl: completed successfully

catcon: ALL catcon-related output will be written to apxremov2_con_catcon_22436.lst
catcon: See apxremov2_con*.log files for output generated by scripts
catcon: See apxremov2_con_*.lst files for spool files, if any
catcon.pl: completed successfully


Installation completed. Log files for each container can be found in:

apxremov*_con*.log

You can quickly scan for ORA errors or compilation errors by using a utility
like grep:

grep ORA- *.log
grep PLS- *.log

SQL>

Install APEX into a Pluggable Database (PDB)

With APEX removed from the CDB, we are free to perform full APEX installations in each PDB. The installation process is almost the same as for previous database versions, but you must remember to connect to the PDB to perform the installation. The example below is a summary based on a more detailed APEX installation article here. This example does not cover all APEX installation options!

Connect to the root container, create a new pluggable database and add a tablespace for the APEX components.

CONN / AS SYSDBA

CREATE PLUGGABLE DATABASE pdb1 ADMIN USER pdb_adm IDENTIFIED BY Password1;
ALTER PLUGGABLE DATABASE pdb1 OPEN;
ALTER PLUGGABLE DATABASE pdb1 SAVE STATE;

-- Switch to the new PDB.
ALTER SESSION SET CONTAINER=pdb1;

-- For Oracle Managed Files (OMF).
CREATE TABLESPACE apex DATAFILE SIZE 100M AUTOEXTEND ON NEXT 1M;

-- For non-OMF.
CREATE TABLESPACE apex DATAFILE '/path/to/datafiles/apex01.dbf' SIZE 100M AUTOEXTEND ON NEXT 1M;

Change directory to the directory holding the unzipped APEX software.

$ cd /home/oracle/apex

All actions from this point are performed within the PDB. I've added a new connection for each command as a reminder, but this is not necessary. All the following actions can be performed in the same session.

Connect to SQL*Plus as the SYS user and run the "apexins.sql" script, specifying the relevant tablespace names and image URL. Remember, you must connect to the specific PDB, not the CDB.

CONN / AS SYSDBA
ALTER SESSION SET CONTAINER=pdb1;

-- @apexins.sql tablespace_apex tablespace_files tablespace_temp images

@apexins.sql APEX APEX TEMP /i/

Once complete, change the admin password by running the "apxchpwd.sql" scripts as the SYS user.

CONN / AS SYSDBA
ALTER SESSION SET CONTAINER=pdb1;

@apxchpwd.sql

Create the APEX_LISTENER and APEX_REST_PUBLIC_USER users by running the "apex_rest_config.sql" script.

CONN / AS SYSDBA
ALTER SESSION SET CONTAINER=pdb1;

@apex_rest_config.sql

Make sure the APEX_PUBLIC_USER account is unlocked.

CONN / AS SYSDBA
ALTER SESSION SET CONTAINER=pdb1;

ALTER USER APEX_PUBLIC_USER IDENTIFIED BY Password1 ACCOUNT UNLOCK;

If you are planning to use the Embedded PL/SQL Gateway (EPG), you will have to set it up, as described here.

For more information see:

Hope this helps. Regards Tim...

Back to the Top.