0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Oracle Database Vault 環境で Data Pump を使う(Oracle Database 19c)

Posted at

Oracle Database Vault を使っている環境で Data Pump がエラーになる現象の説明と対応策について記述しています。

Database Guard による保護

Database Vault ではレルムを作成してユーザーのデータを保護します。レルムの管理は DV_OWNER ロールを保持するユーザーで実行します。

レルムの作成
SQL> BEGIN
  2     DBMS_MACADM.CREATE_REALM (
  3        realm_name => 'REALM_USER1',
  4        description => 'Realm for User1',
  5        enabled => DBMS_MACUTL.G_YES,
  6        audit_options => DBMS_MACUTL.G_REALM_AUDIT_OFF,
  7        realm_type => 1);
  8  END;
  9  /

PL/SQL procedure successfully completed.

SQL> SELECT NAME FROM DBA_DV_REALM;

NAME
--------------------------------------------------------------------------------
Oracle Database Vault
Database Vault Account Management
Oracle Enterprise Manager
Oracle Default Schema Protection Realm
Oracle System Privilege and Role Management Realm
Oracle Default Component Protection Realm
REALM_USER1

レルム REALM_USER1 にオブジェクトを登録します。下記の例では USER1 ユーザーが所有する全オブジェクトをレルム REALM_USER1 に追加しています。

レルムにオブジェクト追加
SQL> BEGIN
  2     DBMS_MACADM.ADD_OBJECT_TO_REALM (
  3        realm_name => 'REALM_USER1',
  4        object_owner => 'USER1',
  5        object_name => DBMS_MACUTL.G_ALL_OBJECT,
  6        object_type => DBMS_MACUTL.G_ALL_OBJECT);
  7  END;
  8  /

PL/SQL procedure successfully completed.

ユーザー USER1 をレルムの参加者(PARTICIPANT)として登録します。

レルムにユーザー登録
SQL> BEGIN
  2     DBMS_MACADM.ADD_AUTH_TO_REALM (
  3        realm_name => 'REALM_USER1',
  4        grantee => 'USER1',
  5        auth_options => DBMS_MACUTL.G_REALM_AUTH_PARTICIPANT);
  6  END;
  7  /

PL/SQL procedure successfully completed.

これにより USER1 が作成したオブジェクトには SYS ユーザーでもアクセスできなくなりました。

SYS ユーザーによるレルム内ユーザーのデータ参照
SQL> CONNECT / AS SYSDBA
Connected.
SQL> ALTER SESSION SET CONTAINER=pdb1;

Session altered.

SQL> SELECT * FROM user1.data1;
SELECT * FROM user1.data1
                    *
ERROR at line 1:
ORA-01031: insufficient privileges

Data Pump の失敗

Data Guard のレルムで保護されたユーザー名を使って Data Pump エクスポートを実行します。スキーマ(SCHEMAS)を指定して実行するとエラーになります。

Data Pump のエラー
$ expdp userid=user1/{password}@pdb1 directory=data_pump_dir dumpfile=user1.dmp schemas=user1

Export: Release 19.0.0.0.0 - Production on Thu May 22 23:28:38 2025
Version 19.26.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
ORA-39006: internal error
ORA-31632: master table "USER1.SYS_EXPORT_SCHEMA_01" not found, invalid, or inaccessible
ORA-01031: insufficient privileges

ORA-39097: Data Pump job encountered unexpected error -1031
$

サポート対象外ですが、従来型の Export ユーティリティは成功します。

Export ユーティリティは成功
$ exp userid=user1/{Password}@pdb1 file=data1.dmp tables=data1 direct=y

Export: Release 19.0.0.0.0 - Production on Thu May 22 19:35:14 2025
Version 19.26.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.26.0.0.0
Export done in AL32UTF8 character set and AL16UTF16 NCHAR character set

About to export specified tables via Direct Path ...
. . exporting table                          DATA1     100000 rows exported
Export terminated successfully without warnings.
$

テーブル単位の Data Pump エクスポート(TABLES オプションを指定)でも同じエラーが発生します。エラーの内容は以下の通りです。

エラー・コード メッセージ 内容
ORA-39006 internal error 内部エラー発生
ORA-31632 master table "テーブル名" not found, invalid, or inaccessible Data Pump管理テーブルにアクセスできない
ORA-01031 insufficient privileges 権限が無い
ORA-39097 Data Pump job encountered unexpected error -1031 Data Pumpが失敗した原因は 1031

Data Pump は実行時に接続ユーザーのスキーマ内に管理用テーブルを作成します。管理テーブルに権限不足でアクセスできないので Data Pump がエラーになったというメッセージです。SQL*Plus で対象テーブルを確認します。

テーブル一覧
$ sqlplus user1/{Password}@pdb1

SQL*Plus: Release 19.0.0.0.0 - Production on Thu May 22 19:23:17 2025
Version 19.26.0.0.0

Copyright (c) 1982, 2024, Oracle.  All rights reserved.

Last Successful login time: Thu May 22 2025 14:17:26 +09:00

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.26.0.0.0

SQL> SELECT table_name FROM user_tables;

TABLE_NAME
--------------------------------------------------------------------------------
DATA1
DATA2
SYS_EXPORT_SCHEMA_01
SYS_EXPORT_SCHEMA_02
SYS_EXPORT_TABLE_01

名前が SYS で始まるテーブルが Data Pump の管理テーブルです。Data Pump 管理テーブル作成まではうまくいっているようです。

トラブル対応

Database Vault のレルム保護対象ユーザーで Data Pump が実行できないのは標準仕様です。このため Data Pump の利用を許可する必要があります。DV_OWNER ロールユーザーで接続して DBMS_MACADM.AUTHORIZE_DATAPUMP_USER プロシージャを使って許可します。指定したユーザーは DBA_DV_DATAPUMP_AUTH ビューで確認できます。

Data Pump の許可
$ sqlplus c##dvowner/{Password}@pdb1

SQL*Plus: Release 19.0.0.0.0 - Production on Fri May 23 09:04:51 2025
Version 19.26.0.0.0

Copyright (c) 1982, 2024, Oracle.  All rights reserved.

Last Successful login time: Thu May 22 2025 14:15:55 +09:00

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.26.0.0.0

SQL> EXECUTE DBMS_MACADM.AUTHORIZE_DATAPUMP_USER('USER1');

PL/SQL procedure successfully completed.

SQL> SELECT * FROM dba_dv_datapump_auth;

GRANTEE              SCHEMA               OBJECT     TYPE       ACTION
-------------------- -------------------- ---------- ---------- ------------------------------
USER1                %                    %          %          %

SQL> Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.26.0.0.0

Data Pump が無事実行できるようになります。

Data Pump の成功
$ expdp userid=user1/{Passowrd}@pdb1 dumpfile=data1.dmp tables=data1 directory=data_pump_dir

Export: Release 19.0.0.0.0 - Production on Fri May 23 09:05:41 2025
Version 19.26.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Starting "USER1"."SYS_EXPORT_TABLE_01":  userid=user1/********@pdb1 dumpfile=data11.dmp tables=data1 directory=data_pump_dir
ORA-39327: Oracle Database Vault data is being stored unencrypted in dump file set.
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
. . exported "USER1"."DATA1"                             141.9 KB   10000 rows
Master table "USER1"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for USER1.SYS_EXPORT_TABLE_01 is:
  /u01/app/oracle/admin/O19A/dpdump/3499FF9608B0ADA5E0655AD221C7892D/data11.dmp
Job "USER1"."SYS_EXPORT_TABLE_01" completed with 1 error(s) at Fri May 23 09:05:52 2025 elapsed 0 00:00:10

$

マニュアル: Oracle Database 19c Database Vault 管理者ガイド

Author: Noriyoshi Shinoda / Date: June 3, 2025

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?