dg备库怎么逻辑导出exp/expdp?

以下技能在备库部署ogg初始化时可用到。

exp可直接执行:

exp jyc/jyc@pdbdgorcl buffer=409600000 file=dg_jyc.dmp log=dg_jyc.log owner=jyc

[oracle@dgrac2 ~]$ exp jyc/jyc@pdbdgorcl buffer=409600000 file=dg_jyc.dmp log=dg_jyc.log owner=jyc

Export: Release 19.0.0.0.0 - Production on Wed Feb 16 09:52:56 2022
Version 19.5.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.5.0.0.0
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified users ...
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user JYC 
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions for user JYC 
About to export JYC's objects ...
. exporting database links
. exporting sequence numbers
. exporting cluster definitions
. about to export JYC's tables via Conventional Path ...
. . exporting table                           TEST          2 rows exported
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting referential integrity constraints
. exporting triggers
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting materialized views
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting statistics
Export terminated successfully without warnings.

expdp需通过主库或其它库的network_link方式导出

expdp jyc/jyc@pdborcl network_link=expdp_primary directory=dmp schemas=JYC dumpfile=dg_jyc.dmp logfile=dg_jyc.log cluster=n exclude=statistics

备库操作报错如下:

[oracle@dgrac1 trace]$ expdp jyc/jyc@pdbdgorcl directory=dmp schemas=JYC dumpfile=dg_jyc.dmp logfile=dg_jyc.log cluster=n exclude=statistics

Export: Release 19.0.0.0.0 - Production on Wed Feb 16 09:42:03 2022
Version 19.5.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-31626: job does not exist
ORA-31633: unable to create master table "JYC.SYS_EXPORT_SCHEMA_05"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.KUPV$FT", line 1163
ORA-16000: database or pluggable database open for read-only access
ORA-06512: at "SYS.KUPV$FT", line 1056
ORA-06512: at "SYS.KUPV$FT", line 1044

主库操作:(主备库先创建好dmp目录)

[oracle@rac1 ~]$ sqlplus jyc/jyc@pdborcl

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Feb 16 09:32:25 2022
Version 19.5.0.0.0

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


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

SQL> select table_name from user_tables;

no rows selected

SQL> create table test (id int);

Table created.

SQL> insert into test values(1);

1 row created.

SQL> insert into test values(2);

1 row created.

SQL> commit;

Commit complete.

SQL> set line 130
SQL> set wrap off
SQL> col DIRECTORY_NAME for a30
SQL> select * from dba_directories;
rows will be truncated


OWNER DIRECTORY_NAME                 DIRECTORY_PATH
----- ------------------------------ ---------------------------------------------------------------------------------------------
SYS   SDO_DIR_WORK
SYS   SDO_DIR_ADMIN                  /oracle/app/oracle/product/19c/dbhome_1/md/admin
SYS   XMLDIR                         /oracle/app/oracle/product/19c/dbhome_1/rdbms/xml
SYS   XSDDIR                         /oracle/app/oracle/product/19c/dbhome_1/rdbms/xml/schema
SYS   OPATCH_INST_DIR                /oracle/app/oracle/product/19c/dbhome_1/OPatch
SYS   ORACLE_OCM_CONFIG_DIR2         /oracle/app/oracle/product/19c/dbhome_1/ccr/state
SYS   ORACLE_BASE                    /oracle/app/oracle
SYS   ORACLE_HOME                    /oracle/app/oracle/product/19c/dbhome_1
SYS   ORACLE_OCM_CONFIG_DIR          /oracle/app/oracle/product/19c/dbhome_1/ccr/state
SYS   DATA_PUMP_DIR                  /oracle/app/oracle/product/19c/dbhome_1/rdbms/log/A0044C1C44692EE6E0539634A8C0A37C
SYS   DBMS_OPTIM_LOGDIR              /oracle/app/oracle/product/19c/dbhome_1/cfgtoollogs

OWNER DIRECTORY_NAME                 DIRECTORY_PATH
----- ------------------------------ ---------------------------------------------------------------------------------------------
SYS   DBMS_OPTIM_ADMINDIR            /oracle/app/oracle/product/19c/dbhome_1/rdbms/admin
SYS   OPATCH_SCRIPT_DIR              /oracle/app/oracle/product/19c/dbhome_1/QOpatch
SYS   OPATCH_LOG_DIR                 /oracle/app/oracle/product/19c/dbhome_1/rdbms/log
SYS   JAVA$JOX$CUJS$DIRECTORY$       /oracle/app/oracle/product/19c/dbhome_1/javavm/admin/

15 rows selected.

SQL> !mkdir -p /oracle/app/oracle/dmp

SQL> create directory dmp as '/oracle/app/oracle/dmp';
grant read,write on directory dmp to public;

Directory created.

SQL> 
Grant succeeded.

此处开始备库操作:先取消同步,这样备库数据不变情况下导出对比主库新增记录的情况:

[oracle@dgrac1 trace]$ dgmgrl sys/oracle@dgorcl
DGMGRL for Linux: Release 19.0.0.0.0 - Production on Wed Feb 16 09:43:20 2022
Version 19.5.0.0.0

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

Welcome to DGMGRL, type "help" for information.
Connected to "dgorcl"
Connected as SYSDBA.

DGMGRL> show CONFIGURATION;

Configuration - adg

  Protection Mode: MaxPerformance
  Members:
  orcl   - Primary database
    dgorcl - Physical standby database 

Fast-Start Failover:  Disabled

Configuration Status:
SUCCESS   (status updated 11 seconds ago)

DGMGRL> show database verbose dgorcl

Database - dgorcl

  Role:               PHYSICAL STANDBY
  Intended State:     APPLY-ON
  Transport Lag:      0 seconds (computed 0 seconds ago)
  Apply Lag:          0 seconds (computed 0 seconds ago)
  Average Apply Rate: 42.00 KByte/s
  Active Apply Rate:  1.45 MByte/s
  Maximum Apply Rate: 1.63 MByte/s
  Real Time Query:    ON
  Instance(s):
    orcl1
    orcl2 (apply instance)

  Properties:
    DGConnectIdentifier             = 'dgorcl'
    ObserverConnectIdentifier       = ''
    FastStartFailoverTarget         = ''
    PreferredObserverHosts          = ''
    LogShipping                     = 'ON'
    RedoRoutes                      = ''
    LogXptMode                      = 'ASYNC'
    DelayMins                       = '0'
    Binding                         = 'optional'
    MaxFailure                      = '0'
    ReopenSecs                      = '300'
    NetTimeout                      = '30'
    RedoCompression                 = 'DISABLE'
    PreferredApplyInstance          = ''
    ApplyInstanceTimeout            = '0'
    ApplyLagThreshold               = '30'
    TransportLagThreshold           = '30'
    TransportDisconnectedThreshold  = '30'
    ApplyParallel                   = 'AUTO'
    ApplyInstances                  = '0'
    StandbyFileManagement           = ''
    ArchiveLagTarget                = '0'
    LogArchiveMaxProcesses          = '0'
    LogArchiveMinSucceedDest        = '0'
    DataGuardSyncLatency            = '0'
    LogArchiveTrace                 = '0'
    LogArchiveFormat                = ''
    DbFileNameConvert               = ''
    LogFileNameConvert              = ''
    ArchiveLocation                 = ''
    AlternateLocation               = ''
    StandbyArchiveLocation          = ''
    StandbyAlternateLocation        = ''
    InconsistentProperties          = '(monitor)'
    InconsistentLogXptProps         = '(monitor)'
    LogXptStatus                    = '(monitor)'
    SendQEntries                    = '(monitor)'
    RecvQEntries                    = '(monitor)'
    HostName(*)
    StaticConnectIdentifier(*)
    TopWaitEvents(*)
    SidName(*)
    (*) - Please check specific instance for the property value

  Log file locations(*):
    (*) - Check specific instance for log file locations.

Database Status:
SUCCESS

DGMGRL> edit database 'dgorcl' set state='apply-off';
Succeeded.
DGMGRL> show database verbose dgorcl

Database - dgorcl

  Role:               PHYSICAL STANDBY
  Intended State:     APPLY-OFF
  Transport Lag:      0 seconds (computed 1 second ago)
  Apply Lag:          12 seconds (computed 1 second ago)
  Average Apply Rate: (unknown)
  Active Apply Rate:  (unknown)
  Maximum Apply Rate: (unknown)
  Real Time Query:    OFF
  Instance(s):
    orcl1
    orcl2 (apply instance)

  Properties:
    DGConnectIdentifier             = 'dgorcl'
    ObserverConnectIdentifier       = ''
    FastStartFailoverTarget         = ''
    PreferredObserverHosts          = ''
    LogShipping                     = 'ON'
    RedoRoutes                      = ''
    LogXptMode                      = 'ASYNC'
    DelayMins                       = '0'
    Binding                         = 'optional'
    MaxFailure                      = '0'
    ReopenSecs                      = '300'
    NetTimeout                      = '30'
    RedoCompression                 = 'DISABLE'
    PreferredApplyInstance          = ''
    ApplyInstanceTimeout            = '0'
    ApplyLagThreshold               = '30'
    TransportLagThreshold           = '30'
    TransportDisconnectedThreshold  = '30'
    ApplyParallel                   = 'AUTO'
    ApplyInstances                  = '0'
    StandbyFileManagement           = ''
    ArchiveLagTarget                = '0'
    LogArchiveMaxProcesses          = '0'
    LogArchiveMinSucceedDest        = '0'
    DataGuardSyncLatency            = '0'
    LogArchiveTrace                 = '0'
    LogArchiveFormat                = ''
    DbFileNameConvert               = ''
    LogFileNameConvert              = ''
    ArchiveLocation                 = ''
    AlternateLocation               = ''
    StandbyArchiveLocation          = ''
    StandbyAlternateLocation        = ''
    InconsistentProperties          = '(monitor)'
    InconsistentLogXptProps         = '(monitor)'
    LogXptStatus                    = '(monitor)'
    SendQEntries                    = '(monitor)'
    RecvQEntries                    = '(monitor)'
    HostName(*)
    StaticConnectIdentifier(*)
    TopWaitEvents(*)
    SidName(*)
    (*) - Please check specific instance for the property value

  Log file locations(*):
    (*) - Check specific instance for log file locations.

Database Status:
SUCCESS

DGMGRL> show database dgorcl

Database - dgorcl

  Role:               PHYSICAL STANDBY
  Intended State:     APPLY-OFF
  Transport Lag:      0 seconds (computed 0 seconds ago)
  Apply Lag:          24 seconds (computed 0 seconds ago)
  Average Apply Rate: (unknown)
  Real Time Query:    OFF
  Instance(s):
    orcl1
    orcl2 (apply instance)

Database Status:
SUCCESS

DGMGRL> 

此处开始主库操作:主库增加3条记录,这样主库是5条,备库是2条

SQL> 
SQL> insert into test values(3);

1 row created.

SQL> insert into test values(4);

1 row created.

SQL> insert into test values(5);

1 row created.

SQL> commit;

Commit complete.

SQL> create database link expdp_primary connect to jyc identified by jyc using 'pdbdgorcl';

Database link created.

SQL> select db_unique_name from v$database;

DB_UNIQUE_NAME
------------------------------
orcl

SQL> select db_unique_name from v$database@expdp_primary;

DB_UNIQUE_NAME
------------------------------
dgorcl

SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.5.0.0.0
[oracle@rac1 ~]$ expdp jyc/jyc@pdborcl network_link=expdp_primary directory=dmp schemas=JYC dumpfile=dg_jyc.dmp logfile=dg_jyc.log cluster=n exclude=statistics

Export: Release 19.0.0.0.0 - Production on Wed Feb 16 09:49:45 2022
Version 19.5.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
FLASHBACK automatically enabled to preserve database integrity.
Starting "JYC"."SYS_EXPORT_SCHEMA_01":  jyc/********@pdborcl network_link=expdp_primary directory=dmp schemas=JYC dumpfile=dg_jyc.dmp logfile=dg_jyc.log cluster=n exclude=statistics 
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
. . exported "JYC"."TEST"                                  5.5 KB       2 rows
Master table "JYC"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for JYC.SYS_EXPORT_SCHEMA_01 is:
  /oracle/app/oracle/dmp/dg_jyc.dmp
Job "JYC"."SYS_EXPORT_SCHEMA_01" successfully completed at Wed Feb 16 09:50:33 2022 elapsed 0 00:00:39

[oracle@rac1 ~]$ expdp jyc/jyc@pdborcl directory=dmp schemas=JYC dumpfile=pri_jyc.dmp logfile=pri_jyc.log cluster=n exclude=statistics

Export: Release 19.0.0.0.0 - Production on Wed Feb 16 09:50:58 2022
Version 19.5.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
FLASHBACK automatically enabled to preserve database integrity.
Starting "JYC"."SYS_EXPORT_SCHEMA_01":  jyc/********@pdborcl directory=dmp schemas=JYC dumpfile=pri_jyc.dmp logfile=pri_jyc.log cluster=n exclude=statistics 
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/DB_LINK
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
. . exported "JYC"."TEST"                                5.093 KB       5 rows
Master table "JYC"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for JYC.SYS_EXPORT_SCHEMA_01 is:
  /oracle/app/oracle/dmp/pri_jyc.dmp
Job "JYC"."SYS_EXPORT_SCHEMA_01" successfully completed at Wed Feb 16 09:51:54 2022 elapsed 0 00:00:48

相关参考:

【DG】怎么从Oracle备库导出数据_ITPUB博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值