2 利用db link迁移数据库:参数 network_link

2 利用db link迁移数据库:参数 network_link
  impdp+network link 跳过expdp直接导入目标库:
 示例:
实验环境:linux下11G,一式两份 (手头只有11G虚拟机)
要点:需要用到监听,以下是源库的 监听信息和 目标库的tnsname信息


源库  listener.ora:
[oracle@primary admin]$ cat l*
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2/network/admin/listener.ora
# Generated by Oracle configuration tools.


SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/app/oracle/product/11.2)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = orcl)
      (ORACLE_HOME = /u01/app/oracle/product/11.2)
      (SID_NAME = orcl)
    )
  )


LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = primary)(PORT = 1521))
    )
  )


源库
[oracle@primary admin]$ lsnrctl status


LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 24-OCT-2011 10:52:07


Copyright (c) 1991, 2009, Oracle.  All rights reserved.


Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=primary)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                24-OCT-2011 09:55:14
Uptime                    0 days 0 hr. 56 min. 54 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/primary/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=primary)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).
  Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
Service "orclXDB.demo" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "primary.demo" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully




目标库   tnsname.ora
[oracle@standby admin]$ cat t*
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.


PRIMARY =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.111)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )


--service_name里的orcl对应 源库lsnrctl status 是显示的instance名字


配置好监听和tnsnames后步骤:


源库:创建测试用表
SQL> conn system/zzzzzz;
SQL> create table test123 (id number(9));


Table created.


SQL> commit;


Commit complete.




目标库:
SQL> create public database link test111  connect to system identified by zzzzzz using 'PRIMARY';
 
--test123为自定义的link 名字
--using ''内的 primary是对应tnsname里的tnsname


目标库:
[oracle@standby admin]$ impdp system/zzzzzz  network_link=test111 schemas=system;
即 将原库 system用户下信息导入目标库 system用户下,
如果是异用户,参考:
impdp system/zzzzzz  network_link=test111 schemas=user1  remap_schema=user1:user2


以下为impdp过程中的日志信息,比较多,贴了一部分
Import: Release 11.2.0.1.0 - Production on Mon Oct 24 10:22:50 2011


Copyright (c) 1982, 2009, Oracle and/or its affiliates.  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
FLASHBACK automatically enabled to preserve database integrity.
Starting "SYSTEM"."SYS_IMPORT_SCHEMA_01":  system/******** network_link=test123 schemas=system
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 384 KB
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/SYNONYM/SYNONYM
ORA-31684: Object type SYNONYM:"SYSTEM"."PUBLICSYN" already exists
ORA-31684: Object type SYNONYM:"SYSTEM"."PRODUCT_USER_PROFILE" already exists
Processing object type SCHEMA_EXPORT/TYPE/TYPE_SPEC
ORA-31684: Object type TYPE:"SYSTEM"."REPCAT$_OBJECT_NULL_VECTOR" already exists
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE
ORA-31684: Object type SEQUENCE:"SYSTEM"."REPCAT$_USER_PARM_VALUES_S" already exists


ORA-31684: Object type SEQUENCE:"SYSTEM"."MVIEW$_ADVSEQ_GENERIC" already exists
Processing object type SCHEMA_EXPORT/TABLE/TABLE
ORA-39151: Table "SYSTEM"."DEF$_ERROR" exists. All dependent metadata and data will be skipped due to table_exists_action of skip
skipped due to table_exists_action of skip
ORA-39151: Table "SYSTEM"."DEF$_ORIGIN" exists. All dependent metadata and data will be skipped due to table_exists_action of skip
due to table_exists_action of skip
Processing object type SCHEMA_EXPORT/TABLE/PRE_TABLE_ACTION
. . imported "SYSTEM"."TEST123"                               0 rows
. . imported "SYSTEM"."TESTIMPDP2"                            0 rows
Processing object type SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Job "SYSTEM"."SYS_IMPORT_SCHEMA_01" completed with 100 error(s) at 10:28:58


目标库:测试源库创建的test123表是否已经impdp到目标库上
SQL> conn system/zzzzzz;
Connected.
SQL> desc test123;
 Name                       Null?    Type
 ----------------------------------------- -------- ----------------------------
 ID                            NUMBER(9)




sccussfull!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
::fn_dblog 是一个用于分析 SQL Server 数据库事务日志的系统函数。事务日志是 SQL Server 中记录数据库操作的重要组成部分,包括对数据的插入、更新和删除等操作。 使用 ::fn_dblog 函数,我们可以查询事务日志中的信息,帮助我们了解数据库中发生的操作和恢复数据的过程。 这个函数可以通过传入不同的参数来过滤和查询日志中的信息。常见的参数包括起始日期、结束日期、操作类型等。根据查询结果,我们可以查看每个操作对应的日志记录,包括日志记录的类型、事务 ID、表名、行 ID、字段值等。 通过分析事务日志,我们可以追踪数据库中的数据变更历史,并且可以根据需要进行数据恢复或回滚操作。例如,当发生误删数据时,可以通过查询事务日志来找到被删除的数据,并将其恢复到之前的状态。同时,也可以通过分析事务日志,了解数据库中的操作情况,监控系统运行状况和性能。 然而,需要注意的是 ::fn_dblog 函数是一个系统函数,仅限于 SQL Server 系统级别的使用,普通用户无法直接调用。另外,在使用这个函数时,要谨慎操作,因为事务日志包含大量的信息,过度查询可能会对数据库性能产生影响。 总之,::fn_dblog 是 SQL Server 中的一个用于分析事务日志的系统函数,可以帮助我们追踪数据变更历史、恢复数据、监控系统运行情况等。在使用时,需要谨慎操作,避免对数据库性能造成影响。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值