Update: I have made a newer version of this post, including a Flatpak solution
Wednesday, 17 November 2021
Monday, 11 October 2021
Clone a pluggable Database with APEX and connect to ORDS
Update: this is still valid for ORDS-versions up to 21.x. With ORDS 22.x, this got a bit easier. I created a newer cookbook under Clone a pluggable Database with APEX and connect to ORDS 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 orclpdb2 from orclpdb file_name_convert = ('/orclpdb/', '/orclpdb2/'); alter pluggable database orclpdb2 open; sho pdbs alter session set container=orclpdb2; select * from apex_release;
java -jar ords.war setup --database orclpdb2
java -jar ords.war map-url --type base-path /orclpdb2 orclpdb2
vm:8080/ords/orclpdb2/apex
And there is also a second Database Actions / SQLDeveloper Web under that new URL pattern.
Thursday, 19 August 2021
Out-of-Place updating the Developer VM Oracle Database to 19.12
This is an update to my post on out-of-place patching to 19.11. The mechanism is identical, but I added a few steps, so better use this one.
In my last post "Enabling Blockchain Tables and SQL Table Macros with 19.10 Patch for the Developer VM Database", I described how to update the Database via OPatch. Now 19.11. and 19.12. do not have that much new features for developers, this post is only to show how to use out-of-place updating alternatively. Find more information on this on Mike Dietrich's Blog, I will only cover what I need to update the Developer VM.
Create a new directory for the new database home, in my case
mkdir /u01/app/oracle/product/19.12.0/dbhome_3
cd /u01/app/oracle/product/19.12.0/dbhome_3/
unzip ~/ddrive/Install/Linux-x64/LINUX.X64_193000_db_home.zip
As for the first installation, get the Oracle Database 19c 19.3.0 Base Release and unpack it to that directory.
Create a separate directory for the patch like
mkdir /u01/app/oracle/patches/32904851
Get patch #32545013 for the 19.11 RU and unpack it to that directory. That needs at least OPatch 12.2.0.1.24. Get the latest OPatch via Patch 6880880 (which is .27 at the time of writing).
mv OPatch OPatch.old unzip ~/ddrive/Install/Linux-x64/opatch-12-2-0-1-27-p6880880_210000_Linux-x86-64.zip
Rename the OPatch directory to something like OPatch.old, create a new OPatch directory and unzip Patch 6880880 to that.
As we are running OEL 8.x, we need to give the installer a little hint
export CV_ASSUME_DISTID=OEL7.8
Now we can go to the newly created ORACLE_HOME and run the installer. Better unset all variables pointing to the old home.
unset ORABASE_EXEC unset ORACLE_HOME unset ORAHOME
cd /u01/app/oracle/product/19.12.0/dbhome_3 ./runInstaller -applyRU /u01/app/oracle/patches/32545013/
This will apply the 19.12 RU during the install. If you need any specific one-off patches, these can be applied using the "-applyOneOffs" option, see Mike Dietrich's Blog. Click through the installer and choose only to install the software without creating a new database.
After the installer has finished, modify /etc/oratab to point to the new ORACLE_HOME
cd $ORACLE_HOME/OPatch ./datapatch -verbose
execute dbms_optim_bundle.enable_optim_fixes('ON','BOTH', 'YES');
@?/rdbms/admin/dbmsoptim.sql @?/rdbms/admin/prvtoptim.plb
Friday, 30 July 2021
How to upgrade Apex 20.2 to 21.2 and get Database Actions on-premise.
This howto is based on my Oracle Developer VM project. To get from the previous Apex version 20.2 to 21.2 is a two step procedure. Install 21.1 over 20.2 and then add Patch Set Bundle 32598392 on top.
Double check the previous version. If you have followed my Oracle Developer VM series, it should be 20.2. Then- Download Apex 21.1 and the PSU from apex.oracle.com
- Unpack apex_21.1.zip to a new directory
- Change to the new apex directory
@apexins.sql SYSAUX SYSAUX TEMP /i/
After about 15 minutes that should be done.
[oracle@orcldevvm-ol8 apex]$ cd /u01/apex
[oracle@orcldevvm-ol8 apex]$ mv images images.20.2 [oracle@orcldevvm-ol8 apex]$ cp -R /u01/patches/apex/images/ .
alter session set "_oracle_script"=true; drop user APEX_200200 cascade;
cd /u01/patches/ unzip ~/ddrive/Install/Generic/apex-21.2-p32598392_2110_Generic.zip cd 32598392/
cp -Rf images/ /u01/apex/
java -jar ords.war install advanced
Monday, 26 July 2021
Out-of-Place updating the Developer VM Oracle Database to 19.11
I have made a newer version of this post covering 19.12. Though this post is still valid, I made some additional hints to the new one, so better go directly to Out-of-Place updating the Developer VM Oracle Database to 19.12.
---8<-----------------------------------------------------------------------------
In my last post "Enabling Blockchain Tables and SQL Table Macros with 19.10 Patch for the Developer VM Database", I described how to update the Database via OPatch. Now 19.11. does not have that much new features for developers, this post is only to show how to use out-of-place updating alternatively. Find more information on this on Mike Dietrich's Blog, I will only cover what I need to update the Developer VM.
Create a new directory for the new database home, in my case
mkdir /u01/app/oracle/product/19.11.0/dbhome_2
As for the first installation, get the Oracle Database 19c 19.3.0 Base Release and unpack it to that directory. Create a separate directory for the patch like
mkdir /u01/app/oracle/patches/32545013
Get patch #32545013 for the 19.11 RU and unpack it to that directory. That needs at least OPatch 12.2.0.1.24. Get the latest via Patch 6880880 (which is .25 at the time of writing). Rename the OPatch directory to something like OPatch.old, create a new OPatch directory and unzip Patch 6880880 to that.
As we are running OEL 8.x, we need to give the installer a little hint
export CV_ASSUME_DISTID=OEL7.8
Now we can go to the newly created ORACLE_HOME and run the installer. Better unset all variables pointing to the old home.
unset ORABASE_EXEC unset ORACLE_HOME unset ORAHOME
cd /u01/app/oracle/product/19.11.0/dbhome_2 ./runInstaller -applyRU /u01/app/oracle/patches/32545013/
This will apply the 19.11 RU during the install. If you need any specific one-off patches, these can be applied using the "-applyOneOffs" option, see Mike Dietrich's Blog. Click through the installer and choose only to install the software without creating a new database.
After the installer has finished, modify /etc/oratab to point to the new ORACLE_HOME
Monday, 22 February 2021
Enabling Blockchain Tables and SQL Table Macros with Oracle 19.10 Patch
Setup
First go to support.oracle.com and get the Database Release Update 19.10.0.0.210119 Patch 32218454. From the prerequisites in the README.html, we need Opatch version 12.2.0.1.23 for patching to 19.10. Checking the installed version:
[oracle@orcldevvm-ol8 ~]$ $ORACLE_HOME/OPatch/opatch version
OPatch Version: 12.2.0.1.17
Our 19.3 standard installation only comes with 12.2.0.1.17. So we also need to download opatch from 6880880. Delete or rename the old OPatch directory and replace it with the contents of this archive and check again:
[oracle@orcldevvm-ol8 ~]$ $ORACLE_HOME/OPatch/opatch version
OPatch Version: 12.2.0.1.24
This is just following the steps from the patch README.html. Next we need to check the prerequisites:
[oracle@orcldevvm-ol8 32218454]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -ph ./ Oracle Interim Patch Installer version 12.2.0.1.24 Copyright (c) 2021, Oracle Corporation. All rights reserved. PREREQ session Oracle Home : /u01/app/oracle/product/19.0.0/dbhome_1 Central Inventory : /u01/app/oraInventory from : /u01/app/oracle/product/19.0.0/dbhome_1/oraInst.loc OPatch version : 12.2.0.1.24 OUI version : 12.2.0.7.0 Log file location : /u01/app/oracle/product/19.0.0/dbhome_1/cfgtoollogs/opatch/opatch2021-02-19_08-53-08AM_1.log Invoking prereq "checkconflictagainstohwithdetail" Prereq "checkConflictAgainstOHWithDetail" passed. OPatch succeeded.
[oracle@orcldevvm-ol8 32218454]$ $ORACLE_HOME/OPatch/opatch apply Oracle Interim Patch Installer version 12.2.0.1.24 Copyright (c) 2021, Oracle Corporation. All rights reserved. Oracle Home : /u01/app/oracle/product/19.0.0/dbhome_1 Central Inventory : /u01/app/oraInventory from : /u01/app/oracle/product/19.0.0/dbhome_1/oraInst.loc OPatch version : 12.2.0.1.24 OUI version : 12.2.0.7.0 Log file location : /u01/app/oracle/product/19.0.0/dbhome_1/cfgtoollogs/opatch/opatch2021-02-19_08-56-24AM_1.log Verifying environment and performing prerequisite checks... OPatch continues with these patches: 32218454 Do you want to proceed? [y|n] y User Responded with: Y All checks passed. Please shutdown Oracle instances running out of this ORACLE_HOME on the local system. (Oracle Home = '/u01/app/oracle/product/19.0.0/dbhome_1') Is the local system ready for patching? [y|n] y User Responded with: Y ... Patching component oracle.jdk, 1.8.0.201.0... Patch 32218454 successfully applied. Sub-set patch [29517242] has become inactive due to the application of a super-set patch [32218454]. Please refer to Doc ID 2161861.1 for any possible further required actions. Log file location: /u01/app/oracle/product/19.0.0/dbhome_1/cfgtoollogs/opatch/opatch2021-02-19_08-56-24AM_1.log OPatch succeeded.
[oracle@orcldevvm-ol8 32218454]$ sqlplus /nolog
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Feb 19 09:13:24 2021
Version 19.10.0.0.0
Copyright (c) 1982, 2020, Oracle. All rights reserved.
SQL> Connect / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 6610222304 bytes
Fixed Size 9149664 bytes
Variable Size 2550136832 bytes
Database Buffers 4043309056 bytes
Redo Buffers 7626752 bytes
Database mounted.
Database opened.
SQL> alter pluggable database all open;
Pluggable database altered.
SQL> quit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.10.0.0.0
[oracle@orcldevvm-ol8 OPatch]$ cd $ORACLE_HOME/OPatch [oracle@orcldevvm-ol8 OPatch]$ ./datapatch -verbose SQL Patching tool version 19.10.0.0.0 Production on Fri Feb 19 09:15:50 2021 Copyright (c) 2012, 2020, Oracle. All rights reserved. Log file for this invocation: /u01/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_14976_2021_02_19_09_15_50/sqlpatch_invocation.log Connecting to database...OK Gathering database info...done Note: Datapatch will only apply or rollback SQL fixes for PDBs that are in an open state, no patches will be applied to closed PDBs. Please refer to Note: Datapatch: Database 12c Post Patch SQL Automation (Doc ID 1585822.1) Bootstrapping registry and package to current versions...done Determining current state...done Current state of interim SQL patches: No interim patches found Current state of release update SQL patches: Binary registry: 19.10.0.0.0 Release_Update 210108185017: Installed PDB CDB$ROOT: Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 18-AUG-20 10.27.40.949667 AM PDB ORCLPDB: Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 18-AUG-20 10.35.55.137144 AM PDB PDB$SEED: Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 18-AUG-20 10.35.55.137144 AM Adding patches to installation queue and performing prereq checks...done Installation queue: For the following PDBs: CDB$ROOT ORCLPDB No interim patches need to be rolled back Patch 32218454 (Database Release Update : 19.10.0.0.210119 (32218454)): Apply from 19.3.0.0.0 Release_Update 190410122720 to 19.10.0.0.0 Release_Update 210108185017 No interim patches need to be applied For the following PDBs: PDB$SEED No interim patches need to be rolled back Patch 32218454 (Database Release Update : 19.10.0.0.210119 (32218454)): Apply from 19.3.0.0.0 Release_Update 190410122720 to 19.10.0.0.0 Release_Update 210108185017 No interim patches need to be applied Installing patches... Patch installation complete. Total patches installed: 3 Validating logfiles...done Patch 32218454 apply (pdb CDB$ROOT): SUCCESS logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/32218454/24018797/32218454_apply_ORCL_CDBROOT_2021Feb19_09_16_38.log (no errors) Patch 32218454 apply (pdb ORCLPDB): SUCCESS logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/32218454/24018797/32218454_apply_ORCL_ORCLPDB_2021Feb19_09_27_46.log (no errors) Patch 32218454 apply (pdb PDB$SEED): SUCCESS logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/32218454/24018797/32218454_apply_ORCL_PDBSEED_2021Feb19_09_35_55.log (no errors) Automatic recompilation incomplete; run utlrp.sql to revalidate. PDBs: ORCLPDB SQL Patching tool complete on Fri Feb 19 09:41:24 2021
[oracle@orcldevvm-ol8 32431413]$ $ORACLE_HOME/OPatch/opatch apply Oracle Interim Patch Installer version 12.2.0.1.24 Copyright (c) 2021, Oracle Corporation. All rights reserved. Oracle Home : /u01/app/oracle/product/19.0.0/dbhome_1 Central Inventory : /u01/app/oraInventory from : /u01/app/oracle/product/19.0.0/dbhome_1/oraInst.loc OPatch version : 12.2.0.1.24 OUI version : 12.2.0.7.0 Log file location : /u01/app/oracle/product/19.0.0/dbhome_1/cfgtoollogs/opatch/opatch2021-02-19_10-17-59AM_1.log Verifying environment and performing prerequisite checks... OPatch continues with these patches: 32431413 Do you want to proceed? [y|n] y User Responded with: Y All checks passed. Please shutdown Oracle instances running out of this ORACLE_HOME on the local system. (Oracle Home = '/u01/app/oracle/product/19.0.0/dbhome_1') Is the local system ready for patching? [y|n] y User Responded with: Y Backing up files... Applying interim patch '32431413' to OH '/u01/app/oracle/product/19.0.0/dbhome_1' Patching component oracle.rdbms, 19.0.0.0.0... Patching component oracle.rdbms.rsf, 19.0.0.0.0... Patch 32431413 successfully applied. Log file location: /u01/app/oracle/product/19.0.0/dbhome_1/cfgtoollogs/opatch/opatch2021-02-19_10-17-59AM_1.log OPatch succeeded.
SQL> alter system set compatible='19.10.0' scope=spfile; System altered. SQL> startup force ORACLE instance started. Total System Global Area 6610222304 bytes Fixed Size 9149664 bytes Variable Size 2768240640 bytes Database Buffers 3825205248 bytes Redo Buffers 7626752 bytes Database mounted. Database opened. SQL> sho parameter compatible NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ compatible string 19.10.0 noncdb_compatible boolean FALSE
SQL Table Macros
CREATE OR REPLACE FUNCTION EmpDept return varchar2 SQL_MACRO is BEGIN RETURN q'{ select employee_id, first_name, last_name, email, phone_number, hire_date, job_id, salary, commission_pct, employees.manager_id emanager_id, department_name, location_id, departments.manager_id dmanager_id from employees, departments where employees.department_id = departments.department_id }'; END; / select * from EmpDept();
Blockchain Tables
CREATE blockchain TABLE Test_Blockchain ( id NUMBER, content VARCHAR2(128) ) no drop until 0 days idle no delete until 16 days after insert hashing using "SHA2_512" version "v1"; insert into Test_Blockchain(id,content) values (1,'Oracle Blockchain Tables'); select * from Test_Blockchain; truncate table Test_Blockchain;
Wednesday, 3 February 2021
The Database Developer VM: installing Apex, ORDS 21.x und SQLDeveloper Web
This post is part of my Oracle Developer VM Project series. It is not meant to replace the official documentation in any way and what I describe is no recommended configuration. It is only meant to be a guide, if you follow my DB Developer VM Project and want to add these services to your VM.
Compared to my other posts, this is a bunch of tools to be installed in one go. The reason is that if you want ORDS and Apex, then it is the best way to install Apex first. But it won't run without ORDS, so both should be installed in one go. And SQLDeveloper Web comes for free with ORDS. But despite the number of additional tools, this is one of the shorter posts of this series.
According to the documentation, memory_target needs to be set to at least 300M for Apex, but in my setup the database won't start with this amount of memory. I get the following error:
ORA-00838: Specified value of MEMORY_TARGET is too small, needs to be at least 6304M
So first, we will set that parameter to the required value.
1 2 | alter system set memory_target='6304M' scope=spfile; startup force; |
sqlplus sys/your_password@orclpdb as sysdba @apexins sysaux sysaux temp /i/
alter user apex_public_user identified by oracle account unlock;
1 2 3 4 5 6 7 | BEGIN DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE( host => '*', ace => xs$ace_type(privilege_list => xs$name_list('connect'), principal_name => 'APEX_200200', principal_type => xs_acl.ptype_db)); END; |
java -jar ords.war
- location to store configuration data => /u01/ords/params/
- database service name: orclpdb
- Enter the APEX static resources location:/u01/apex/images/
java -Dorg.eclipse.jetty.server.Request.maxFormContentSize=3000000 -jar ords.war
<entry key="jdbc.MaxLimit">20</entry> <entry key="jdbc.InitialLimit">10</entry>
1 2 3 4 5 6 7 8 | alter user ORDS_PUBLIC_USER account unlock; alter user APEX_PUBLIC_USER account unlock; alter user APEX_LISTENER account unlock; alter user APEX_REST_PUBLIC_USER account unlock; alter user ORDS_PUBLIC_USER identified by oracle; alter user APEX_PUBLIC_USER identified by oracle; alter user APEX_LISTENER identified by oracle; alter user APEX_REST_PUBLIC_USER identified by oracle; |
Thursday, 21 January 2021
Connect a local database to Oracle Data Safe with the on-premise adapter
Then click on On Premises Connectors on the left pane.
python3 setup.py install --connector-port=1560
In the Data Safe Service Console under Targets, you should find your newly registered database.For a simple test run, go to Home/Security Assessement and pick your database. Click on Assess Now, wait for the report to finish and click View Report.
Oh dear, my database has 2 high risk issues. Don't tell anyone ...