Getting The Best Out of Data Pump
Getting The Best Out of Data Pump
Agenda
Moving large amounts of data with Transportable Tablespaces Filtering metadata using the INCLUDE and EXCLUDE parameters Restarting stopped/failed jobs Hear about Nokia Corporation's database environment How Nokia uses the REMAP_DATA parameter to scramble data How Nokia regenerates primary keys without having to use additional software or scripts
3
An Oracle Database feature that allows data file transfer from a database to another via a simple os copy and a light specific export/import Data Pump will move metadata only Data moves with data file copy Much faster than using direct path or external tables
Tablespaces need to be read only for duration of export and datafile copying. Not restartable Must be privileged account Notes: Use RMAN CONVERT to change endianness (if needed) Data Pump moves only metadata Can use network link For a full list of what is exported:
select unique seq_num, full_path from datapump_paths where het_type = 'TRANSPORTABLE_EXPORT order by seq_num;
Transportable Tablespaces Self Containment Check Create table part_tab(id number) tablespace a partition by range (id) (partition low value less than (100) tablespace b, partition hi values less than (1000) tablespace c); Create index part_ind on part_tab.id tablespace d; Transportable tablespace export requires all 4 tablespaces
(a, b, c, d)
Copy datafiles and dumpfiles to target system Optionally set tablespaces read write Target system tasks: Run impdp command Optionally set tablespaces to read write
9
Data Pump export will list tablespaces that need to be read only if not already done Data Pump export will list datafiles and dumpfiles that need to be copied to target Data Pump import can use filters dont have to import the complete dumpfile set Can import only one partition Data Pump creates a non-partitioned table Partition_options=departition creates nonpartitioned tables for every partition
10
Table filter needs to be complete tables or partitions from the same table ptab1,ptab2, etc or ptab1:lo,ptab1:hi ORA-29335: tablespace 'USER1' is not read only ORA-29335: tablespace 'USER2 is not read only Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is: /oracle/work/tab_tts.dmp Datafiles required for transportable tablespace USER1: /oracle/dbs/user1.f Datafiles required for transportable tablespace USER2: /oracle/dbs/user2.f
11
Creates all tablespaces even if no objects created due to import filters Cleans up any unused tablespace segments that are not imported
12
Filtering Metadata
13
Perform selective export/import job based on object type Exp/imp had limited filtering
Grants, index, triggers, statistics, constraints
14
15
Exclude Example:
expdp system/manager schema=hr exclude=statistics vs expdp system/manager schema=hr exclude= SCHEMA_EXPORT/TABLE/STATISTICS select unique seq_num, full_path from sys.datapump_paths where het_type = 'SCHEMA_EXPORT' AND full_path like '%STATISTICS% order by seq_num;
77 78 221 222 223 225 226 227 SCHEMA_EXPORT/TABLE/INDEX/STATISTICS SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS SCHEMA_EXPORT/TABLE/INDEX/STATISTICS SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/FUNCTIONAL_AND_BITMAP SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/FUNCTIONAL_AND_BITMAP/INDEX_STATISTICS SCHEMA_EXPORT/TABLE/STATISTICS SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS SCHEMA_EXPORT/TABLE/STATISTICS/USER_PREF_STATISTICS
16
Include Examples:
impdp system/manager tables=hr.employees vs impdp system/manager schemas=hr include=table:\"= \'EMPLOYEES\'\" Same results Includes all objects that have table in the path vs impdp system/manager schemas=hr include=table/table:\"= \'EMPLOYEES\'\ Only includes the table Some of the TABLE object paths
SCHEMA_EXPORT/TABLE/TABLE SCHEMA_EXPORT/TABLE/TABLE_DATA SCHEMA_EXPORT/TABLE/GRANT
17
18
Optionally change value of PARALLEL parameter Helps to know the job name
System generated job names SYS_IMPORT_FULL_01 SYS_EXPORT_TABLE_05
19
Restart command:
expdp system/manager attach=datapump_exp Export> start_job
Resets dumpfile pointers to last completed object type Restarts the job after the last completed object
20
21
22
Hear about Nokia Corporation's Database Environment and how they use Oracle Data Pump
Viljo Hakala (Nokia)
23
Nokia
Nokia is a world leader in mobility Head office in Finland; R&D, production, sales, marketing activities around the world Worlds #1 manufacturer of mobile devices, with estimated 40% share of global device market in 2009 Mobile device volumes 468 million units Net sales EUR 50.7 billion Operating profit EUR 5.0 billion 128 445 employees at year end (including Nokia Siemens Networks) Strong R&D presence in 16 countries R&D investment EUR 6.0 billion Sales in more than 150 countries
24 24
Oracle @ Nokia
20 DBAs, 2300 databases Grid Control: used for almost 5 years, #1 tool for all DBAs Applications: OLTP: 50%, Hybrid databases: 40%, DW: 10% + Teradata About 1800+ Oracle; also MySQL 200+, MS SQL 300+ 11g: 4% 10g: 80% 9i: 15% 8i: 1% Host platforms: Solaris: 35% HP-UX: 35% Linux: 20% Windows 10%
25 25
Oracle @ Nokia
Production databases: single, HA Oracle, RAC, HA MySQL 5 MB 7 TB range Leverage virtually all Oracle database features DBAs share responsibilities Many federated databases: Streams, Advanced Replication, Materialized views, DB links Common Oracle platform, Common MySQL platform and Common MS SQL platform 99% of databases backed up with RMAN 8 RMAN catalog databases 10 PB+ backed up / month
26 26
27 27
28
29 29
For example, a column with phone numbers could be replaced by a numbers generated by a REMAP_DATA function.
30 30
To mask multiple columns in the same process and command, the REMAP_DATA parameter can be used multiple times.
31 31
32 32
33 33
34 34
35 35
The function masknumber will accept a varchar2 type and returns a random phone number in varchar2 type
By default the owner of the remap function is the user running expdp/impdp
Now the dumpfile phones_masked.dmp can be used for testing environments
37 37
38 38
39 39
40 40
41 41
42 42
43
Oracle Advanced Security Option for encrypting data at tablespace or column level.
Oracle Label Security for restricting access to data based on policies. Oracle Database Vault for separating roles and restricting access to data per roles.
44
Security for data is not just Obscurity. It is a process and requires time.
45 45
Filtering metadata using the INCLUDE and EXCLUDE parameters Restarting stopped/failed jobs REMAP_DATA parameter to scramble data How to generate primary keys without having to use additional software or scripts
46
Questions?
47
48
49