Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 12.2
- On prem
- non-cdb
- decrypt a tablespace
- [oracle@stormking db12201 ~]$ export TNS_ADMIN=/u01/app/oracle/product/12.2.0/dbhome_1/network/admin
- [oracle@stormking db12201 ~]$ cd $TNS_ADMIN
- [oracle@stormking db12201 admin]$ cat sqlnet.ora
- encryption_wallet_location =
- (source =
- (method = file)
- (method_data =
- (directory = /u01/app/oracle/wallet/$ORACLE_SID/wallet)))
- [oracle@stormking db12201 admin]$ mkdir -p /u01/app/oracle/wallet/$ORACLE_SID/wallet
- SQL> administer key management create keystore '/u01/app/oracle/wallet/db12201/wallet' identified by kspw;
- keystore altered.
- SQL> administer key management set keystore open identified by kspw;
- keystore altered.
- SQL> administer key management set key identified by kspw with backup;
- keystore altered.
- SQL> create table tcr ( a varchar2(30)) tablespace users;
- Table created.
- SQL> insert into tcr ( a ) values ( rpad('A',30,'A' ) );
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> select rowid, a from tcr;
- ROWID A
- ------------------ ------------------------------
- AAAR9nAAHAAAACEAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
- [oracle@stormking db12201 buffercache]$ cat dump.rowid.block.sql
- define rowid=&&1
- column file_id new_value file_id
- column block_id new_value block_id
- set linesize 100
- set trimspool on
- select
- trim(dbms_rowid.rowid_relative_fno('&&rowid')) file_id,
- trim(dbms_rowid.rowid_block_number('&&rowid')) block_id
- from dual;
- alter system checkpoint;
- alter session set tracefile_identifier="dumpfno&&file_id._block&&block_id";
- alter system dump datafile &&file_id block &&block_id;
- @ tracefile.sql
- [oracle@stormking db12201 buffercache]$ less /u01/app/oracle/diag/rdbms/db12201/db12201/trace/db12201_ora_7820_dumpfno7_block132.trc
- block_row_dump:
- tab 0, row 0, @0x1f76
- tl: 34 fb: --H-FL-- lb: 0x1 cc: 1
- col 0: [30]
- 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
- 41 41 41 41 41
- end_of_block_dump
- SQL> create tablespace ts encryption using 'aes256' default storage ( encrypt );
- Tablespace created.
- SQL> alter table tcr move tablespace ts;
- Table altered.
- SQL> select rowid, a from tcr;
- ROWID A
- ------------------ ------------------------------
- AAAR9oAAFAAAACDAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
- [oracle@stormking db12201 buffercache]$ sysdba @ dump.rowid.block.sql AAAR9oAAFAAAACDAAA
- SQL*Plus: Release 12.2.0.1.0 Production on Wed Nov 15 00:26:38 2017
- Copyright (c) 1982, 2016, Oracle. All rights reserved.
- Connected to:
- Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
- old 2: trim(dbms_rowid.rowid_relative_fno('&&rowid')) file_id,
- new 2: trim(dbms_rowid.rowid_relative_fno('AAAR9oAAFAAAACDAAA')) file_id,
- old 3: trim(dbms_rowid.rowid_block_number('&&rowid')) block_id
- new 3: trim(dbms_rowid.rowid_block_number('AAAR9oAAFAAAACDAAA')) block_id
- FILE_ID BLOCK_ID
- ---------------------------------------- ----------------------------------------
- 5 131
- System altered.
- old 1: alter session set tracefile_identifier="dumpfno&&file_id._block&&block_id"
- new 1: alter session set tracefile_identifier="dumpfno5_block131"
- Session altered.
- old 1: alter system dump datafile &&file_id block &&block_id
- new 1: alter system dump datafile 5 block 131
- System altered.
- /u01/app/oracle/diag/rdbms/db12201/db12201/trace/db12201_ora_8419_dumpfno5_block131.trc
- ...
- flags: encrypted_on_disk only_sequential_access block_written_once
- ...
- Block dump from disk:
- Decrypting encrypted buffer before dump.
- ...
- block_row_dump:
- tab 0, row 0, @0x1f5e
- tl: 34 fb: --H-FL-- lb: 0x0 cc: 1
- end_of_block_dump
- SQL> select file_name from dba_data_files where tablespace_name = 'TS';
- FILE_NAME
- --------------------------------------------------------------------------------
- +DATA/DB12201/DATAFILE/ts.257.960077917
- SQL> alter tablespace ts encryption decrypt;
- Tablespace altered.
- SQL> select file_name from dba_data_files where tablespace_name = 'TS';
- FILE_NAME
- --------------------------------------------------------------------------------
- +DATA/DB12201/DATAFILE/ts.295.960079179
- /u01/app/oracle/diag/rdbms/db12201/db12201/trace/alert_db12201.log
- 2017-11-15T00:39:37.937822-05:00
- alter tablespace ts encryption decrypt
- 2017-11-15T00:39:38.042792-05:00
- About to decrypt tablespace TS (tsn 0/6)
- Rekeying datafile +DATA/DB12201/DATAFILE/ts.257.960077917 (5) to +DATA
- 2017-11-15T00:39:50.518138-05:00
- Rekey operation committed for file +DATA/DB12201/DATAFILE/ts.295.960079179
- 2017-11-15T00:39:52.934430-05:00
- About to zero out original file "+DATA/DB12201/DATAFILE/ts.257.960077917"
- 2017-11-15T00:39:58.045933-05:00
- Successfully zero'ed out original file "+DATA/DB12201/DATAFILE/ts.257.960077917"
- Successfully deleted original file "+DATA/DB12201/DATAFILE/ts.257.960077917"
- Completed rekey for tablespace TS (tsn 0/6) from key version 0 to 1.
- Completed: alter tablespace ts encryption decrypt
- [oracle@stormking db12201 buffercache]$ sysdba @ dump.rowid.block.sql AAAR9oAAFAAAACDAAA
- SQL*Plus: Release 12.2.0.1.0 Production on Wed Nov 15 00:44:10 2017
- Copyright (c) 1982, 2016, Oracle. All rights reserved.
- Connected to:
- Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
- old 2: trim(dbms_rowid.rowid_relative_fno('&&rowid')) file_id,
- new 2: trim(dbms_rowid.rowid_relative_fno('AAAR9oAAFAAAACDAAA')) file_id,
- old 3: trim(dbms_rowid.rowid_block_number('&&rowid')) block_id
- new 3: trim(dbms_rowid.rowid_block_number('AAAR9oAAFAAAACDAAA')) block_id
- FILE_ID BLOCK_ID
- ---------------------------------------- ----------------------------------------
- 5 131
- Notes:
- The rowid is the same across the decrypt.
- That implies that the file number remains unchanged.
- The ASM file name has changed.
- System altered.
- old 1: alter session set tracefile_identifier="dumpfno&&file_id._block&&block_id"
- new 1: alter session set tracefile_identifier="dumpfno5_block131"
- Session altered.
- old 1: alter system dump datafile &&file_id block &&block_id
- new 1: alter system dump datafile 5 block 131
- System altered.
- tab 0, row 0, @0x1f5e
- tl: 34 fb: --H-FL-- lb: 0x0 cc: 1
- col 0: [30]
- 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
- 41 41 41 41 41
- end_of_block_dump
Add Comment
Please, Sign In to add comment