正在阅读:Oracle数据库备份与恢复(1):exp和impOracle数据库备份与恢复(1):exp和imp

2009-06-12 09:45 出处:PConline 作者:网页教学网 责任编辑:lizhiyan

  三、优化

  1、加快exp速度

  加大large_pool_size,可以提高 exp的速度 采用直接路径的方式(direct=y),数据不需要经过内存进行整合和检查。 设置较大的 buffer,如果导出大对象,小buffer会失败。

  export文件不在ORACLE使用的驱动器上,不要export到NFS文件系统。

  UNIX环境:用管道模式直接导入导出来提高 imp/exp的性能

  2、加快imp速度

  建立一个indexfile,在数据 import完成后在建立索引将import文件放在不同的驱动器上增加 DB_BLOCK_BUFFERS增加 LOG_BUFFER

  用非归档方式运行 ORACLE:ALTER DATABASE NOARCHIVELOG; 建立大的表空间和回滚段,OFFLINE其他回滚段,回滚段的大小为最大表的 1/2 使用  COMMIT=N

  使用 ANALYZE=N

  单用户模式导入

  UNIX环境:用管道模式直接导入导出来提高 imp/exp的性能

  3、通过unix/Linux PIPE管道加快exp/imp速度

  通过管道导出数据:

  (1)通过 mknod -p 建立管道

  $ mknod /home/exppipe p    //  在目录/home下建立一个管道 exppipe注意参数 p

  (2)通过 exp和 gzip导出数据到建立的管道并压缩

  $ exp test/test file=/home/exppipe & gzip < /home/exppipe > exp.dmp.gz

  $ exp test/test tables=bitmap file=/home/newsys/test.pipe & gzip < /home/newsys/test.pipe > bitmap.dmp.gz

  (3)导出成功完成之后删除建立的管道

  $ rm    -rf    /home/exppipe

  导出脚本:

  ###UNIX下 ORACLE数据库通过 PIPE管道进行备份

  ###### using "export" and "tar" command to bakup oracle datebase #######

  trap "" 1 #nohup

  LOGFILE=/opt/bakup/log/bakup_ora.log

  export LOGFILE

  DUMPDIR=/archlog_node1

  export DUMPDIR

  exec >$LOGFILE 2>&1

  echo

  echo ' Begin at ' `date`

  echo

  #               clear old result file

  cd $DUMPDIR

  if [ -f exp.dmp.Z ]

  then echo "clear old result file"

  rm exp.dmp.Z

  fi

  #               make pipe

  mkfifo exp.pipe

  chmod a+rw exp.pipe

  #               gain the dmp.Z file

  compress < exp.pipe > exp.dmp.Z &

  su -u oracle -c "exp userid=ll/ll file=$DUMPDIR/exp.pipe full=y buffer=20000000"

  echo

  echo '    exp end at '`date`

   echo

  #               rm pipe

  rm exp.pipe

  #               tar the dmp.Z file to tape

  mt -f /dev/rmt/0 rew

  tar cvf /dev/rmt/0 exp.dmp.Z

  echo

  echo '    tar end at '`date`

  echo

  通过管道导入生成的文件

  (1)通过 mknod -p 建立管道

  $ mknod /home/exppipe p

  (2)导入生成的压缩文件

  $ imp test/test file=/home/exppipe fromuser=test touser=macro & gunzip < exp.dmp.gz > /home/exppipe

  (3)删除管道

  $ rm –fr /home/exppipe

  (4)全库导入的一般步骤

  注意:在导出时,需要通过toad或其他工具提取源数据库创建主键和索引的脚本

  (1)先全库加 rows=n 把结构导进去

  $ imp system/manager file=exp.dmp log=imp.log full=y rows=n indexes=n

  (2)使业务用户的触发器失效/删除主键和唯一索引

  spool drop_pk_u.sql

  select 'alter table '||table_name||' drop constraint '||constraint_name||';'

  from user_constraints

  where constraint_type in ('P','U');

  /

  spool off

  spool disable_trigger.sql

  select 'alter trigger '||trigger_name||' disable;'

  from user_triggers;

  /

  spool off

  @drop_pk_u.sql

  @disable_trigger.sql

  (3)以 ignore=y全库导入$ imp system/manager file=exp.dmp log=imp.log full=y ignore=y

  (4)通过 toad或其他工具提取源数据库创建主键和索引的脚本,在目标数据库中创建主键和索引。使触发器生效。

键盘也能翻页,试试“← →”键
本文导航
第1页:基本命令
第2页:高级选项
第3页:优化
第4页:常见问题

关注我们

最新资讯离线随时看 聊天吐槽赢奖品