ITPub博客

首页 > 数据库 > Oracle > [20140827]imp exp 使用管道迁移数据.txt

[20140827]imp exp 使用管道迁移数据.txt

原创 Oracle 作者:lfree 时间:2014-08-28 10:59:18 0 删除 编辑

[20140827]imp exp 使用管道迁移数据.txt

--最近帮别人升级一套数据库,9i到11g.
--那个慢真让人受不了,也许是以前的老机器性能不行.数据量并不大.导出花了时间比较长.

--我很久就知道导出可以管道压缩导出文件,实现一边导出一边压缩的功能,现在硬盘空间都很大,很少考虑这种方式.
--而且现在很少使用这种方式备份数据.

--是否可以使用管道实现一边导出一边导入呢?这样可以节约时间,我做了一个测试:
--全部操作都在目的端进行,主要是exp/imp版本问题(烦),操作系统都是linux。

1.首先测试是否不用管道是否正常使用:

exp system/xxxx file=ticd10.dmp tables=icare.ticd10  buffer=20971520 consistent=y log=ticd10_exp.log direct=y triggers=n
imp scott/btbtms@192.168.100.40/test.com file=ticd10.dmp tables=ticd10 buffer=20971520 commit=y log=ticd10_imp.log fromuser=icare touser=scott

--测试通过!为了后面的验证,改名表,删除索引以及约束等信息。
alter table ticd10 rename to ticd10_org;


2.建立shell脚本:

$ cat ./play_pipe.sh
#! /bin/bash
mknod exp_pipe p
mknod imp_pipe p
exp system/xxxx file=exp_pipe tables=icare.ticd10  buffer=20971520 consistent=y log=ticd10_exp.log direct=y triggers=n &
sleep 1
dd bs=1M if=exp_pipe of=imp_pipe &
sleep 1
imp scott/btbtms@192.168.100.40/test.com file=imp_pipe tables=ticd10 buffer=20971520 commit=y log=ticd10_imp.log fromuser=icare touser=scott &

chmod 755 play_pipe.sh
./play_pipe.sh  > /dev/null 2>&1

--说明: 加入>/dev/null 2>&1后面的参数,主要避免显示界面太乱了。

3.验证数据是否正确:
--检查导出日志正常!检查数据看看。

SCOTT@test> select count(*) from ticd10_org ;
  COUNT(*)
----------
     24177

SCOTT@test> select count(*) from ticd10 ;
  COUNT(*)
----------
     24177

SCOTT@test> select * from ticd10 minus select * from ticd10_org;
no rows selected

SCOTT@test> select * from ticd10_org minus select * from ticd10;
no rows selected

SCOTT@test> analyze table scott.ticd10 validate structure;
Table analyzed.

SCOTT@test> analyze table scott.ticd10_org validate structure;
Table analyzed.

--没有数据丢失,说明是可行。

4.总结:
--测试说明以上方法是可行的。没有做大规模的测试,真不敢在迁移中使用。
--真正迁移使用,估计自己也不敢用,保险还是选择传统的方式。仅仅为了学习的需要,做了这个测试。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-1259389/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4006
  • 访问量
    7971771