Skip to content

Oracle 11g OCM之表空间加密

表空间加密

  • 1.1.wallet链接
  • 1.2.表空间加密解释连接

表空间加密即对表空间里的所有数据进行自动加密,它能够保证在数据文件或者数据备份泄漏的情况下保证数据的安全性。
表空间的加密采用transparent data encryption architecture即透明数据加密结构,加密方式类似以前常见的TDE。加密的密钥再次由一个称为主密钥的密钥二次加密,主密钥存储在wallet中。加密后的表空间加密的密钥存储在数据库中的字典表中。只需要对数据表空间进行加密,临时表空间和回滚表空间并不需要加密,因为在将数据写入redo,undo,temp时候,数据库会自动进行加密。wallet无法对sys用户的对象或者数据进行加密。

加密表空间有一定的限定条件,不能对已经在使用的表空间进行加密,但是可以通过向加密表空间中利用数据泵导入数据,或使用ctas或atm把已经存在数据转储到加密表空间。官网还关于LOB方面注释:
There is no need to use LOB encryption on SECUREFILE LOBs stored in an encrypted tablespace.

使用表空间加密的步骤:

  • 1.3.创建表空间加密的主密匙存放目录(wallet目录)

[oracle@luda 23:03:32|~]mkdir $ORACLE_HOME/luda_wallets

  • 1.4.设置SQLNET.ORA文件中的ENCRYPTION_WALLET_LOCATION 参数指定使用密匙目录。

[oracle@luda 23:07:37|/oracle/product/11.2/network/admin]cat sqlnet.ora

ENCRYPTION_WALLET_LOCATION=

(SOURCE=

(METHOD=file)

(METHOD_DATA=

(DIRECTORY=/oracle/product/11.2/luda_wallets)))

[oracle@luda 23:07:40|/oracle/product/11.2/network/admin]

  • 1.5.重新启动数据库

[oracle@luda 23:09:23|/oracle/product/11.2/network/admin]sq

SQL*Plus: Release 11.2.0.1.0 Production on Tue Nov 13 23:09:25 2012

Copyright (c) 1982, 2009, Oracle.  All rights reserved.
Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

Total System Global Area  422670336 bytes

Fixed Size                  1336960 bytes

Variable Size             318769536 bytes

Database Buffers           96468992 bytes

Redo Buffers                6094848 bytes

Database mounted.

Database opened.

SQL>

  • 1.6.打开wallet

SQL> ALTER SYSTEM SET ENCRYPTION KEY IDENTIFIED BY “oracle”;

System altered.

*已经打开wallet,再次打开就会报错

SQL> ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY “oracle”;

ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY “oracle”

*

ERROR at line 1:

ORA-28354: wallet already open
SQL>

  • 1.7. 表空加密的算法

透明的数据加密,支持标准的加密算法,包括高级加密标准(AES)和三重数据加密标准(3DES)算法,默认使用AES128:

1)AES256

2)AES192

3)AES128

4)3DES168

oracle官方解释对于加密表空间没有额外的磁盘空间开销。

  • 1.8 创建加密表空间

SQL>   create tablespace luda_ent datafile ‘/data01/ludaent01.dbf’ size 100M

2          encryption default storage(encrypt);

Tablespace created.

  • 1.9 其他加密算法操作

create tablespace luda_ent02 datafile ‘/data01/ludaent02_1.dbf’ size 20M

encryption using ‘3DES168’ default storage(encrypt);

  • 2.0查询表空间的加密信息

SQL> SELECT t.name, e.encryptionalg algorithm  FROM  v$tablespace t, v$encrypted_tablespaces e WHERE t.ts# = e.ts#;

NAME                           ALGORIT

—————————— ——-

LUDA_ENT                       AES128

LUDA_ENT02                     3DES168

  • 2.1.关闭加密表空间

 

drop tablespace luda_ent including contents and datafiles;

drop tablespace luda_ent02 including contents and datafiles;

col WRL_PARAMETER for a40

col status for a10

select * from v$encryption_wallet;

WRL_TYPE             WRL_PARAMETER                            STATUS

——————– —————————————- ———-

file                 /oracle/product/11.2/luda_wallets        OPEN

  • 2.2.关闭wallet

SQL> alter system set encryption wallet close identified by “oracle”;

System altered.

*关闭wallet后,对已经加密过的数据将无法查询。

4 thoughts on “Oracle 11g OCM之表空间加密

  1. lishixia says:

    整理的好,很详细

    • luda says:

      3Q啊 感觉还不是很详细啊,没有把数据访问和加密方面的结合起来讲

  2. luda says:

    沙发

  3. Pingback: Ludatou's life » 11g OCM复习项目列表(更新中)

Comments are closed.