在Unix上使用管道压缩exp导出文件

简介:
exp导出文件大到文件系统放不下怎么办? 在Unix上一种行之有效的解决方法是创建一个命名管道,因为exp的导出dumpfile的内容是顺序的,可以将其内容重定向到管道并对该管道实施压缩操作,从而实现其直接的导出文件就是压缩过的。下面我们举出一个使用该中管道压缩的例子:
[oracle@vrh1 exp]$ exp system/oracle  file=maclean.dmp tables=maclean.tv

Export: Release 10.2.0.4.0 - Production on Fri Apr 1 17:03:09 2011
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses WE8ISO8859P1 character set (possible charset conversion)
About to export specified tables via Conventional Path ...
Current user changed to MACLEAN
. . exporting table                             TV      19988 rows exported
Export terminated successfully without warnings.

/* 不压缩情况下本例中的dumpfile大小为2MB  */

[oracle@vrh1 exp]$ ls -lh maclean.dmp
-rw-r--r-- 1 oracle oinstall 2.0M Apr  1 17:03 maclean.dmp

/* 首先使用mknod命令创建命名管道 */

[oracle@vrh1 exp]$ mknod macleanpipe p

/*使用nohup命令在后台执行对macleanpipe管道的内容进行gzip压缩,
   之后重定向到maclean_compress.dmp.gz压缩文件                 */


[oracle@vrh1 exp]$ nohup  gzip maclean_compress.dmp.gz &
[1] 27686


[oracle@vrh1 exp]$ exp system/oracle file=macleanpipe tables=maclean.tv


Export: Release 10.2.0.4.0 - Production on Fri Apr 1 17:13:50 2011
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses WE8ISO8859P1 character set (possible charset conversion)
About to export specified tables via Conventional Path ...
Current user changed to MACLEAN
. . exporting table                             TV      19988 rows exported
Export terminated successfully without warnings.


[1]+  Done                    nohup gzip < macleanpipe > maclean_compress.dmp.gz

/* 以上当压缩进程gzip接收到exp输出的EOF文件终结符后,
    该压缩进程会自行结束                 * /

/* 可以看到这里的压缩比还是很高的 */

[oracle@vrh1 exp]$ ls -lh maclean_compress.dmp.gz
-rw-r--r-- 1 oracle oinstall 225K Apr  1 17:13 maclean_compress.dmp.gz

/* 使用gzip -d命令解压以上gz文件就可以得到普通的dumpfile用以imp导入 */

[oracle@vrh1 exp]$ gzip -d maclean_compress.dmp.gz

[oracle@vrh1 exp]$ ls -lh maclean_compress.dmp
-rw-r--r-- 1 oracle oinstall 2.0M Apr  1 17:13 maclean_compress.dmp

在Oracle 10g中引入了速度更快的DataPump Server-side Expdp/Impdp导入导出工具,与exp不同的是,Expdp导出的dumpfile中信息不遵循某种顺序规则,这导致传统的顺序设备如磁带和管道不支持expdp或impdp;换而言之我们无法使用expdp工具将导出结果直接输出到磁带设备或命名管道中,这也造成上述介绍的管道压缩方法对expdp命令是不适用的。 所幸在Oracle Database 11g中对Expdp的压缩选项添加了all和dataonly选项,虽然目前Datapump压缩的性能仍比gzip压缩要差一些,但2者间的差别几乎可以忽略不计。一般在11g中,Oracle推荐使用DataPump压缩来彻底代替Unix管道压缩。


本文转自maclean_007 51CTO博客,原文链接:http://blog.51cto.com/maclean/1277746

相关文章
|
3月前
|
Unix Shell Linux
在Unix/Linux Shell中,管道(`|`)和重定向
在Unix/Linux Shell中,管道(`|`)和重定向
23 1
|
监控 关系型数据库 Shell
Linux/Unix shell 自动导出Oracle数据库
       使用shell脚本实现对Oracle数据库的监控与管理将大大简化DBA的工作负担,如常见的对实例的监控,监听的监控,告警日志的监控,以及数据库的备份,AWR report的自动邮件等。
1308 0
|
5月前
|
缓存 网络协议 Unix
Linux(UNIX)五种网络I/O模型与IO多路复用
Linux(UNIX)五种网络I/O模型与IO多路复用
112 0
|
10月前
|
Unix Linux C语言
计算机操作系统实验一 Unix/Linux编程开发环境
计算机操作系统实验一 Unix/Linux编程开发环境
96 0
|
4月前
|
Unix Shell Linux
在Unix/Linux操作系统中,Shell脚本广泛用于自动化任务
在Unix/Linux操作系统中,Shell脚本广泛用于自动化任务
26 2
|
2月前
|
Oracle Ubuntu Unix
Unix与Linux区别
Unix: Unix是一个操作系统家族的名称,最早由贝尔实验室(Bell Labs)的肖像电机公司(AT&T)开发。最早的Unix版本是在1969年创建的。 Linux: Linux是由芬兰计算机科学家Linus Torvalds在1991年创建的。它是作为一个免费、开放源代码的Unix克隆而开始的。
19 1
|
8月前
|
Unix 大数据 Linux
【Linux is not Unix】Linux前言
【Linux is not Unix】Linux前言
|
4月前
|
Ubuntu Unix Linux
Unix/Linux操作系统的最强入门科普(经典)
Unix/Linux操作系统的最强入门科普(经典)
85 0
|
4月前
|
网络协议 Unix Linux
在Unix/Linux shell中,与网络相关的命令
在Unix/Linux shell中,与网络相关的命令
24 2
|
4月前
|
Unix Shell Linux
在Unix/Linux shell中,`ps` 命令
在Unix/Linux shell中,`ps` 命令
28 2