La versatilidad de DataPump comprende muchos beneficios, siendo los más interesantes:
- Respaldos de instancias completas (respaldo full DB)
- Respaldos de esquemas completos (respaldo full esquema)
- Respaldos de esquema con algunas tablas (respaldo selectivo de esquema).
A continuación realizaremos algunas experiencias que nos ayudarán a entender y manejar este utilitario.
Configurar Datapump:
Para utilizar datapump es necesario configurar los siguientes items:- usuario de exportación/importacion.
- directorio de respaldo donde se alojarán los archivos contenedores de la data de la BD.
- asociación de usuario con directorio de respaldo.
Creación de usuario de exportación/importacion.
se crea el usuario datapump. Para el ejemplo se usa el nombre "respaldo".Observar que entre los privilegios se encuentra "grant exp_full_database". Este es el más importante puesto que permite al usuario ejecutar las operaciones de respaldo sobre la BD.
$sqlplus "/as sysdba"
SQL> @create_user_respaldo.sql
script create_user_respaldo.sql
create user respaldo
identified by respaldo1
default tablespace USERS
temporary tablespace TEMP
profile DEFAULT
/
-- Grant/Revoke role privileges
grant connect to respaldo;
grant resource to respaldo;
grant unlimited tablespace to respaldo;
grant exp_full_database to respaldo;
/
Creación directorio de respaldo.
se crea el directorio de respaldo. Para el ejemplo se usa el nombre "DIR_RESPALDO". Se debe crear primero el FileSystem y que posea una capacidad dimensionada a los respaldos que se van a realizar.SQL> create or replace directory DIR_RESPALDO as '/DATA/respaldos';
Asociación de usuario con directorio de respaldo.
Se otorgan los privilegios al usuario para que realice las operaciones sobre el directorio de respaldo.SQL>grant read, write on directory DIR_RESPALDO to PUBLIC;
SQL>grant read, write on directory DIR_RESPALDO to respaldo;
Una vez que se configurado el usuario y el directorio, la BD se encuentra configurada para realizar operaciones de respaldo con los utilitarios expdp/impdp.
Taller 1: respaldo full BD.
La siguiente experiencia consiste en exportar a un archivo una instancia de BD completa.$ expdp respaldo/respaldo1 FULL=y DIRECTORY=dir_respaldo DUMPFILE=dpfull.20130129.dmp LOGFILE=dpfullexp.20130129.log JOB_NAME=dpfullJob.20130129
Donde los parametros:
FULL=y significa respaldo full a la instancia de BD
DIRECTORY=dir_respaldo indica el directorio de respaldo adonde se generan los archivos de respaldo.
DUMPFILE=dpfull.20130129.dmp indica el nombre del archivo de respaldo.
LOGFILE=dpfullexp.20130129.log indica el log de operaciones del utilitario de respaldo.
JOB_NAME=dpfullJob.20130129 indica el nombre del job para el monitoreo del proceso en el motor de datos. Si no se especifica este parametro se genera un nombre aleatorio.
Monitoreo de job.
Mientras se genera la operación exportar/importar es posible monitroear el proceso dentro del motor de BD a través de la vista dba_datapump_jobs:Al comenzar el respaldo
SQL>select * from dba_datapump_jobs;
OWNER_NAME JOB_NAME OPERATION JOB_MODE STATE DEGREE ATTACHED_SESSIONS DATAPUMP_SESSIONS
------------------------------ ------------------------------ ------------------------------ ------------------------------ ------------------------------ ---------- ----------------- -----------------
RESPALDO dpfullJob.20130129 EXPORT FULL UNDEFINED 0 1 1
durante el respaldo
OWNER_NAME JOB_NAME OPERATION JOB_MODE STATE DEGREE ATTACHED_SESSIONS DATAPUMP_SESSIONS
------------------------------ ------------------------------ ------------------------------ ------------------------------ ------------------------------ ---------- ----------------- -----------------
RESPALDO dpfullJob.20130129 EXPORT FULL EXECUTING 1 1 3
Al terminar el respaldo el job se elimina automáticamente del motor RDBMS
SQL> select * from dba_datapump_jobs;
no rows selected
SQL>
SQL> select * from dba_datapump_jobs;
no rows selected
SQL>
La consola muestra la siguiente info en la generación del respaldo full:
Export: Release 10.2.0.4.0 - 64bit Production on Wednesday, 30 January, 2013 9:47:46
Copyright (c) 2003, 2007, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "RESPALDO"."dpfullJob.20130130": respaldo/******** FULL=y DIRECTORY=dir_respaldo DUMPFILE=dpfull.20130130.dmp LOGFILE=dpfullexp.20130130.log JOB_NAME=dpfullJob.20130130
Estimate in progress using BLOCKS method...
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 40.52 GB
Processing object type DATABASE_EXPORT/TABLESPACE
Processing object type DATABASE_EXPORT/PROFILE
Processing object type DATABASE_EXPORT/SYS_USER/USER
Processing object type DATABASE_EXPORT/SCHEMA/USER
Processing object type DATABASE_EXPORT/ROLE
Processing object type DATABASE_EXPORT/GRANT/SYSTEM_GRANT/PROC_SYSTEM_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/GRANT/SYSTEM_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/ROLE_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/DEFAULT_ROLE
Processing object type DATABASE_EXPORT/SCHEMA/TABLESPACE_QUOTA
Processing object type DATABASE_EXPORT/RESOURCE_COST
Processing object type DATABASE_EXPORT/TRUSTED_DB_LINK
Processing object type DATABASE_EXPORT/SCHEMA/SEQUENCE/SEQUENCE
Processing object type DATABASE_EXPORT/SCHEMA/SEQUENCE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type DATABASE_EXPORT/DIRECTORY/DIRECTORY
Processing object type DATABASE_EXPORT/DIRECTORY/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type DATABASE_EXPORT/DIRECTORY/GRANT/CROSS_SCHEMA/OBJECT_GRANT
Processing object type DATABASE_EXPORT/CONTEXT
Processing object type DATABASE_EXPORT/SCHEMA/PUBLIC_SYNONYM/SYNONYM
Processing object type DATABASE_EXPORT/SCHEMA/SYNONYM
Processing object type DATABASE_EXPORT/SCHEMA/TYPE/TYPE_SPEC
Processing object type DATABASE_EXPORT/SYSTEM_PROCOBJACT/PRE_SYSTEM_ACTIONS/PROCACT_SYSTEM
Processing object type DATABASE_EXPORT/SYSTEM_PROCOBJACT/PROCOBJ
Processing object type DATABASE_EXPORT/SYSTEM_PROCOBJACT/POST_SYSTEM_ACTIONS/PROCACT_SYSTEM
Processing object type DATABASE_EXPORT/SCHEMA/PROCACT_SCHEMA
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/PRE_TABLE_ACTION
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/GRANT/CROSS_SCHEMA/OBJECT_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/INDEX
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/CONSTRAINT/CONSTRAINT
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/COMMENT
Processing object type DATABASE_EXPORT/SCHEMA/PACKAGE/PACKAGE_SPEC
Processing object type DATABASE_EXPORT/SCHEMA/PACKAGE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/FUNCTION/FUNCTION
Processing object type DATABASE_EXPORT/SCHEMA/PROCEDURE/PROCEDURE
Processing object type DATABASE_EXPORT/SCHEMA/PROCEDURE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/FUNCTION/ALTER_FUNCTION
Processing object type DATABASE_EXPORT/SCHEMA/PROCEDURE/ALTER_PROCEDURE
Processing object type DATABASE_EXPORT/SCHEMA/VIEW/VIEW
Processing object type DATABASE_EXPORT/SCHEMA/VIEW/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/VIEW/GRANT/CROSS_SCHEMA/OBJECT_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/VIEW/COMMENT
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type DATABASE_EXPORT/SCHEMA/PACKAGE_BODIES/PACKAGE/PACKAGE_BODY
Processing object type DATABASE_EXPORT/SCHEMA/TYPE/TYPE_BODY
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/FUNCTIONAL_AND_BITMAP/INDEX
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/STATISTICS/FUNCTIONAL_AND_BITMAP/INDEX_STATISTICS
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/POST_TABLE_ACTION
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TRIGGER
Processing object type DATABASE_EXPORT/SCHEMA/VIEW/TRIGGER
Processing object type DATABASE_EXPORT/SCHEMA/JOB
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/POST_INSTANCE/PROCACT_INSTANCE
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/POST_INSTANCE/PROCDEPOBJ
Processing object type DATABASE_EXPORT/SCHEMA/POST_SCHEMA/PROCOBJ
Processing object type DATABASE_EXPORT/SCHEMA/POST_SCHEMA/PROCACT_SCHEMA
. . exported "SYSTEM"."DEF$_AQCALL" 0 KB 0 rows
. . exported "SYSTEM"."DEF$_AQERROR" 0 KB 0 rows
. . exported "SYSTEM"."DEF$_CALLDEST" 0 KB 0 rows
. . exported "SYSTEM"."DEF$_DEFAULTDEST" 0 KB 0 rows
. . exported "SYSTEM"."DEF$_DESTINATION" 0 KB 0 rows
. . exported "SYSTEM"."DEF$_ERROR" 0 KB 0 rows
. . exported "SYSTEM"."DEF$_LOB" 0 KB 0 rows
. . exported "SYSTEM"."DEF$_ORIGIN" 0 KB 0 rows
. . exported "SYSTEM"."DEF$_PROPAGATOR" 0 KB 0 rows
. . exported "SYSTEM"."DEF$_PUSHED_TRANSACTIONS" 0 KB 0 rows
. . exported "SYSTEM"."DEF$_TEMP$LOB" 0 KB 0 rows
. . exported "SYSTEM"."LOGSTDBY$APPLY_MILESTONE" 0 KB 0 rows
. . exported "SYSTEM"."LOGSTDBY$APPLY_PROGRESS":"P0" 0 KB 0 rows
. . exported "SYSTEM"."LOGSTDBY$EVENTS" 0 KB 0 rows
. . exported "SYSTEM"."LOGSTDBY$HISTORY" 0 KB 0 rows
. . exported "SYSTEM"."LOGSTDBY$PARAMETERS" 0 KB 0 rows
. . exported "SYSTEM"."LOGSTDBY$PLSQL" 0 KB 0 rows
. . exported "SYSTEM"."LOGSTDBY$SCN" 0 KB 0 rows
. . exported "SYSTEM"."LOGSTDBY$SKIP" 0 KB 0 rows
. . exported "SYSTEM"."LOGSTDBY$SKIP_TRANSACTION" 0 KB 0 rows
. . exported "SYSTEM"."MD_USERS" 0 KB 0 rows
. . exported "SYSTEM"."MVIEW$_ADV_INDEX" 0 KB 0 rows
. . exported "SYSTEM"."MVIEW$_ADV_PARTITION" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_AUDIT_COLUMN" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_COLUMN_GROUP" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_CONFLICT" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_DDL" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_EXCEPTIONS" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_EXTENSION" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_FLAVORS" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_FLAVOR_OBJECTS" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_GENERATED" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_GROUPED_COLUMN" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_INSTANTIATION_DDL" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_KEY_COLUMNS" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_OBJECT_PARMS" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_PARAMETER_COLUMN" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_PRIORITY" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_PRIORITY_GROUP" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_REFRESH_TEMPLATES" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_REPCAT" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_REPCATLOG" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_REPCOLUMN" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_REPGROUP_PRIVS" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_REPOBJECT" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_REPPROP" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_REPSCHEMA" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_RESOLUTION" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_RESOLUTION_STATISTICS" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_RESOL_STATS_CONTROL" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_RUNTIME_PARMS" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_SITES_NEW" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_SITE_OBJECTS" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_SNAPGROUP" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_TEMPLATE_OBJECTS" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_TEMPLATE_PARMS" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_TEMPLATE_REFGROUPS" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_TEMPLATE_SITES" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_TEMPLATE_TARGETS" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_USER_AUTHORIZATIONS" 0 KB 0 rows
. . exported "SYSTEM"."REPCAT$_USER_PARM_VALUES" 0 KB 0 rows
. . exported "SYSTEM"."SQLPLUS_PRODUCT_PROFILE" 0 KB 0 rows
. . exported "TSMSYS"."SRS$" 0 KB 0 rows
Master table "RESPALDO"."dpfullJob.20130130" successfully loaded/unloaded
******************************************************************************
Dump file set for RESPALDO.dpfullJob.20130130 is:
/DATA/respaldos/dpfull.20130130.dmp
Job "RESPALDO"."dpfullJob.20130130" successfully completed at 10:16:34
finalmente observamos que en el directorio /data/respaldos se ha generado el archivo de respaldo y el log:
[oracle@QUICO respaldos]$ du -h *
34G dpfull.20130129.dmp
76K dpfullexp.20130129.log
[oracle@QUICO respaldos]$
fuentes de consulta:
http://www.oracle-base.com/articles/10g/oracle-data-pump-10g.php
http://cajondesastreoracle.wordpress.com/2010/08/04/data-pump-versus-import-export/
No hay comentarios:
Publicar un comentario