Oracle TDE Conversion
Oracle TDE Conversion
Oracle TDE Conversion
Table of Contents 0
Introduction 1
Prerequisites 1
Conversion Overview 3
Prerequisites 3
Conversion Example 3
Asymmetrical Configurations 12
Hardware Keystore 13
Decrypt 13
Conclusion 13
Once installed, the patch enables offline, in-place TDE conversion of data files at a Data Guard standby with a DDL
command instead of having to reload data which can be time consuming, tedious, and in some cases complex. The
patch must be applied to all Oracle Homes in the Data Guard configuration. This process is the recommended
Oracle Maximum Availability Architecture best practice for converting to TDE with minimal downtime and least
complexity. This supersedes previous methods for converting to TDE described in Appendix A- Alternative Methods.
Whether you have an existing physical standby database or are using a new physical standby database deployed
solely for facilitating conversion to TDE, the process of conversion includes the following:
NOTE: As of Oracle Database 12.2, Online encryption can be performed against a primary database which in turn
encrypts the standby. See Encryption Conversions for Existing Online Tablespaces in the 12.2 documentation for
more details.
Prerequisites
» See MOS 2148746.1 for the most recent information on the patch to the database home for the primary and
standby databases required by this process.
» Take or ensure there is a viable backup available.
» Understand TDE implications and restrictions and develop a process for maintaining wallets and keys. Refer to
the Oracle Database Advanced Security Administrator's Guide (11.2|12.1|12.2) and MOS 1228046.1 for further
details.
7. Execute a Data Guard switchover making the encrypted standby the new primary and the unencrypted primary
the new standby.
8. On the NEW standby: Place the new standby database in a mounted state with recovery stopped.
10. On the NEW standby: Restart redo apply and catch up.
11. Optionally execute a Data Guard switchover to reestablish the original configuration.
This Oracle Maximum Availability Architecture (Oracle MAA) best practices white paper is intended for database
administrators who wish to convert a non-encrypted Oracle Database to TDE with minimal downtime. This paper
assumes the reader has a technical understanding of Data Guard and TDE.
As always, be sure to execute and verify this process in a test environment before executing in production.
There are two forms of TDE encryption. TDE column encryption encrypts specific columns of data while TDE
tablespace encryption encrypts all data within a TDE encrypted tablespace. Tablespace encryption takes advantage
of bulk encryption to enhance performance while relieving the administrator of the task of analyzing each column to
determine which should be encrypted. Additionally, there are fewer restrictions with tablespace encryption compared
to column encryption. This paper describes how to convert to TDE tablespace encryption. TDE tablespace
encryption is available in Oracle Database 11g Release 1 (11.1) and higher.
Refer to the Oracle Database Advanced Security Administrator's Guide and MOS 2359020.1 for full details
regarding TDE encryption1.
1 https://docs.oracle.com/database/121/ASOAG/asotrans.htm#ASOAG10117
Conversion Overview
There are many configuration options for TDE tablespace encryption including but not limited to the type of keystore
and storage used. This document describes the most common options. Refer to the Database Advance Security
Guide for your specific version for full details. 11.2 | 12.1 | 12.2
Prerequisites
This process requires the following prerequisites to ensure a successful execution.
Note: If UNRECOVERABLE_CHANGE# is >0 for any datafile, compare the value on the primary to the value on the
standby. If they are the same the datafile was copied after the unrecoverable change and no action is necessary.
» A log archive destination (LAD) must be set for each database to transport redo when it is a primary database. If
the broker is configured and utilized as per MAA best practices, the LAD will be set automatically after the role
transition.
Conversion Example
TDE utilizes wallets and keystores to store the master encryption key. While the default database wallet can be
used, Oracle recommends using a separate wallet for TDE by using the ENCRYPTION_WALLET_LOCATION
parameter in sqlnet.ora. Additionally, using an auto-login wallet relieves the administrator from opening the wallet
manually each time the database is started.
The wallet will be created on the primary database and must be manually copied to the standby environment. In
RAC configurations the MAA best practice is to create the wallet in a shared location such as an ASM disk group. If
no shared storage is available, the wallet must be copied to all nodes of the primary and standby clusters.
If the database is already using an encryption wallet or keystore, the same may be reused but Oracle recommends
a new master key be set.
NOTE: The new wallet should not be used for encryption on the primary database until the end of this process. A
database bounce is required for all database processes to pick up the wallet location from the sqlnet.ora which is
being deferred at the initial primary until the switchover.
NOTE: ASM storage of the encryption wallet is not supported until RDBMS version 12.1.0.1
Set the wallet location in the sqlnet.ora on all nodes of primary and standby.
ENCRYPTION_WALLET_LOCATION =
(METHOD_DATA =
(DIRECTORY = /u01/app/oracle/admin/TDE/$ORACLE_UNQNAME)
NOTE: Using an environment variable like $ORACLE_UNQNAME in the directory path ensures that all databases on a
shared system use their own wallet. Using this environment variable requires that the variable be set in CRS(where
applicable) and the OS user’s environment.
2. Create the corresponding directory on all nodes or shared storage with the proper ORACLE_UNQNAME.
$ mkdir -p /u01/app/oracle/admin/TDE/<ORACLE_UNQNAME>
3. Set the environment variable in CRS(if applicable) and for the OS session.
$ export ORACLE_UNQNAME=<ORACLE_UNQNAME>
NOTE: Set the ORACLE_UNQNAME variable in login scripts or environment scripts as well. Any session that may
start the database or instance must have the variable set in order to find the wallet
This step may cause redo apply to stop on the standby. It can be restarted once the wallet is copied to the standby
in the step 8.
NOTE: Ensure that the password string is contained in double quotation marks (" ").
System altered.
An auto login wallet removes the requirement of manually opening the wallet when the database is started.
8. Copy the files generated in the keystore directory to all nodes of the primary and standby.
$ scp /u01/app/oracle/admin/TDE/$ORACLE_UNQNAME/*
oracle@<host>:/u01/app/oracle/admin/TDE/<ORACLE_UNQNAME>/
OR
The keystore will be created on one primary instance and must be manually copied to the standby database
environment.
Set the keystore location in the sqlnet.ora on all nodes of primary and standby.
ENCRYPTION_WALLET_LOCATION =
(SOURCE = (METHOD = FILE)
(METHOD_DATA =
(DIRECTORY = +DATA/$ORACLE_UNQNAME/TDE)
)
)
NOTE: Using an environment variable like $ORACLE_UNQNAME in the directory path ensures that all databases on a
shared system use their own wallet. Using this environment variable requires that the variable be set in CRS(where
applicable) and the OS user’s environment.
2. Create the corresponding directory on all nodes with the proper ORACLE_UNQNAME.
3. Set the environment variable in CRS(if applicable) and for the OS session.
NOTE: Set the ORACLE_UNQNAME variable in login scripts or environment scripts as well. Any session that may
start the database or instance must have the variable set in order to find the wallet
4. Initiate a new SQL*Plus session. This causes the changes to sqlnet.ora and environment variable to be picked
up by the new session.
NOTE: Ensure that the password string is contained in double quotation marks (" ").
ADMINISTER KEY MANAGEMENT SET KEY IDENTIFIED BY "AbCdEfGh!" WITH BACKUP USING 'TDE'
[CONTAINER=ALL|CURRENT];
NOTE: If the database is a non-CDB, omit the CONTAINER clause. Each PDB including the ROOT container (but
not PDB$SEED) will have a different master encryption key, and setting CONTAINER=ALL generates a master key
for each PDB including ROOT using one command. If only a subset of PDBs requires TDE, first set the ROOT
master key followed by each PDB individually.
An auto login keystore removes the requirement of manually opening the keystore when the database is started.
8. Copy the files generated in the keystore directory to each standby environment.
OR
In version 12.2, the TEMP tablespaces can be encrypted but they cannot be converted. To have an encrypted
TEMP tablespace, create an encrypted TEMP tablespace in Oracle Database 12c release 2 (12.2), make it the
default temporary tablespace, and then drop the original TEMP tablespace. Remember not to use the wallet to
encrypt on the primary until either after a role transition or the primary database has been restarted.
The UNDO and TEMP metadata that is generated from sensitive data in an encrypted tablespace is already
automatically encrypted. Therefore, encrypting UNDO and TEMP tablespaces is optional.
2. Stop recovery.
no rows selected
While Redo Apply is stopped, redo is still being transported from the primary to the standby database while it is
mounted, minimizing the Recovery Point Objective (RPO) in the event of a primary database failure or disaster.
Only application tablespace data files can be converted in Oracle Database releases 12.1 and 11.2. SYSTEM,
SYSAUX, UNDO, and TEMP cannot be encrypted with TDE.
For 12.2 encrypting UNDO and SYSTEM tablespaces is not recommended.
Remove ‘ts.con_id=df.con_id and’ from the query above for RDBMS version 11.2
For container databases use the following query instead (You may need to open the database in read only mode to
get results from this query. Remember to stop and start the database in mounted mode before continuing.) :
COMMAND
------------------------------------------------------------------------------------
Each datafile can be encrypted simultaneously in its own session. In this example, the four data files were converted
at the same time in four different windows.
Note: This process uses CPU and I/O resources. In a shared environment, some care should be taken to monitor
resources so that multiple encryption processes do not infringe on other databases’ resource requirements.
Database altered.
Database altered.
Database altered.
Note: The offline encryption operation is idempotent; if the conversion of a data file is interrupted for any reason
simply re-run the alter database command.
Total Pages Encrypted : 751075 <-- Total Pages Examined - Total Pages Empty
In the DBVerify output, any pages marked as ‘Data’ or ‘Index’ are not encrypted. Pages labeled as ‘Other’ are not
Data or Index pages and do not need to be encrypted, any value for ‘Other’ can be ignored. All encrypted pages
whether Data or Index will be grouped together as Encrypted.
6. Restart recovery.
After all datafiles are encrypted restart recovery. Any new redo applied to the encrypted data files will be encrypted.
Once the standby is current with no gaps, proceed to step 7.
7. Switchover.
Execute a switchover making the standby the new primary. All new data applied to the standby will be encrypted.
This step is potentially the only outage required for this process (an optional switchback would also incur an outage).
Refer to the ‘Role Transition Best Practices’ whitepaper to optimize switchover and reduce application down time.
MAA testing has produced switchovers in less than 1 minute.
Note: While this switchover does not have to occur immediately after datafile encryption on the standby, it is not
recommended that the state of a non-encrypted primary with an encrypted standby be left indefinitely.
8. Restart the new standby (the original primary) to pick up the sqlnet.ora changes, and repeat steps 1-5 for the new
standby database and all other standby databases in the configuration.
Note: The datafile names are potentially different on the primary than those on the standby.
9. As before, when the conversion steps are complete and the standby has caught up with the primary, optionally
switch back to the original configuration.
Asymmetrical Configurations
When one database in the Data Guard configuration is encrypted and the other is not, the state of encryption of a
recovered block changes depending on the RDBMS version.
For Oracle Database 12.2 and later, recovery honors the encryption properties of the database. If a data file is
encrypted at the standby, a recovered block to that data file will be encrypted regardless of whether the redo (source
primary) is encrypted.
For Oracle Database 12.1 and 11.2, the encryption state of the redo (source primary) is honored, so regardless of
the encryption state of the data file at the standby, redo from an unencrypted data file on the primary is stored
unencrypted at the standby.
Therefore in Oracle Database 11.2 and 12.1, to ensure all blocks at the standby are encrypted, an additional
execution of the encryption commands is potentially required if any redo from an unencrypted primary has been
applied. This second execution should be much shorter in duration because there should be fewer blocks to encrypt.
For example:
6. Switch back.
7. Run DBVerify against the standby data files, and if unencrypted data blocks are found, encrypt
standby data files a second time replacing the ‘encrypt’ clause with the ‘force encrypt’ clause.
For Example:
SQL> alter database datafile '+DATA/TDESTBY/DATAFILE/users.1163.910254789'
force encrypt;
Hardware Keystore
Hardware keystores are supported for Oracle Database 12c. For additional details with regard to hardware
keystores please review the documentation.
For additional details on logical standby databases and TDE please see the relevant documentation (11.2|12.1).
Decrypt
If datafiles need to be decrypted for any reason, there is also a DECRYPT clause. Only datafiles encrypted with this
offline encryption conversion method described in the paper can be decrypted with the following method:
Note: Requirements of a mounted database or an offline data file apply to the DECRYPT command as well.
Conclusion
Converting to Oracle Advanced Security Transparent Data Encryption provides protection for data at rest in an
Oracle Database. The process of encrypting the data is a challenge with 24/7 requirements for many applications.
Using a Data Guard physical standby database to facilitate the encryption process minimizes the impact to the
availability of the application while achieving the goal of encrypted data at rest. The new offline encrypt feature is
available with a patch in Oracle Database releases 12c and 11.2.0.4 to greatly simplify TDE conversion to a DDL
CONNECT W ITH US Copyright © 2018, Oracle and/or its affiliates. All rights reserved. This document is provided for information purposes only, and the
contents hereof are subject to change without notice. This document is not warranted to be error-free, nor subject to any other
blogs.oracle.com/oracle warranties or conditions, whether expressed orally or implied in law, including implied warranties and conditions of merchantability or
fitness for a particular purpose. We specifically disclaim any liability with respect to this document, and no contractual obligations are
facebook.com/oracle formed either directly or indirectly by this document. This document may not be reproduced or transmitted in any form or by any means,
electronic or mechanical, for any purpose, without our prior written permission.
twitter.com/oracle Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
oracle.com Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and
are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are
trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group. 0818