{"id":1009,"date":"2025-07-15T19:03:33","date_gmt":"2025-07-15T17:03:33","guid":{"rendered":"https:\/\/anjo.pt\/keyword-oracle\/?p=1009"},"modified":"2025-08-25T13:27:45","modified_gmt":"2025-08-25T11:27:45","slug":"encrypt-the-whole-oracle-database-online-with-tde","status":"publish","type":"post","link":"https:\/\/anjo.pt\/keyword-oracle\/2025\/07\/15\/encrypt-the-whole-oracle-database-online-with-tde\/","title":{"rendered":"Encrypt the whole Oracle database online with TDE"},"content":{"rendered":"\n<p>Some programs are part of Oracle ISV &#8211; Independent Software Vendors &#8211; program and include various types of Oracle licenses. This allows to install the application database in various Oracle configurations. At my customer, the software includes Advance Security Option Oracle license. This was the reason we decided, even before moving to the cloud, to encrypt the database.<\/p>\n\n\n\n<p>Here is a summary on how to perform<strong>&nbsp;full online encryption<\/strong>&nbsp;(TDE) of a database. The process is quite simple, but there are known surprises you might want to avoid.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">Check space requirements<\/h2>\n\n\n\n<p>Online encryption is done datafile by datafile. It is necessary to have enough space for copying the biggest datafile of the database.&nbsp;This can be a problem when using bigfile tablespaces.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nSQL&gt;\u00a0select\u00a0con_id,tablespace_name, max(bytes\/1024\/1024\/1024) max_gb \nfrom cdb_data_files \ngroup by con_id,tablespace_name \norder by 3 desc nulls last \nfetch first 10 rows only;\n<\/pre><\/div>\n\n\n<p>While the encryption happens one datafile at the time, on the RHEL8 installation at my client, the process did not release the file descriptor at the end of each datafile encryption. This meant that space was still being used and filesystem was almost full. At <a href=\"#troubleshooting\" data-type=\"internal\" data-id=\"#troubleshooting\">Troubleshooting<\/a> section it is described how to clean up this space during the encryption. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Configure TDE Wallet<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Create Wallet and unified master key<\/h3>\n\n\n\n<p>First, we need to setup a TDE Wallet in the database. Few points to remind:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>This step requires a restart of database!<\/li>\n\n\n\n<li>We will define a new password to be used for keystore. Make sure to save it,<\/li>\n\n\n\n<li>Make sure the files created under&nbsp;the path of <code>WALLET_ROOT<\/code> parameter are part of a filesystem backup.&nbsp;These files are required to open the database!<\/li>\n\n\n\n<li>If there is Dataguard, the parameters below need also to be set on standby and the two generated wallet files copied.<\/li>\n\n\n\n<li>If you plan to clone this database, you need to export and import the keys on the future DB when cloning.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$\u00a0mkdir\u00a0-p\u00a0\/u00\/app\/oracle\/wallet_root\/tde\n\u00a0\nSQL&gt; alter system\u00a0set\u00a0tablespace_encryption=AUTO_ENABLE;\u00a0 -- available from 19.16\nSQL&gt; alter system\u00a0set\u00a0wallet_root=&#039;\/u00\/app\/oracle\/wallet_root&#039;\u00a0scope=spfile;\n\u00a0\n\u00a0\u00a0- plan restart and restart DB -\n\u00a0\nSQL&gt; alter system\u00a0set\u00a0tde_configuration=&#039;keystore_configuration=FILE&#039;\u00a0scope=both;\nSQL&gt; ADMINISTER KEY MANAGEMENT CREATE KEYSTORE IDENTIFIED BY\u00a0&quot;xxxx&quot;;\u00a0 \/* Add to Password Safe *\/\n\u00a0\nSQL&gt; !\u00a0ls\u00a0-l\u00a0\/u00\/app\/oracle\/wallet_root\/tde\ntotal 4\n-rw-------. 1 oracle dba 2553 Apr 17 11:55 ewallet.p12\n\u00a0\nSQL&gt; ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN IDENTIFIED BY\u00a0&quot;xxx&quot;\u00a0container=all;\nSQL&gt; ADMINISTER KEY MANAGEMENT SET KEY IDENTIFIED BY\u00a0&quot;xxx&quot;\u00a0with backup container=all; \nSQL&gt; col wrl_parameter\u00a0for\u00a0a40\nSQL&gt;\u00a0select\u00a0con_id,WRL_PARAMETER, WRL_TYPE,WALLET_TYPE, status from V$ENCRYPTION_WALLET;\n\u00a0\n\u00a0\u00a0\u00a0\u00a0CON_ID WRL_PARAMETER\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 WRL_TYPE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 WALLET_TYPE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 STATUS\n---------- ---------------------------------------- -------------------- -------------------- ------------------------------\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a01\u00a0\/u00\/app\/oracle\/wallet_root\/tde\/\u00a0\u00a0\u00a0\u00a0 \u00a0 \u00a0\u00a0FILE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 PASSWORD\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 OPEN\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 FILE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 PASSWORD\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 OPEN\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a03\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 FILE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 PASSWORD\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 OPEN\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">Create autologin wallet<\/h3>\n\n\n\n<p>This ensures the DB will automatically open the wallet during startup. The <code>WALLET_TYPE <\/code>in the <code>V$ENCRYPTION_WALLET<\/code> will change from <code>PASSWORD <\/code>to <code>AUTOLOGIN<\/code>.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSQL&gt; ADMINISTER KEY MANAGEMENT CREATE AUTO_LOGIN KEYSTORE FROM KEYSTORE\u00a0&#039;\/u00\/app\/oracle\/wallet_root\/tde\/&#039;\u00a0IDENTIFIED BY\u00a0&quot;xxx&quot;;\n\u00a0\nSQL&gt; ADMINISTER KEY MANAGEMENT SET KEYSTORE CLOSE IDENTIFIED BY\u00a0&quot;xxx&quot;\u00a0container=all;\n\u00a0\nSQL&gt; col wrl_parameter\u00a0for\u00a0a40\nSQL&gt;\u00a0select\u00a0con_id,WRL_PARAMETER, WRL_TYPE,WALLET_TYPE, status from V$ENCRYPTION_WALLET;\n\u00a0\n\u00a0\u00a0\u00a0\u00a0CON_ID WRL_PARAMETER\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 WRL_TYPE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 WALLET_TYPE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 STATUS\n---------- ---------------------------------------- -------------------- -------------------- ------------------------------\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a01\u00a0\/u00\/app\/oracle\/wallet_root\/tde\/\u00a0\u00a0\u00a0\u00a0 \u00a0 \u00a0\u00a0FILE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 AUTOLOGIN\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 OPEN\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 FILE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 AUTOLOGIN\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 OPEN\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a03\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 FILE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 AUTOLOGIN\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 OPEN\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Encrypt tablespaces<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Check if OMF is configured and used<\/strong><\/h3>\n\n\n\n<p>It is recommended to enable OMF if not yet done. To enable OMF, the <code>db_create_file_dest<\/code> needs to be set.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSQL&gt; show parameter db_create_file_dest\u00a0\nNAME\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TYPE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 VALUE\n------------------------------------ ----------- ------------------------------\ndb_create_file_dest\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 string\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/u01\/oradata\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\"><strong>Get list of commands to run<\/strong><\/h3>\n\n\n\n<p>On each of the PDBs, including <code>CDB$ROOT<\/code>, encrypt the tablespaces. To speed up, you can run different tablespace encryption in parallel sessions.&nbsp;Each session uses about one CPU and some IO.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nSQL&gt; select\u00a0&#039;\/* PDB: &#039;||con_id_to_con_name(con_id)||&#039; *\/ ALTER TABLESPACE &#039;||tablespace_name||&#039; ENCRYPTION ONLINE ENCRYPT; \/* &#039;||count(*)||&#039; files - &#039;||round(sum(bytes)\/1024\/1024\/1024) ||&#039; GB *\/&#039;\u00a0cmd\nfrom\u00a0cdb_tablespaces\u00a0join\u00a0cdb_data_files using (con_id, tablespace_name)\nwhere\u00a0con_id!=2\u00a0and\u00a0encrypted=&#039;NO&#039;\ngroup\u00a0by\u00a0con_id, tablespace_name\norder\u00a0by\u00a0con_id,sum(bytes);\u00a0\nCMD\n------------------------------------------------------------------------------------------------------------------------------------------------------\n\/* PDB: CDB$ROOT *\/\u00a0ALTER\u00a0TABLESPACE USERS ENCRYPTION ONLINE ENCRYPT; \/* 1 - 1 GB *\/\n\/* PDB: CDB$ROOT *\/\u00a0ALTER\u00a0TABLESPACE ABC_ENCRYPT ENCRYPTION ONLINE ENCRYPT; \/* 1 - 5 GB *\/\n...\n<\/pre><\/div>\n\n\n<p>Run the output from above command in right container.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Follow-up TDE encryption&nbsp;<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nSELECT to_char(sysdate,&#039;DD-MON-YY HH24:MI:SS&#039;)\u00a0time, con_id, tablespace_name,\n    COUNT(*) as\u00a0&quot;#FILES&quot;,\u00a0\u00a0\u00a0\u00a0\u00a0SUM(CASE WHEN encrypted =\u00a0&#039;YES&#039;\u00a0THEN 1 ELSE 0 END) as\u00a0&quot;#ENC_FILES&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0ROUND(SUM(bytes)\/1024\/1024\/1024, 2) as size_gb,\n\u00a0\u00a0\u00a0\u00a0\u00a0TO_CHAR(ROUND( (SUM(CASE WHEN encrypted =\u00a0&#039;YES&#039;\u00a0THEN bytes ELSE 0 END) \/ SUM(bytes)) * 100, 2 ),&#039;90.00&#039;)||&#039; %&#039;\u00a0as enc_perc\nFROM\u00a0v$datafile_header\nWHERE con_id != 2\nGROUP BY rollup (con_id, tablespace_name)\nHAVING SUM(CASE WHEN encrypted =\u00a0&#039;YES&#039;\u00a0THEN bytes ELSE 0 END) \/ SUM(bytes) &lt; 1 \/* only not finished *\/\nORDER BY con_id, tablespace_name;\u00a0\n-- \nor via Alertlog: tail\u00a0-100f alert*.log |\u00a0grep\u00a0-B1\u00a0&quot;:TDE converting datafile&quot;\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">TDE encryption throughput<\/h3>\n\n\n\n<p>On a single node VM, the average throughput was 4 GB\/minute &#8211; one 32GB datafile in a bit more than 8 minutes.On the standby side was a ExaCC, it took less than 5 minutes per 32GB datafile.<\/p>\n\n\n\n<p>Having 4 parallel sessions encrypting the database on primary side did not change the timing per datafile, meaning: it was 4 times faster. On the standby side only one process is doing the encryption.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Resume TDE encryption<\/h3>\n\n\n\n<p>In case the encryption stops or is killed in the middle, you can continue the encryption operation by calling:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nSQL&gt; ALTER TABLESPACE &lt;tbs_name&gt; ENCRYPTION ONLINE FINISH ENCRYPT;\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">Re-create Temporary tablespaces<\/h3>\n\n\n\n<p>In each of the containers, re-create the temporary tablespace (add more tempfiles if needed with <code>ALTER TABLESPACE xxx ADD TEMPFILE;<\/code>):<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nSQL&gt; SELECT\u00a0&#039;\/* PDB: &#039;||con_id_to_con_name(con_id)||&#039; *\/ CREATE TEMPORARY TABLESPACE &#039;\u00a0||tablespace_name||&#039;_ENC; \/* tempfiles to be added: &#039;||count(*)||&#039; *\/&#039;\u00a0cmd \nFROM CDB_TEMP_FILES \ngroup by con_id, tablespace_name;\n<\/pre><\/div>\n\n\n<p>In each container &#8211; change default temporary tablespace to the new one:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nSQL&gt; ALTER DATABASE DEFAULT TEMPORARY TABLESPACE &lt;old_name&gt;_enc;\n<\/pre><\/div>\n\n\n<p>Drop the old temporary tablespace<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nSQL&gt; DROP TABLESPACE TEMP INCLUDING CONTENTS AND DATAFILES;\n<\/pre><\/div>\n\n\n<p>Rename the temporary tablespace back (optional)<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nSQL&gt; ALTER TABLESPACE &lt;old_name&gt;_enc RENAME TO &lt;old_name&gt;;\n<\/pre><\/div>\n\n\n<p>Check all tablespaces are encrypted<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nSQL&gt; SELECT CON_ID, CONTENTS, TABLESPACE_NAME, ENCRYPTED \nFROM CDB_TABLESPACES \nORDER BY 1,2,3;\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Dataguard impact of TDE Encryption<\/h2>\n\n\n\n<p>When your database has a standby, it is usually better to use the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Stop the apply process and make sure standby is in mount mode<\/li>\n\n\n\n<li>Perform OFFLINE encryption of tablespaces on standby<\/li>\n\n\n\n<li>Resume the apply process<\/li>\n\n\n\n<li>Switchover the database to the standby<\/li>\n\n\n\n<li>Repeat the OFFLINE encryption on the other side<\/li>\n<\/ul>\n\n\n\n<p>If doing ONLINE TDE encryption on the primary side, then the encryption is simultaneous done on standby side.&nbsp;<\/p>\n\n\n\n<p>The &#8220;ALTER TABLESPACE&#8221; DDL commands are sent to the standby and the&nbsp;TDE conversion in standby is run independently from the conversion in the primary. It can that the TDE conversion for some tablespaces finishes before on standby than on primary.<\/p>\n\n\n\n<p>During the single tablespace encryption the the apply is paused (transport continues). The lag will increase until all datafiles of the tablespace are encrypted. On alertlog is possible to see this:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSWITCHOVER VERIFY: standby database&#039;s reccovery lags behind. The apply lag is 11781\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"troubleshoting\">Troubleshooting<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Backups conflicts<\/h3>\n\n\n\n<p>If backups are running during the encryption, it can also happen that some files cannot be deleted, as they are still being read by rman. You get this in alertlog:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nANJO_PDB1(3):Successfully zero&#039;ed out original file &quot;+DATA\/ANJOCDB\/374BFC384F82D5B2E063DC62A10AB914\/DATAFILE\/sysaux.678.1205510495&quot;\nANJO_PDB1(3):WARNING: Cannot delete old file +DATA\/ANJOCDB\/374BFC384F82D5B2E063DC62A10AB914\/DATAFILE\/sysaux.678.1205510495 left after datafile TDE conversion\n2025-07-15T11:18:26.238729+02:00\nANJO_PDB1(3):Errors in file \/u02\/app\/oracle\/diag\/rdbms\/anjocdb\/ANJOCDB\/trace\/ANJOCDB_pr00_179903.trc:\nORA-15028: Oracle Automatic Storage Management (Oracle ASM) file &#039;+DATA\/ANJOCDB\/374BFC384F82D5B2E063DC62A10AB914\/DATAFILE\/sysaux.678.1205510495&#039; not dropped; currently being accessed\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">Recover space from deleted datafiles<\/h3>\n\n\n\n<p>While the encryption happens datafile after datafile, it was seen that the &#8220;deleted&#8221; files did not have the space released until the sqlplus session was closed. The file descriptors remained there:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ lsof +aL1 \/u01\/oradata\/ANJO_CDB\n\nCOMMAND      PID   USER   FD   TYPE DEVICE    SIZE\/OFF NLINK        NODE NAME\noracle_17  17729 oracle  276u   REG  253,4           1     0 24015839280 \/u01\/oradata\/ANJO_CDB\/374BFC384F82D5B2E063DC62A10AB914\/datafile\/o1_mf_sysaux_n4lxr8gf_.dbf (deleted)\noracle_17  17729 oracle  278u   REG  253,4           1     0 23734824823 \/u01\/oradata\/ANJO_CDB\/374BFC384F82D5B2E063DC62A10AB914\/datafile\/o1_mf_sysaux_n4lxr8gx_.dbf (deleted)\noracle_17  17729 oracle  279u   REG  253,4           1     0 24015839269 \/u01\/oradata\/ANJO_CDB\/374BFC384F82D5B2E063DC62A10AB914\/datafile\/o1_mf_sysaux_n4lxr8h4_.dbf (deleted)\noracle_17  17729 oracle  280u   REG  253,4           1     0 23734824830 \/u01\/oradata\/ANJO_CDB\/374BFC384F82D5B2E063DC62A10AB914\/datafile\/o1_mf_sysaux_n4lxr8hh_.dbf (deleted)\n<\/pre><\/div>\n\n\n<p>As I was encrypting a 10 TB tablespace and did not have enough disk space to wait, I did wrote a small script which is called by crontab every 30 minutes to empty the file descriptors and giving back the disk space. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ cat rm_deleted_files.sh\n\n#!\/bin\/bash\n\necho $(date) &gt;&gt; \/tmp\/log.txt\n\/sbin\/lsof +aL1 \/u01\/oradata\/ANJOCDB | awk &#039;NR&gt;1 &amp;&amp; $7 &gt; 100000 {gsub(\/&#x5B;^0-9]\/, &quot;&quot;, $4); print $2, $4, $7, $10}&#039; | while read pid fd size file; do\n    echo &quot;\/proc\/$pid\/fd\/$fd&quot; &gt;&gt; \/tmp\/log.txt\n    echo &gt; &quot;\/proc\/$pid\/fd\/$fd&quot;\ndone\n<\/pre><\/div>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some programs are part of Oracle ISV &#8211; Independent Software Vendors &#8211; program and include various types of Oracle licenses. This allows to install the application database in various Oracle configurations. At my customer, the software includes Advance Security Option Oracle license. This was the reason we decided, even before moving to the cloud, to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,39,9],"tags":[],"class_list":{"0":"post-1009","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-oracle","7":"category-oracle-19c","8":"category-security","9":"czr-hentry"},"_links":{"self":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/1009","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/comments?post=1009"}],"version-history":[{"count":21,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/1009\/revisions"}],"predecessor-version":[{"id":1042,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/1009\/revisions\/1042"}],"wp:attachment":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/media?parent=1009"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/categories?post=1009"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/tags?post=1009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}