逻辑备份与恢复实战数据库教程

2024-05-21

逻辑备份与恢复实战数据库教程(精选6篇)

篇1:逻辑备份与恢复实战数据库教程

逻辑备份与恢复的前提

1. 数据库工作在归档状态

2. 给数据库管理员授予角色权限

(1)如图12.2所示的编辑用户的【角色】选项卡,

(2)在【可用】下拉列表框里选中EXP FULL DATABASE和IMP FULL DATABASE角色,单击按钮,在【已授予】列表框里出现已经授予的角色权限。

3. 给NT管理员授予批处理作业权限

(1)如图12.3所示的本地安全设置界面。

(2)出现如图12.4所示的【本地安全策略设置】界面。

(3)出现如图12.5所示的【选择用户或组】界面。

4. 设置节点的首选身份证明

(1)如图12.6所示。

(2)切换到如图12.7所示的编辑管理员首选项的【首选身份证明】选项卡。

5. 设置数据库的首选身份证明

用exp命令文件实现逻辑备份

(1)数据库连接成功后出现如图12.9所示界面。

(2)出现如图12.10所示界面。

(3)开始逻辑备份过程,出现如图12.11所示界面。

(4)在c:oracleora90bin目录下已经有名为EXPDAT.DMP的二进制文件存在。

用imp命令文件实现逻辑恢复

(1)数据库连接成功后出现如图12.12所示界面。

(2)出现如图12.13所示界面,

(3)出现如图12.14所示界面表明利用imp命令文件成功完成逻辑恢复,

(4)出现如图12.15所示的界面显示其参数配置。

用导出向导实现逻辑备份

(1)如图12.16所示。

(2)出现如图12.17所示的导出向导的【简介】界面。

(3)出现如图12.18所示的导出向导的【导出文件】界面。

(4)出现如图12.19所示的导出向导的【导出类型】界面,有3种导出类型。

(5)出现如图12.20所示的导出向导的【关联对象】界面,指定要导出的关联对象。

(6)出现如图12.21所示的导出向导的【调度】界面,包括6种调度方式。

(7)出现如图12.22所示的导出向导的【作业信息】界面。

(8)出现如图12.23所示的导出向导的【概要】界面。

(9)出现如图12.24所示界面。

(10)成功完成的备份作业如图12.25所示。

用导入向导实现逻辑恢复

(1)如图12.26所示。

(2)出现导入向导的【简介】界面。

(3)出现如图12.27所示的导入向导的【导入文件】界面。

(4)出现如图12.28所示的导入向导的【进度】界面。

(5)出现如图12.29所示的导入向导的【导入类型】界面。

(6)出现如图12.30所示的导入向导的【用户选择】界面。

(7)出现如图12.31所示的导入向导的【用户映射】界面。

(8)出现如图12.32所示的导入向导的【关联对象】界面,用于设置要导入的关联对象,包括。

(9)出现导入向导的【调度】界面。

(10)出现导入向导的【作业信息】界面。

(11)出现导入向导的【概要】界面。

(12)出现作业成功提交界面。

篇2:逻辑备份与恢复实战数据库教程

(1)在【企业管理器】里关闭数据库例程,

(2)利用计算机的【资源管理器】查找与数据库有关的文件,

如图12.1所示。

(3)数据库的初始化文件位于c:oracleora90database目录下,名为initmyoracle.ora,将其拷贝到指定目录下。

脱机恢复

(1)在【企业管理器】里关闭数据库例程。

篇3:逻辑备份与恢复实战数据库教程

数据库的备份设备

数据库的备份设备可以分为三种类型:磁盘文件、磁带和命名管道, 这三种类型相辅相成才能真正的把数据有效的保护起来。磁盘备份设备是硬盘或其他磁盘存储媒体上的文件, 与常规操作系统文件一样。引用磁盘备份设备与引用任何其他操作系统文件一样。可以在服务器的本地磁盘上或共享网络资源的远程磁盘上定义磁盘备份设备, 磁盘备份设备根据需要可大可小。最大的文件大小相当于磁盘上可用的闲置空间。

如果在网络上将文件备份到远程计算机上的磁盘, 使用通用命名规则名称 (UNC) , 以ServernameSharenamePathFile格式指定文件的位置。将文件写入本地硬盘时, 必须给SQL Server使用的用户帐户授予适当的权限, 以在远程磁盘上读写该文件。

SQL Server用逻辑设备和物理设备来标识设备, 逻辑设备是物理设备的别名, 我们可以利用企业管理器, 也可以调用系统存储过程来生成备份设备。

数据库备份方案的选择

根据备份的内容和不同的备份情况, 我们一般而言, 对于SQL server采用4种有效的备份策略进行选择:

1.只备份数据库

数据库备份是将数据库的表和视图以及数据一次性备份出来, 并可以设定备份周期。但是如果只采用数据库完全备份, 而不备份该数据库的事务日志, 当出现故障时只能将该数据库恢复到上次备份的时刻, 因此可能会丢失大量的数据。

2.事务日志备份

事务日志备份是对自上次备份事务日志后对数据库执行的所有事务的一系列记录进行备份, 可以使用事务日志备份将数据库恢复到特定的即时点, 如插入一批新数据前的那点, 或恢复到故障点。可以采用下列一般步骤来进行事务日志的备份: (1) 备份在故障发生前的当前事务日志; (2) 还原最近的数据库完全备份; (3) 按顺序还原数据库完全备份后建立的所有事务日志。

3.数据库差异备份

如果数据库中的数据经常被修改, 可以使用数据库的差异备份来减少数据库的备份时间和恢复时间。要执行数据库的差异备份时, 首先需要执行完全数据库备份, 数据库的差异备份只备份上一次完全数据库备份之后已经改变的数据库内容, 和在执行数据库差异备份中发生的任何操作以及事务日志中没有提交的事务。

4.对指定文件组和文件的备份

文件和文件组备份的备份可以备份和还原数据库中的个别文件或文件组, 这样将使您能够只还原已损坏的文件或文件组, 而不用还原数据库的其余部分, 从而提高了数据库的恢复速度。

备份方法的优化处理

1.防止故障

为了预防数据库的数据丢失, 我们需要认真做好数据库的灾难恢复计划, 并且要按时定期进行数据库的损坏预防推演, 在每一段时间内, 都要检查所备份的数据库时候安全, 通过多次检查和确认, 保证数据库和数据库备份设备能够可靠、安全的运行, 当前大量的数据库应用系统都有着各种不同的数据备份预案。

我们简单以一个应用系统为例:目前系统数据层主要包括2台SUN V880小型机 (2个1.2G CPU, 4G内存) , 一台HDS 9570磁盘阵列 (容量为2T) , 2台SUN V880小型机通过FC-HBA卡直接连接到磁盘阵列上, 2台SUN V880小型机使用Veritas集群软件进行双机热备, 数据库为SQL Server企业版。中间层服务器为IBM PC Server运行Windows操作系统, 目前有两台同时使用, 如果一台出现问题, 可以将其服务的客户交由另一台负责。磁盘阵列目前只有一台, 并且没有备用硬盘。

2.数据库备份优化

(1) 系统性能提升。

由于数据库服务器端的磁盘列阵目前只有一台, 而且没有相关备用的硬盘, 因此我们需要增加备份硬盘的数量, 并且考虑到磁盘列阵控制器有可能会出现故障, 当出现故障时, 就会出现系统数据丢失或者损坏, 因此我们还需要增加配置一台小型备用电脑, 作为专门数据库维护和定时备份的机器, 但系统出现重大问题时, 则启动该台电脑。另外, 随着数据量的增加, 系统的操作反应时间也在加大, 特别是在业务繁忙时期系统的反应速度已经影响业务运行。因此, 原来配置的小型机需升级到4CPU 16G内存。

(2) 服务器群系统备份及恢复。

由于企业当前运行的应用型系统会有多种, 门户网站、OA、域名、代理服务器等, 多种系统就有可能出现人为失误、硬件故障, 病毒侵入、黑客攻击、自然灾害等, 都可能出现服务器系统平台的崩溃和丢失, 给整个应用型系统造成无可挽回的损失。

因此在企业内部建立起一套统一、高效的操作系统备份和恢复管理方案, 通过专业的数据库恢复软件, 将数据库迅速恢复, 规避各种风险带来的损失, 企业应当集中采用通用的备份方案。并且在现有的网路设备基础上, 增加备份服务器, 不改变现有网络架构, 所有数据都统一集中备份到备份服务器的磁盘列阵当中。在未来需要购买专业备份恢复软件及一台磁盘阵列, 实现自动将全网多台服务器系统备份到磁盘阵列中。当任意一台服务器系统瘫痪、崩溃时, 可简单、快速的恢复操作系统的备份, 并快速的重新恢复应用系统运行, 保障整个系统的高可用性。一个完整的数据备份及灾难恢复方案包括:备份硬件、备份软件、备份制度和灾难恢复计划四个部分。选了先进的备份硬件后, 决不能忽略备份软件的选择, 因为只有优秀的备份件才能充分发挥硬件的先进功能, 保证快速、有效的数据备份和恢复, 还需要制定日常备份制度和灾难恢复措施, 并由管理人员切实执行备份制度。

结束语

篇4:探讨计算机数据库备份与恢复技术

【关键词】计算机数据库;备份;恢复技术;

【中图分类号】 TP309.3【文献标识码】A【文章编号】1672-5158(2013)02-0143-02

前言:随着计算机技术的迅猛发展,保证互联网时代的数据资料的安全已经成为一个迫在眉睫的问题。要恢复因不明入侵、计算机固件损坏、网络故障等原因造成的数据损坏,就必须要用到计算机数据库备份技术及恢复技术,以免造成重大损失。

1、计算机数据库的备份的含义

对计算机内部储存的数据资料进行复制并拷贝成副本的行为就是进行计算机数据库备份。通俗点来说,整合现有正常数据的过程就是进行计算机数据库备份。

计算机数据库备份按照不同的分类原则分为静态备份和动态备份两个方面,其具体含义如下:

(1)静态备份

在进行计算机数据库备份的过程中,要停止对数据库的其他操作,以便能在数据库备份过程中将当时的原始数据进行相对完整的保留的行为就是静态备份。

(2)动态备份

在进行计算机数据库备份的过程中,可与用户进行其他操作同时进行的,对数据做存取与修改行为的备份就叫做动态备份。因为动态备份常常被作为最能保存备份资料完整性的备份方式。所以在多数情况下,用户都会选择动态备份来进行计算机数据的备份工作。要将用户所需的数据资料恢复到原来状态,就要将在备份期间对数据进行修改活动的操作记录下来,建立日志文件,才能保证在后续的备份副本加上日志文件,以实现备份数据的恢复。

2、在计算机数据库备份的过程中主要应用的备份方式

顺应快速发展的现代社会的发展要求,数据备份技术也亟待提高,因此,要建立多种多样的备份方式,例如建立高性能系统,网络和SAN备份,归档和分级存储管理以及数据容灾系统等,实现保障数据资料安全的目的。

(1)高性能系统

为保证技术及数据及业务的不间断、不停顿,在计算机的软硬件出现单点故障时,通过集群软件达到业务切换就是所谓的高性能系统。

(2)网络备份

采用单机备份方式进行数据备份,通常情况下就是将单机备份的资料,直接与服务器连接,不仅会造成服务器负担过重的情况,所进行得备份操作也极不安全。为此就要采用安全性更高的备份方式,例如网络备份。网路备份就是在需要进行数据备份的,采用双机或集群运行方式的服务器主机上,利用网络将需要备份的数据上传至服务器进行备份的方式。

网络备份不仅减轻了需要进行数据备份的服务器负担,同时还提高了备份操作的安全性。不仅如此,网络备份还具有其他众多便捷的功能:网络备份既现定了定时备份,同时还实现能对备份介质进行管理、设置,以达到数据全自动备份的目的,在此基础上网络备份还能支持完全、增量、差量备份,丰富了局域网中的备份手段。

(3)SAN备份

在计算机系统和存储单元以及存储单元之间用来进行数据传输的网络系统被称为SAN。SAN备份是指在SAN存储区域网中,通过性能较高的光纤接口将计算机的磁盘裂口与前端服务器链接起来,再通过计算机管理人员的集中化管理,将存储系统强化备份以提高系统效率的备份方式。

(4) 归档和分级存储管理

归档和分级储存管理较之网络备份有很大区别。归档和分级存储管理主要用来解决因计算机存储空间不足而无法满足数据库存储需求的情况。其中归档指的是通过文档服务器对有价值的数据进行复制或打包以便保存。其主要作用就是保证有价值的数据能够得到长时间的存储。

(5)数据远程复制备份

在计算机系统遭到入侵、破坏或是因人为原因而误删、误改数据的情况下,计算机数据库中存储的数据的完整性就有可能发生损毁,这种情况还能够通过高性能系统的处理来避免,但在发生天灾人祸(例如地震、海啸、火灾、洪涝)的情况下,这些备份手段就显得无用武之地。为避免因天灾人祸而造成数据资料损毁、丢失的情况产生,有必要进行数据的远程复制备份。

数据远程复制备份是通过软件数据复制和硬件数据复制来实现的,它不仅能保证远程备份数据中心的数据备份副本与本地数据备份中心的数据备份副本完全一致,同时还能实现备份数据的远程故障诊断与分析,是避免数据丢失、损毁的好办法。

3、计算机数据库备份时间

进行计算机备份的时间有定期和不定期两种:

(1)定期备份

在固定的时间内进行数据备份工作就是通常所说的定期备份。通常情况下最好的备份方案是:每周、每月进行一次数据备份工作。

(2)不定期备份

根据计算机网络系统运行的实际情况,在计算计数据库运行的同时进行数据的备份工作就是所谓的不定期备份,不定期备份通常都需要建立备份日志文件,以免所备份的数据具有滞后性。

4、计算机数据库的恢复技术

(1)计算机数据的恢复方法

在进行计算机数据库的恢复过程中,要遵循一个基本原则:进行数据的重复储存。其具体方式有以下两种:

①转储和建立日志。

当计算数据库发生故障时,要对整个数据进行周期性复制。

②若出现数据库故障,则要根据实际情况进行处理操作

进行数据的周期性复制也要根据实际情况来进行处理,大体上分为两种:一是在数据库已经损毁的情况下,要将最后一次备份的数据备份副本装入磁盘然后根据日志记录将数据库之间的更新重新处理。二是在数据没有损毁,但数据完整性及其可靠性降低的情况下,就不需要进行周期性复制,只需要利用日志库中的日志文件作具体的撤销处理就可能帮助数据库恢复。

(2)计算机数据的恢复形式

我国现有的计算机恢复技术主要包括:全盘恢复、数据库和邮件系统恢复、个别文件恢复、重定向恢复等。每一种恢复技术都有其特定的恢复对象,也有其特定的恢复效果。

①全盘恢复

进行数据库的全盘恢复可以恢复数据库大部分的存储信息。它主要是在计算机数据库发生意外损毁(如服务器发生意外造成数据丢失,系统崩溃、重组、升级等情况)的情况下进行的恢复操作。

②数据库和邮件系统恢复

进行数据库和邮件系统的恢复时,不仅要通过备份软件进行恢复操作,同时还要在恢复数据后进行对数据的维护处理工作。这项恢复操作需要用户具有专业的操作技能水平,不仅如此还要熟悉掌握各种操作软件程序的操作流程。为此,用户需在进行数据库和邮件系统恢复的操作之前对被管理的数据库和邮件系统做好相应的备份处理,以保证数据恢复的完整性。

③个别文件恢复

个别文件的恢复较之数据库和邮件系统的恢复显得异常简单,只要利用网络备份副本就可以实现文件的恢复了。

④重定向恢复

重定向恢复就是指改变文件的恢复位置,将其恢复到与当时文件所处位置不同的位置或系统上去,以此来达到恢复目的的恢复操作。因此,重定向恢复的范围就囊括了全盘恢复、个别文件恢复以及数据库和邮件系统恢复。

结束语

我国社会经济、科学在不断发展的同时也极大地促进了我国计算机技术的发展与应用,计算机的逐渐普及便利人民、企业或其他企事业单位的生活、工作,但同时也增加了各企事业单位内部数据丢失、损毁的风险性,为保障计算机数据的安全性和完整性,加大对计算机数据库备份和恢复技术的探讨、研究就变得尤为重要。

参考文献

[1] 粱晓明. 试析计算机数据库的备份及恢复技术[J]. 计算机光盘软件与应用.2011(24)

[2] 胡晶. 计算机数据库的备份及恢复技术初探[J]. 信息安全与技术.2011(8)

篇5:逻辑备份与恢复

逻辑备份与恢复备份与恢复简介:

备份是数据库中数据的副本,它可以保护数据在出现意外

损失时最大限度的恢复,

Oracle数据库的备份包括以下两种类型:

物理备份是对数据库的操作系统物理文件(如数据文件、控制文件和日志文件等)的备份:RMAN备份

逻辑备份是对数据库逻辑组件(如表、视图和存储过程等数据库对象)的备份:imp[dp]/exp[dp]

故障类型:

导致数据库操作中止的故障包括四种类型:

语句故障:在执行 SQL 语句无效可导致语句故障。

用户进程故障:当用户程序出错而无法访问数据库时发生用户进程故障。导致用户进程故障的原因是异常断开连接或异常终止进程

实例故障:当 Oracle 的数据库实例由于硬件或软件问题而无法继续运行时,就会发生实例故障

介质故障:在数据库无法正确读取或写入某个数据库文件时,会发生介质故障

语句故障select * from aa;//假如aa表并不存在的情况不需要处理用户进程故障用户(死机、用户进程消失了)<――>连接<――>服务器(pmon进程处理,监测到客户端进程消失后马上就把serverPro杀死掉)不需要处理实例故障oracle服务器死机、坏掉了,通过重启oracle就可以解决实例故障不需要处理介质故障硬盘坏了导致数据文件丢失或者损坏了需要dba来进行处理

传统的导入导出:

简介:传统的导出导入程序用于实施数据库的逻辑备份和恢复导出程序将数据库中的对象定义和数据备份到一个操作系统二进制文件中导入程序读取二进制导出文件并将对象和数据载入数据库中传统的导出导入程序是客户端工具。

导出和导入实用程序的特点有:可以按时间保存表结构和数据允许导出指定的表,并重新导入到新的数据库中可以把数据库迁移到另外一台异构服务器上在两个不同版本的Oracle数据库之间传输数据在联机状态下进行备份和恢复可以重新组织表的存储结构,减少链接及磁盘碎片

使用以下三种方法调用导出和导入实用程序:

1,交互提示符:以交互的方式提示用户逐个输入参数的值。

2,命令行参数:在命令行指定执行程序的参数和参数值。

3,参数文件:允许用户将运行参数和参数值存储在参数文件中,以便重复使用参数

导出和导入数据库对象的四种模式是:四种模式独立互斥的,不能同时存在

1,数据库模式:导出和导入整个数据库中的所有对象

2,表空间模式:导出和导入一个或多个指定的表空间中的所有对象

3,用户模式:导出和导入一个用户模式中的所有对象

4,表模式:导出和导入一个或多个指定的表或表分区表的高水位线可以使用导入导出来下降

导出操作的基本命令参数:

参数

说明

USERID

确定执行导出实用程序的用户名和口令

BUFFER

确定导出数据时所使用的缓冲区大小,其大小用字节表示

FILE

指定导出的二进制文件名称,默认的扩展名是.dmp

FULL

指定是否以全部数据库方式导出,只有授权用户才可使用此参数

OWNER

要导出的数据库用户列表

HELP

指定是否显示帮助消息和参数说明

ROWS

确定是否要导出表中的数据

TABLES

按表方式导出时,指定需导出的表和分区的名称

PARFILE

指定传递给导出实用程序的参数文件名

TABLESPACES

按表空间方式导出时,指定要导出的表空间名

[root@ localhost ~]# su - oracle[oracle@ localhost ~]$ clear[oracle@ localhost ~]$ cd $ORACLE_BASE[oracle@ localhost oracle]$ lsadmin archive cfgtoollogs checkpoints diag flash_recovery_area oradata pl_sql_pacakge[oracle@ localhost oracle]$ mkdir - p test_imp_exp[oracle@ localhost oracle]$ cd test_imp_exp/[oracle@ localhost test_imp_exp]$ ls[oracle@ localhost test_imp_exp]$ pwd/u01 /app /oracle /test_imp_exp[oracle@ localhost test_imp_exp]$ sqlplus hr/ hr@ jiagulun

SQL*Plus: Release 11.2.0.1.0 Production on Tue Jan 20 23: 50: 52

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

Connected to :Oracle Database 11 g Enterprise Edition Release 11.2 .0.1.0 - 64 bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing options

SQL> select * from student;

ID NAMEAGE---------- -------------------- ----------

SQL> select * from address;

XH ZZ---------- ----------

SQL> exit;Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing options[oracle@ localhost test_imp_exp]$ exp help =y--通过这个来查看关于exp命令的解释

Export: Release 11.2.0.1.0 - Production on Tue Jan 20 23:51:56 2015

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

You can let Export prompt you for parameters by entering the EXPcommand followed by your username/password :

Example: EXP SCOTT/TIGER

Or, you can control how Export runs by entering the EXP command followedby various arguments. To specify parameters, you use keywords:

Format: EXP KEYWORD= value or KEYWORD =(value1 ,value2 ,... ,valueN ) Example: EXP SCOTT/TIGER GRANTS=Y TABLES=( EMP, DEPT, MGR) or TABLES=( T1: P1, T1: P2), if T1 is partitioned table

USERID must be the first parameter on the command line.

Keyword Description (Default )KeywordDescription (Default )--------------------------------------------------------------------------USERID username/password FULL export entire file (N )BUFFER size of data buffer OWNER list of owner usernamesFILE output files (EXPDAT.DMP ) TABLES list of table namesCOMPRESS import into one extent (Y ) RECORDLENGTH length of IO recordGRANTS export grants (Y) INCTYPEincremental export typeINDEXES export indexes (Y ) RECORD track incr. export (Y )DIRECT direct path (N )TRIGGERS export triggers (Y )LOG log file of screen output STATISTICS analyze objects (ESTIMATE )ROWS export data rows (Y ) PARFILEparameter filenameCONSISTENT cross- table consistency (N ) CONSTRAINTS export constraints (Y )

OBJECT_CONSISTENT transaction set to read only during object export (N )FEEDBACK display progress every x rows (0 )FILESIZE maximum size of each dump fileFLASHBACK_SCN SCN used to set session snapshot back toFLASHBACK_TIME time used to get the SCN closest to the specified timeQUERY select clause used to export a subset of a tableRESUMABLEsuspend when a space related error is encountered (N )RESUMABLE_NAME text string used to identify resumable statementRESUMABLE_TIMEOUT wait time for RESUMABLETTS_FULL_CHECK perform. full or partial dependency check for TTSVOLSIZE number of bytes to write to each tape volumeTABLESPACES list of tablespaces to exportTRANSPORT_TABLESPACE export transportable tablespace metadata (N)TEMPLATE template name which invokes iAS mode export

[oracle@ localhost test_imp_exp]$ exp hr/ hr@ jiagulun tables =student file=/u01/app/oracle/test_imp_exp/hr_student_file.dbf log=/u01/app/oracle/test_imp_exp/hr_student_log.log

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 00:05:42 2015--上面的命令为通过导出表的模式导出student表

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 - 64bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing optionsExport done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path .... . exporting tableSTUDENT 4 rows exportedExport terminated successfully without warnings.[oracle@ localhost test_imp_exp]$ ! ls - als - a. .. expdat.dmp hr_student_file.dbf hr_student_log.log

[oracle@ localhost test_imp_exp]$ exp hr/ hr@ jiagulun tablespaces= users file=/u01/app/oracle/test_imp_exp/hr_tbs_users_file.dbf log=/u01/app/oracle/test_imp_exp/hr_tbs_users_log.log

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 00:08:23 2015--导出表空间

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 - 64bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing optionsEXP-00023 : must be a DBA to do Full Database or Tablespace export--假如是导出数据库或者恶表空间需要dba来做(2) U( sers), or ( 3) T( ables): ( 2) U > u--自动跳到了交互提示符模式:exp

Export grants (yes /no ): yes > yes

Export table data (yes /no ): yes > yes

Compress extents (yes /no ): yes > yes

Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export selected tablespaces ...

. exporting referential integrity constraints. exporting triggersExport terminated successfully with warnings.[oracle@ localhost test_imp_exp]$ lsexpdat.dmp hr_student_file.dbf hr_student_log.log hr_tbs_users_file.dbf hr_tbs_users_log.log[oracle@ localhost test_imp_exp]$ lltotal 40-rw -r--r-- 1 oracle oinstall 0 Jan 21 00:02 expdat.dmp-rw -r--r-- 1 oracle oinstall 16384 Jan 21 00:05 hr_student_file.dbf-rw -r--r-- 1 oracle oinstall 427 Jan 21 00:05 hr_student_log.log-rw -r--r-- 1 oracle oinstall 16384 Jan 21 00:10 hr_tbs_users_file.dbf-rw -r--r-- 1 oracle oinstall 463 Jan 21 00:10 hr_tbs_users_log.log[oracle@ localhost test_imp_exp]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Wed Jan 21 00: 11: 22 2015

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

Connected to :Oracle Database 11 g Enterprise Edition Release 11.2 .0.1.0 - 64 bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing options

SQL> create user test1 identified by test1;

User created.

SQL> grant connect, resource to test1 ;

Grant succeeded.

SQL> create table test_export_tab(id number (20 ),name varchar2 (20 ));

Table created.

SQL> insert into test_export_tab values( 1, ‘zhangsan‘);

1 row created.

SQL> exit;Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing options[oracle@ localhost test_imp_exp]$ exp hr/ hr@ jiagulun tables=test1.test_export_tab file=/u01/app/oracle/test_imp_exp/hr_test1_tab_file.dbf log=/u01/app/oracle/test_imp_exp/hr_test1_tab_log.log

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 00:20:07 2015--导出不同用户的表

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 - 64bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing optionsExport done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...EXP-00009 : no privilege to export TEST1 ‘s table TEST_EXPORT_TABExport terminated successfully with warnings.--导出不同用户的数据信息必须有权限[oracle@localhost test_imp_exp]$ exp system/oracle@jiagulun tables=test1.test_export_tab file=/u01/app/oracle/test_imp_exp/hr_test1_tab_file.dbf log=/u01/app/oracle/test_imp_exp/hr_test1_tab_log.log

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 00:23:48 2015--system用户可以导出不同用户数据

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 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsExport done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...Current user changed to TEST1. . exporting table TEST_EXPORT_TAB 1 rows exportedExport terminated successfully without warnings.

导入操作的基本命令参数:

参数

说明

USERID

指定执行导入的用户名和密码

BUFFER

指定用来读取数据的缓冲区大小,以字节为单位

COMMIT

指定是否在每个数组(其大小由BUFFER参数设置)插入后进行提交

FILE

指定要导入的二进制文件名

FROMUSER

指定要从导出转储文件中导入的用户模式

TOUSER

指定要将对象导入的用户名。FROMUSER与TOUSER可以不同

FULL

指定是否要导入整个导出转储文件

TABLES

指定要导入的表的列表

ROWS

指定是否要导入表中的行

PARFILE

指定传递给导入实用程序的参数文件名,此文件可以包含这里列出的所有参数

IGNORE

导入时是否忽略遇到的错误,默认为N

TABLESPACES

按表空间方式导入,列出要导入的表空间名

[oracle@ localhost test_imp_exp]$ exp hr/ hr@ jiagulun tables = student,address file = $ORACLE_BASE /test_imp_exp /hr_stu_add log = $ORACLE_BASE/test_imp_exp /hr_stu_add

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 00:56:30 2015--导出文件的表不是table=(tab1,tab2)而是如上面所示

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 - 64bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing optionsExport done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path .... . exporting tableSTUDENT 4 rows exported. . exporting tableADDRESS 4 rows exportedExport terminated successfully without warnings.[oracle@ localhost test_imp_exp]$ lshr_stu_add.dmp hr_stu_add.log[oracle@ localhost test_imp_exp]$ sqlplus hr/ hr

SQL*Plus: Release 11.2.0.1.0 Production on Wed Jan 21 00: 57: 04 2015

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

Connected to :Oracle Database 11 g Enterprise Edition Release 11.2 .0.1.0 - 64 bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing options

SQL> drop table address;

Table dropped.

SQL> drop table student;

Table dropped.

SQL> commit;

Commit complete.

SQL> purge recyclebin;--清除回收站

Recyclebin purged.

SQL> exitDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing options[oracle@ localhost test_imp_exp]$ imp hr/hr@jiagulun file=$ORACLE_BASE/test_imp_exp/hr_stu_add.dmp

Import: Release 11.2 .0.1.0 - Production on Wed Jan 21 00 :59 :27 2015--导入表到自己当中去

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 - 64bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing options

Export file created by EXPORT: V11.02.00 via conventional pathimport done in ZHS16GBK character set and AL16UTF16 NCHAR character set. importing HR‘s objects into HR. importing HR‘ s objects into HR. . importing table “STUDENT” 4 rows imported. . importing table “ADDRESS” 4 rows importedAbout to enable constraints...Import terminated successfully without warnings.[oracle@ localhost test_imp_exp]$ imp hr/hr@jiagulun file=$ORACLE_BASE/test_imp_exp/hr_stu_add.dmp fromuser =hr touser=test1

Import: Release 11.2 .0.1.0 - Production on Wed Jan 21 01 :00 :31 2015--通过其他用户把表导入到另外用户中去

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 - 64bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing options

Export file created by EXPORT: V11.02.00 via conventional pathimport done in ZHS16GBK character set and AL16UTF16 NCHAR character setIMP- 00007: must be a DBA to import objects to another user ‘s accountIMP-00000: Import terminated unsuccessfully--通过其他用户把表导入到另外用户中去,这是不行的[oracle@localhost test_imp_exp]$ imp test1/test1@jiagulun file=$ORACLE_BASE/test_imp_exp/hr_stu_add.dmp fromuser=hr touser=test1 tables=student

Import: Release 11.2.0.1.0 - Production on Wed Jan 21 01:01:26 2015--自己导入其他用户的表到自己当中去

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 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options

Export file created by EXPORT:V11.02.00 via conventional path

Warning: the objects were exported by HR, not by you--可以导入,但是会有警告

import done in ZHS16GBK character set and AL16UTF16 NCHAR character set. importing HR‘ s objects into TEST1. . importing table “STUDENT” 4 rows importedImport terminated successfully without warnings.[oracle@ localhost test_imp_exp]$ imp system/ oracle@ jiagulun file=$ORACLE_BASE/test_imp_exp/hr_stu_add.dmp fromuser =hr touser=test1 tables= address

Import: Release 11.2 .0.1.0 - Production on Wed Jan 21 01 :02 :00 2015--通过system导入其他表到另外用户中可以

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 - 64bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing options

Export file created by EXPORT: V11.02.00 via conventional path

Warning: the objects were exported by HR , not by you--通过system导入其他表到另外用户中可以但也会有警告出现

import done in ZHS16GBK character set and AL16UTF16 NCHAR character set. importing HR‘s objects into TEST1. . importing table “ADDRESS” 4 rows importedAbout to enable constraints...Import terminated successfully without warnings.[oracle@localhost test_imp_exp]$ sqlpus test1/test1-bash: sqlpus: command not found[oracle@localhost test_imp_exp]$ sqlplus test1/test1

SQL*Plus: Release 11.2.0.1.0 Production on Wed Jan 21 01:02:22 2015

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

Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from tab;

TNAME TABTYPE CLUSTERID------------------------------ ------- ----------ADDRESSTABLESTUDENTTABLETEST_EXPORT_TAB TABLE

SQL>假如我想导入用户已经存在的表:需要添加ignore参数下面是通过交互提示符的方式导入的:没有添加ignore

[oracle@localhost test_imp_exp]$ imp

Import: Release 11.2.0.1.0 - Production on Wed Jan 21 01:33:00 2015

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

Username: test1

Password:

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Import data only (yes/no): no >

Import file: expdat.dmp > hr_stu_add.dmp

Enter insert buffer size (minimum is 8192) 30720>

Export file created by EXPORT:V11.02.00 via conventional path

Warning: the objects were exported by HR, not by you

import done in ZHS16GBK character set and AL16UTF16 NCHAR character set

List contents of import file only (yes/no): no >

Ignore create error due to object existence (yes/no): no >

Import grants (yes/no): yes >

Import table data (yes/no): yes >

Import entire export file (yes/no): no >

Username: hr

Enter table(T) or partition(T:P) names. Null list means all tables for user

Enter table(T) or partition(T:P) name or . if done: .

. importing HR‘s objects into TEST1

. importing HR‘s objects into TEST1

IMP-00015: following statement failed because the object already exists:

“CREATE TABLE ”STUDENT“ (”ID“ NUMBER(10, 0), ”NAME“ VARCHAR2(20), ”AGE“ NUMB”

“ER(10, 0)) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 STORAGE(INITIAL 6”

“5536 NEXT 1048576 MINEXTENTS 1 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DE”

“FAULT) LOGGING NOCOMPRESS”

IMP-00015: following statement failed because the object already exists:

“CREATE TABLE ”ADDRESS“ (”XH“ NUMBER, ”ZZ“ VARCHAR2(10)) PCTFREE 10 PCTUSED”

“ 40 INITRANS 1 MAXTRANS 255 STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1”

“ FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) LOGG”

“ING NOCOMPRESS”

Import terminated successfully with warnings.下面是通过参数文件的方式导入的:添加ignore

file=$ORACLE_BASE/test_imp_exp/hr_stu_add.dmp

ignore=y

fromuser=hr

touser=test1

[oracle@localhost test_imp_exp]$ imp test1/test1@jiagulun parfile=imp_by_spfile

Import: Release 11.2.0.1.0 - Production on Wed Jan 21 01:46:58 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Export file created by EXPORT:V11.02.00 via conventional path

Warning: the objects were exported by HR, not by you

import done in ZHS16GBK character set and AL16UTF16 NCHAR character set

. importing HR‘s objects into TEST1

. . importing table “STUDENT”

IMP-00019: row rejected due to ORACLE error 1

IMP-00003: ORACLE error 1 encountered

ORA-00001: unique constraint (TEST1.PK_STUDENT) violated

Column 1 1

Column 2 ????

Column 3 20

IMP-00019: row rejected due to ORACLE error 1

IMP-00003: ORACLE error 1 encountered

ORA-00001: unique constraint (TEST1.PK_STUDENT) violated

Column 1 2

Column 2 ????

Column 3 25

IMP-00019: row rejected due to ORACLE error 1

IMP-00003: ORACLE error 1 encountered

ORA-00001: unique constraint (TEST1.PK_STUDENT) violated

Column 1 3

Column 2 ????

Column 3 30

IMP-00019: row rejected due to ORACLE error 1

IMP-00003: ORACLE error 1 encountered

ORA-00001: unique constraint (TEST1.PK_STUDENT) violated

Column 1 4

Column 2 ????

Column 3 30 0 rows imported

. . importing table “ADDRESS”

IMP-00019: row rejected due to ORACLE error 1

IMP-00003: ORACLE error 1 encountered

ORA-00001: unique constraint (TEST1.PK_ADDRESS) violated

Column 1 3

Column 2 ????

IMP-00019: row rejected due to ORACLE error 1

IMP-00003: ORACLE error 1 encountered

ORA-00001: unique constraint (TEST1.PK_ADDRESS) violated

Column 1 2

Column 2 ???

IMP-00019: row rejected due to ORACLE error 1

IMP-00003: ORACLE error 1 encountered

ORA-00001: unique constraint (TEST1.PK_ADDRESS) violated

Column 1 1

Column 2 ????

IMP-00019: row rejected due to ORACLE error 1

IMP-00003: ORACLE error 1 encountered

ORA-00001: unique constraint (TEST1.PK_ADDRESS) violated

Column 1 4

Column 2 ???? 0 rows imported

About to enable constraints...

Import terminated successfully with warnings.

[oracle@localhost test_imp_exp]$

之所以会出现建表语句是因为exp操作就是把数据库中的表的建表信息,数据信息,对象信息全部转换成sql语句当使用Imp的其实也就是执行里面的sql语句。当ignore设置为Y时,oracle会忽略其中的错误重新执行一遍建表操作,数据插入操作等

可传输表空间:下面模拟两个不同主机下的不同数据库进行表空间的传输操作:

明确什么事自包含?

就是要传输的表空间的对象中被建立的对象存放在其他表空间中:例如表,可以把表的索引建立在其他的表空间中,这样就不是自包含了。

在Linux下进行的传输表空间:

[oracle@ localhost imp_tran_file]$ sqlplus / as sysdba--sys登录oracle数据库

SQL*Plus: Release 11.2.0.1.0 Production on Wed Jan 21 18: 06: 45 2015

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

Connected to :Oracle Database 11 g Enterprise Edition Release 11.2 .0.1.0 - 64 bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing options

SQL> create tablespace test_tran_ts datafile ‘/u01/app/oracle/oradata/jiagulun/test_tran_ts_file.dbf‘ size 10 m;

Tablespace created.--创建表空间

SQL> create table test_tran_tab1 (id number ,name varchar2 (20 )) tablespace test_tran_ts ;

Table created.--在该表空间中创建表

SQL> alter tablespace test_tran_ts read only;

Tablespace altered.--修改表空间为只读的状态

[oracle@ localhost imp_tran_file]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Wed Jan 21 18: 18: 58 2015

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

Connected to :Oracle Database 11 g Enterprise Edition Release 11.2 .0.1.0 - 64 bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing options

SQL> exec dbms_tts.transport_set_check (test_tran_ts ,true );BEGIN dbms_tts.transport_set_check (test_tran_ts ,true ); END;

*ERROR at line 1:ORA-06550 : line 1, column 36 :PLS-00201 : identifier ‘TEST_TRAN_TS‘ must be declaredORA-06550 : line 1, column 7 :PL/SQL: Statement ignored

SQL> exec dbms_tts.transport_set_check (‘test_tran_ts‘ ,true );--检查表空间的是否是自包含

PL/SQL procedure successfully completed.

SQL> SELECT * FROM TRANSPORT_SET_VIOLATIONS ;--检查表空间的是否是自包含

no rows selected

SQL> exit;Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing options

[oracle@ localhost test_imp_exp]$ exp ‘system/oracle@jiagulun as sysdba‘ tablespaces=test_tran_ts transport_tablespace =y file=/u01/app/oracle/test_imp_exp/exp_tran_file.dmp

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 18:25:37 2015

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

EXP-00056 : ORACLE error 1031 encounteredORA-01031 : insufficient privilegesUsername:Password:

EXP-00056 : ORACLE error 1017 encounteredORA-01017 : invalid username /password ; logon deniedUsername:Password:

EXP-00056 : ORACLE error 1017 encounteredORA-01017 : invalid username /password ; logon deniedEXP-00005 : all allowable logon attempts failedEXP-00000 : Export terminated unsuccessfully[oracle@ localhost test_imp_exp]$ exp ‘sys/oracle@jiagulun as sysdba‘ tablespaces=test_tran_ts transport_tablespace =y file=/u01/app/oracle/test_imp_exp/exp_tran_file.dmp--必须使用sys用户而且是as sysdba才可以--在Linux中需要对‘进行转义才可以Export: Release 11.2.0.1.0 - Production on Wed Jan 21 18:25:49 2015

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 - 64bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing optionsExport done in ZHS16GBK character set and AL16UTF16 NCHAR character setNote: table data ( rows) will not be exportedAbout to export transportable tablespace metadata...For tablespace TEST_TRAN_TS .... exporting cluster definitions. exporting table definitions. exporting referential integrity constraints. exporting triggers. end transportable tablespace metadata exportExport terminated successfully without warnings.[oracle@ localhost test_imp_exp]$ lsexp_tran_file.dmp hr_stu_add.dmp hr_stu_add.log imp_by_spfile[oracle@ localhost test_imp_exp]$ mkdir -p imp_tran_file--之所以建立一个文件夹是因为模拟是从另外一台主机拷贝过来的,统一放在该目录下[oracle@ localhost test_imp_exp]$ lsexp_tran_file.dmp hr_stu_add.dmp hr_stu_add.log imp_by_spfile imp_tran_file[oracle@ localhost test_imp_exp]$ cp - avf /u01 /app /oracle /oradata /jiagulun /test_tran_tstest_tran_ts01.dbf test_tran_ts_file.dbf[oracle@ localhost test_imp_exp]$ cp - avf /u01 /app /oracle /oradata /jiagulun /test_tran_ts_file.dbf . /imp_tran_file /`/ u01/ app/ oracle/ oradata/ jiagulun/ test_tran_ts_file.dbf‘ -> `./imp_tran_file/test_tran_ts_file.dbf‘[oracle@ localhost test_imp_exp]$ cd imp_tran_file/[oracle@ localhost imp_tran_file]$ lsexp_tran_file.dmp test_tran_ts_file.dbf[oracle@ localhost imp_tran_file]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Wed Jan 21 18: 29: 38 2015

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

Connected to :Oracle Database 11 g Enterprise Edition Release 11.2 .0.1.0 - 64 bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing options

SQL> drop tablespace test_tran_ts including contents;--删除刚刚创建的表空间,因为实际上是在同一个oracle中进行传输表空间的

Tablespace dropped.

SQL> exitDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing options[oracle@ localhost imp_tran_file]$ imp ‘sys/oracle@jiagulun as sysdba‘ tablespaces=test_tran_ts transport_tablespace =y file=/u01/app/oracle/test_imp_exp/imp_tran_file/exp_tran_file.dmp datafiles=/u01/app/oracle/test_imp_exp/imp_tran_file/test_tran_ts_file.dbf--导入表空间Import: Release 11.2 .0.1.0 - Production on Wed Jan 21 18 :32 :15 2015

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 - 64bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing options

Export file created by EXPORT: V11.02.00 via conventional pathAbout to import transportable tablespace (s ) metadata...import done in ZHS16GBK character set and AL16UTF16 NCHAR character set. importing SYS‘s objects into SYS. importing SYS‘ s objects into SYSImport terminated successfully without warnings.[oracle@ localhost imp_tran_file]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Wed Jan 21 18: 32: 25 2015

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

Connected to :Oracle Database 11 g Enterprise Edition Release 11.2 .0.1.0 - 64 bit ProductionWith the Partitioning , OLAP , Data Mining and Real Application Testing options

SQL> set linesize 10000 pagesize 10000;SQL> select dt.tablespace_name ,dt.block_size ,dt.status ,dt.contents from dba_tablespaces dt;

TABLESPACE_NAME BLOCK_SIZE STATUS CONTENTS------------------------------ ---------- --------- ---------SYSTEM 8192 ONLINE PERMANENTSYSAUX 8192 ONLINE PERMANENTUNDOTBS1 8192 ONLINE UNDOTEMP 8192 ONLINE TEMPORARYUSERS 8192 ONLINE PERMANENTUNDOTBS2 8192 ONLINE UNDOEXAMPLE8192 ONLINE PERMANENTTESTTS 8192 ONLINE PERMANENTTEMP2 8192 ONLINE TEMPORARYTEMP3 8192 ONLINE TEMPORARYTEST_TRAN_TS 8192 READ ONLY PERMANENT

11 rows selected.

SQL> alter tablespace TEST_TRAN_TS read, write;alter tablespace TEST_TRAN_TS read, write *ERROR at line 1:ORA-02142 : missing or invalid ALTER TABLESPACE option

SQL> alter tablespace TEST_TRAN_TS read write;--修改表空间的状态

Tablespace altered.

SQL> insert into test_tran_tab values( 1, ‘张三‘);insert into test_tran―n_tab values( 1, ‘张三‘)*ERROR at line 1:ORA-00942 : table or view does not exist

SQL> insert into test_tran_tab values( 1, ‘zs‘);

1 row created.

SQL> select * from test_tran_tab;

ID NAME---------- --------------------1 zs

SQL>

使用数据泵的方式导入导出:

exp/imp的缺点是速度太慢,在大型生产库中尤其明显。从10g开始,oracle设计了数据泵,这是一个服务器端的工

具,它为Oracle数据提供高速并行及大数据的迁移。imp/exp可以在客户端调用,但是expdp/impdp只能在服

务端,因为在使用expdp/impdp以前需要在数据库中创建一个 Directory 。

在expdp进行导出时,先创建了MT表,并把对象的信息插入到MT表,之后进行导出动作;导出完成后,MT表也导

出到转储文件中;导出任务完成后、或者删除了导出任务后,MT表自动删除;如果导出任务异常终止,MT表仍然保留。

expdp也具有四种模式:表、用户、可传输表空间、全库。

数据泵的导出:1,部分的exp中的参数仍然可用,有的不能使用,如index。

2,directory:供转储文件和日志文件使用的目录对象。

3,job_name:指定的任务的名称。

4,content:指定要导出的数据, 其中有效关键字值为: (ALL), DATA_ONLY 和 METADATA_ONLY,当设置content为ALL 时,将导出对象定义及其所有数据;

DATA_ONLY时,只导出对象数据;为METADATA_ONLY时,只导出对象定义 。

5,reuse_dumpfiles:如果导出文件已经存在,是否覆盖。

6,compression:压缩导出文件。

7,estimate:指定估算被导出表所占用磁盘空间分方法.默认值是BLOCKS

8, estimate_only:是否只估算导出占用的磁盘空间,而不进行真正的导出,默认是N。

9,exclude:用于指定执行操作时要排除对象类型或相关对象,用法:EXCLUDE=object_type[:name_clause] [,….]

10,include:用于指定执行操作时要包含的对象类型或相关对象,用法:INCLUDE=object_type[:name_clause] [,….]

11,query:导出符合条件的行。

12,attch:连接到现有的作业,可以用在中断导出任务后重新启动导出任务。----------------------------------------------------------------[oracle@localhost oracle]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Wed Jan 21 20:50:29 2015

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create directory test_impdp_expdp as ‘/u01/app/oracle/test_impdp_expdp‘;

Directory created.--创建目录

SQL> grant write,read on directory test_impdp_expdp to hr;

Grant succeeded.--给用户赋予权限

SQL> grant write,read on directory test_impdp_expdp to test1;

Grant succeeded.--给用户赋予权限

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Productio

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@localhost oracle]$ cd test_impdp_expdp/

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun directory=TEST_IMPDP_EXPDP dumpfile

--默认是多出用户的所有的对象

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 22:14:04 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Starting “HR”.“SYS_EXPORT_SCHEMA_01”: hr/********@jiagulun directory=TEST_IMPDP_EXPDP dumpfi

Estimate in progress using BLOCKS method...

Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA

Total estimation using BLOCKS method: 768 KB

Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA

Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE

Processing object type SCHEMA_EXPORT/CLUSTER/CLUSTER

Processing object type SCHEMA_EXPORT/CLUSTER/INDEX

Processing object type SCHEMA_EXPORT/TABLE/TABLE

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

Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

Processing object type SCHEMA_EXPORT/TABLE/COMMENT

Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_SPEC

Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE

Processing object type SCHEMA_EXPORT/PACKAGE/COMPILE_PACKAGE/PACKAGE_SPEC/ALTER_PACKAGE_SPEC

Processing object type SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE

Processing object type SCHEMA_EXPORT/VIEW/VIEW

Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_BODY

Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT

Processing object type SCHEMA_EXPORT/TABLE/TRIGGER

Processing object type SCHEMA_EXPORT/EVENT/TRIGGER

Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

Processing object type SCHEMA_EXPORT/JOB

. . exported “HR”.“ADDRESS”5.476 KB 2 rows

. . exported “HR”.“COUNTRIES” 6.367 KB25 rows

. . exported “HR”.“DEPARTMENTS” 7.007 KB27 rows

. . exported “HR”.“DEPT” 5.492 KB 3 rows

. . exported “HR”.“DROPPED_OBJ” 6.367 KB21 rows

. . exported “HR”.“EMPLOYEES” 16.81 KB 107 rows

. . exported “HR”.“JOBS” 6.992 KB19 rows

. . exported “HR”.“JOB_HISTORY” 7.054 KB10 rows

. . exported “HR”.“LOCATIONS” 8.273 KB23 rows

. . exported “HR”.“REGIONS”5.476 KB 4 rows

. . exported “HR”.“STUDENT”5.937 KB 3 rows

. . exported “HR”.“TEST_JOB” 24.74 KB 1684 rows

Master table “HR”.“SYS_EXPORT_SCHEMA_01” successfully loaded/unloaded

******************************************************************************

Dump file set for HR.SYS_EXPORT_SCHEMA_01 is:

/u01/app/oracle/test_impdp_expdp/test_exp_01.dmp

Job “HR”.“SYS_EXPORT_SCHEMA_01” successfully completed at 22:16:07

[oracle@localhost test_impdp_expdp]$ ls

export.log test_exp_01.dmp

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun directory=TEST_IMPDP_EXPDP TABLES=Sexp_02.dmp EXCLUDE=INDEX:“=‘INDEX_ADDRESS_NAME‘”

LRM-00116: syntax error at ‘INDEX:‘ following ‘=‘

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun directory=TEST_IMPDP_EXPDP TABLES=Sexp_02.dmp EXCLUDE=INDEX:“IN‘INDEX_ADDRESS_NAME‘”

.--通过上面的导出你会发现需要对‘进行转义,而且是IN关键字Export: Release 11.2.0.1.0 - Production on Wed Jan 21 22:25:09 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Starting “HR”.“SYS_EXPORT_TABLE_01”: hr/********@jiagulun directory=TEST_IMPDP_EXPDP TABLES=_exp_02.dmp EXCLUDE=INDEX:IN‘INDEX_ADDRESS_NAME‘

Estimate in progress using BLOCKS method...

Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

Total estimation using BLOCKS method: 128 KB

Processing object type TABLE_EXPORT/TABLE/TABLE

Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX

Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT

Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

. . exported “HR”.“ADDRESS”5.476 KB 2 rows

. . exported “HR”.“STUDENT”5.937 KB 3 rows

Master table “HR”.“SYS_EXPORT_TABLE_01” successfully loaded/unloaded

******************************************************************************

Dump file set for HR.SYS_EXPORT_TABLE_01 is:

/u01/app/oracle/test_impdp_expdp/test_exp_02.dmp

Job “HR”.“SYS_EXPORT_TABLE_01” successfully completed at 22:25:20

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student,address encryption=dmpfiles=test_exp_encrytion_reuse_01.dmp

LRM-00101: unknown parameter name ‘dumpfiles‘

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student,address encryption=dmpfile=test_exp_encrytion_reuse_01.dmp

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 22:32:31 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

ORA-39002: invalid operation

ORA-39070: Unable to open the log file.

ORA-39145: directory object parameter must be specified and non-null

--对于上面的错误是因为没有打开或者不存在encryption wallet所以需要进行下面操作:

oracle Wallet的使用(即内部加密技术TDE(Transparent Data Encryption ))

1. TDE是Oracle10gR2中推出的一个新功能,使用时要保证Oracle版本是在10gR2或者以上

--查看oracle版本:

select * from v$version;

2、创建一个新目录,并指定为Wallet目录

D:oracleproduct10.2.0adminora10ora_wallet

3. 设置wallet目录,在参数文件sqlnet.ora中(window+f,在你安装盘区查找sqlnet.ora),按照下面的格式加入信息:

ENCRYPTION_WALLET_LOCATION=(SOURCE=(METHOD=FILE)

(METHOD_DATA=(DIRECTORY=D:oracleproduct10.2.0adminora10ora_wallet)))

4. 创建master key文件,指定wallet密码,使用SYS用户登入系统,建立加密文件

SQL> alter system set encryption key identified by “wallet”;

System altered

-- 密码“wallet”不加引号时,后面使用时也不需要用引号

此时在设置的目录下,多出一个Personal Information Exchange类型的文件,相当于我们生成的master key文件,

电脑资料

D:oracleproduct10.2.0adminora10ora_walletewallet.p12

5、启动、关闭Wallet

SQL> ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY “wallet”;

ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY “wallet”

ORA-28354: wallet 已经打开

SQL> ALTER SYSTEM SET ENCRYPTION WALLET CLOSE; --关闭

System altered

SQL> ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY “wallet”; --打开

System altered

到此,已经成功配置了Wallet,创建了master key。

--通过上面的创建并且开启encryption wallet后才可以进行如下[oracle@localhost wallet]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMPDP_EXPDP dumpfile=test_exp_encryption_1.dmp encryption=data_only

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:57:01 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Starting “HR”.“SYS_EXPORT_TABLE_01”: hr/********@jiagulun tables=student directory=TEST_IMPDP_EXPDP dumpfile=test_exp_encryption_1.dmp encryption=data_only

Estimate in progress using BLOCKS method...

Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

Total estimation using BLOCKS method: 64 KB

Processing object type TABLE_EXPORT/TABLE/TABLE

Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX

Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT

Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

. . exported “HR”.“STUDENT”5.945 KB 3 rows

Master table “HR”.“SYS_EXPORT_TABLE_01” successfully loaded/unloaded

******************************************************************************

Dump file set for HR.SYS_EXPORT_TABLE_01 is:

/u01/app/oracle/test_impdp_expdp/test_exp_encryption_1.dmp

Job “HR”.“SYS_EXPORT_TABLE_01” successfully completed at 23:57:08

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student compression=data_onl reuse_dumpfiles=y dumpfile=test_exp_01.dmp--reuse_dumpfiles表示可以覆盖原文件

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 22:41:57 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Starting “HR”.“SYS_EXPORT_TABLE_01”: hr/********@jiagulun tables=student compression=data_on reuse_dumpfiles=y dumpfile=test_exp_01.dmp

Estimate in progress using BLOCKS method...

Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

Total estimation using BLOCKS method: 64 KB

Processing object type TABLE_EXPORT/TABLE/TABLE

Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX

Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT

Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

. . exported “HR”.“STUDENT”4.914 KB 3 rows

Master table “HR”.“SYS_EXPORT_TABLE_01” successfully loaded/unloaded

******************************************************************************

Dump file set for HR.SYS_EXPORT_TABLE_01 is:

/u01/app/oracle/test_impdp_expdp/test_exp_01.dmp

Job “HR”.“SYS_EXPORT_TABLE_01” successfully completed at 22:42:02

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMPDP_EXPDP

EXCLUDE=CONSTRAINT:IN‘PK_PRIMARY‘“ dumpfile=test_exp_jobname.dmp job_name=test_exp_jobname

--需要转义和大写Export: Release 11.2.0.1.0 - Production on Wed Jan 21 22:56:23 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Starting ”HR“.”TEST_EXP_JOBNAME“: hr/********@jiagulun tables=student directory=TEST_IMPDP_EK_PRIMARY‘ dumpfile=test_exp_jobname.dmp job_name=test_exp_jobname

Estimate in progress using BLOCKS method...

Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

Total estimation using BLOCKS method: 64 KB

Processing object type TABLE_EXPORT/TABLE/TABLE

Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX

Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT

Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

. . exported ”HR“.”STUDENT“5.937 KB 3 rows

Master table ”HR“.”TEST_EXP_JOBNAME“ successfully loaded/unloaded

******************************************************************************

Dump file set for HR.TEST_EXP_JOBNAME is:

/u01/app/oracle/test_impdp_expdp/test_exp_jobname.dmp

Job ”HR“.”TEST_EXP_JOBNAME“ successfully completed at 22:56:28

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMPIN‘PK_PRIMARY‘” dumpfile=test_exp_jobname.dmp job_name=test_exp_jobname

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 22:57:02 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

ORA-39001: invalid argument value

ORA-39000: bad dump file specification

ORA-31641: unable to create dump file “/u01/app/oracle/test_impdp_expdp/test_exp_jobname.dmp”

ORA-27038: created file already exists

Additional information: 1

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMPIN‘PK_PRIMARY‘“ dumpfile=test_exp_jobname.dmp job_name=test_exp_jobname REUSE_DUMPFILES=Y

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:16:05 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Starting ”HR“.”TEST_EXP_JOBNAME“: hr/********@jiagulun tables=student directory=TEST_IMPDP_EK_PRIMARY‘ dumpfile=test_exp_jobname.dmp job_name=test_exp_jobname REUSE_DUMPFILES=Y

Estimate in progress using BLOCKS method...

Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

Total estimation using BLOCKS method: 64 KB

Processing object type TABLE_EXPORT/TABLE/TABLE

Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX

Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT

Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

. . exported ”HR“.”STUDENT“5.937 KB 3 rows

Master table ”HR“.”TEST_EXP_JOBNAME“ successfully loaded/unloaded

******************************************************************************

Dump file set for HR.TEST_EXP_JOBNAME is:

/u01/app/oracle/test_impdp_expdp/test_exp_jobname.dmp

Job ”HR“.”TEST_EXP_JOBNAME“ successfully completed at 23:16:19

[oracle@localhost test_impdp_expdp]$ exp hr/hr@jiagulun TABLES=STUDENT DIRECTORY=test_impdp_etion.dmp

LRM-00101: unknown parameter name ‘DIRECTORY‘

EXP-00019: failed to process parameters, type ‘EXP HELP=Y‘ for help

EXP-00000: Export terminated unsuccessfully

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMP id <2” dumpfile=test_exp_query.dmp

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:17:57 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

ORA-39001: invalid argument value

ORA-39035: Data filter SUBQUERY has already been specified.

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMP id <2“ dumpfile=test_exp_query.dmp reuse_dumpfile=y

LRM-00101: unknown parameter name ‘reuse_dumpfile‘

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMP id <2” dumpfile=test_exp_query.dmp reuse_dumpfiles=y

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:18:28 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

ORA-39001: invalid argument value

ORA-39035: Data filter SUBQUERY has already been specified.

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMP id <2“ dumpfile=test_exp_query_1.dmp

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:18:56 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

ORA-39001: invalid argument value

ORA-39035: Data filter SUBQUERY has already been specified.

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun directory=TEST_IMPDP_EXPDP query=s=test_exp_query_1.dmp

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:19:11 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

ORA-39001: invalid argument value

ORA-39035: Data filter SUBQUERY has already been specified.

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun directory=TEST_IMPDP_EXPDP query=s=test_exp_query_1.dmp

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:19:37 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

ORA-39001: invalid argument value

ORA-39035: Data filter SUBQUERY has already been specified.

[oracle@localhost test_impdp_expdp]$

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun directory=TEST_IMPDP_EXPDP query=se=test_exp_query_1.dmp

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:21:12 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

ORA-39001: invalid argument value

ORA-39035: Data filter SUBQUERY has already been specified.

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMP id <2” dumpfile=test_exp_query_1.dmp

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:21:41 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

ORA-39001: invalid argument value

ORA-39035: Data filter SUBQUERY has already been specified.

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMP dumpfile=test_exp_query_1.dmp

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:26:04 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

ORA-39001: invalid argument value

ORA-39035: Data filter SUBQUERY has already been specified.

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMPery_1.dmp query=STUDENT:“WHERE ID < 2”

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:28:16 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

ORA-39001: invalid argument value

ORA-39035: Data filter SUBQUERY has already been specified.

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMPery_1.dmp query=STUDENT:“WHERE ID < 2”

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:28:23 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

ORA-39001: invalid argument value

ORA-39035: Data filter SUBQUERY has already been specified.

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMPery_1.dmp query=STUDENT:“WHERE ID < 2”

--通过上面的错误可以知道符号需要被转义和query的使用方式

Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:28:30 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Starting “HR”.“SYS_EXPORT_TABLE_01”: hr/********@jiagulun tables=student directory=TEST_IMPDry_1.dmp query=STUDENT:“WHERE ID < 2”

Estimate in progress using BLOCKS method...

Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

Total estimation using BLOCKS method: 64 KB

Processing object type TABLE_EXPORT/TABLE/TABLE

Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX

Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT

Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

. . exported “HR”.“STUDENT”5.906 KB 1 rows

Master table “HR”.“SYS_EXPORT_TABLE_01” successfully loaded/unloaded

******************************************************************************

Dump file set for HR.SYS_EXPORT_TABLE_01 is:

/u01/app/oracle/test_impdp_expdp/test_exp_query_1.dmp

Job “HR”.“SYS_EXPORT_TABLE_01” successfully completed at 23:28:40

WRL_TYPE

--------------------

WRL_PARAMETER

--------------------------------------------------------------------------------

STATUS

------------------

file

/u01/app/oracle/admin/jiagulun/wallet

CLOSED

数据泵的导入:

1,content:指定要加载的数据, 其中有效关键字值为: (ALL), DATA_ONLY 和 METADATA_ONLY,当设置content为ALL 时,将加载对象定义及其所有数据;

DATA_ONLY时,只加载对象数据;为METADATA_ONLY时,只加载对象定义 。

2,estimate:估算所占用磁盘空间分方法.默认值是BLOCKS

3,remap_schema:用于将对象从一个用户下导入到另一个用户下。

4,remap_tablespace:用于将对象从一个表空间下导入到另一个表空间下。

5,remap_datafile:用于在不同文件系统的平台间,切换数据文件路径。

remap_achema:导入

[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun directory=TEST_IMPDP_EXPDP dumpfile=exp_01.dmp schemas= hr

Export: Release 11.2.0.1.0 - Production on Thu Jan 22 00:59:42 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Starting “HR”.“SYS_EXPORT_SCHEMA_01”: hr/********@jiagulun directory=TEST_IMPDP_EXPDP dumpfile=exp_01.dmp schemas=

Estimate in progress using BLOCKS method...

[oracle@localhost test_impdp_expdp]$ impdp test1/test1@jiagulun directory=TEST_IMPDP_EXPDP dumpfile=exp_01.dmpREMAP_SCHEMA=HR:TEST1

Import: Release 11.2.0.1.0 - Production on Thu Jan 22 01:10:11 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Master table “TEST1”.“SYS_IMPORT_FULL_01” successfully loaded/unloaded

Starting “TEST1”.“SYS_IMPORT_FULL_01”: test1/********@jiagulun directory=TEST_IMPDP_EXPDP dumpfile=exp_01.dmp REMAP_SCHEMA=HR:TEST1

Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA

remap_tablespace导入

通过remap_tablespace来变换表所属表空间:SQL> select segment_name,segment_type,tablespace_name from user_extents ;SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME-------------------------------------------------------------------------------- ------------------ ------------------------------REGIONS TABLE EXAMPLELOCATIONS TABLE EXAMPLEDEPARTMENTS TABLE EXAMPLEJOBS TABLE EXAMPLEEMPLOYEES TABLE EXAMPLEJOB_HISTORYTABLE EXAMPLEDEPT TABLE USERSDROPPED_OBJ TABLE USERSTEST_JOBTABLE USERSSTUDENT TABLE TEST_TRAN_TSADDRESS TABLE TEST_TRAN_TS

[oracle@localhost test_impdp_expdp]$ expdp ‘sys/oracle@jiagulun as sysdba‘ directory=test_impdp_expdp dumpfile=exp_04.dmp tablespaces=users--导出表空间

Export: Release 11.2.0.1.0 - Production on Thu Jan 22 01:20:04 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Starting “SYS”.“SYS_EXPORT_TABLESPACE_01”: “sys/********@jiagulun AS SYSDBA” directory=test_impdp_expdp dumpfile=exp_02.dmp tablespaces=users

Estimate in progress using BLOCKS method...

SQL> drop table student purge;

Table dropped.--之所以要先删除再导入表是因为在一个数据库中一个用户中的对象是唯一的,所以先删除再导入

SQL> drop table address purge;

Table dropped.

SQL> commit;

Commit complete.

[oracle@localhost test_impdp_expdp]$ impdp ‘sys/oracle@jiagulun as sysdba‘ directory=test_impdp_expdp dumpfile=exp_04.dmp REMAP_TABLESPACE=test_tran_ts:users--导入表空间到test_tran_ts

Import: Release 11.2.0.1.0 - Production on Thu Jan 22 01:28:45 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Master table “SYS”.“SYS_IMPORT_FULL_01” successfully loaded/unloaded

Starting “SYS”.“SYS_IMPORT_FULL_01”: “sys/********@jiagulun AS SYSDBA” directory=test_impdp_expdp dumpfile=exp_02.dmp REMAP_TABLESPACE=users:test_tran_ts

Processing object type TABLE_EXPORT/TABLE/TABLE

Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

. . imported “HR”.“ADDRESS”5.476 KB 2 rows

. . imported “HR”.“STUDENT”5.937 KB 3 rows

Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX

SQL> select segment_name,segment_type,tablespace_name from user_extents ;SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME-------------------------------------------------------------------------------- ------------------ ------------------------------REGIONS TABLE EXAMPLELOCATIONS TABLE EXAMPLEDEPARTMENTS TABLE EXAMPLEJOBS TABLE EXAMPLEEMPLOYEES TABLE EXAMPLEJOB_HISTORYTABLE EXAMPLESTUDENT TABLE USERSADDRESS TABLE USERS

为了把用户按表空间归类,需要把用户所有的当前数据转移到另一个表空间里,那么可以使用impdp的remap_tablespace参数。下面就这一内容进行实验。

SQL> select du.username,du.default_tablespace,du.temporary_tablespace from dba_users du where du.username=‘HR‘;USERNAME DEFAULT_TABLESPACE TEMPORARY_TABLESPACE------------------------------ ------------------------------ ------------------------------HR USERS TEMP2

SQL> select segment_name,segment_type,tablespace_name from user_extents where rownum < 10;SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME-------------------------------------------------------------------------------- ------------------ ------------------------------REGIONS TABLE EXAMPLELOCATIONS TABLE EXAMPLEDEPARTMENTS TABLE EXAMPLEJOBS TABLE EXAMPLEEMPLOYEES TABLE EXAMPLEJOB_HISTORYTABLE EXAMPLESTUDENT TABLE USERSADDRESS TABLE USERSDEPT TABLE USERS9 rows selected

SQL>

[oracle@localhost test_impdp_expdp]$ expdp system/oracle@jiagulun directory=TEST_IMPDP_EXPDP dumpfile=exp_03.dmp schemas=hr

Export: Release 11.2.0.1.0 - Production on Thu Jan 22 02:22:28 2015

--导出hr用户对象信息,使用system导出的更加的全

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

[oracle@localhost test_impdp_expdp]$ impdp system/oracle@jiagulun directory=TEST_IMPDP_EXPDP dumpfile=exp_03.dmp remap_tablespace=users:test_tran_ts--导入hr用户中是users表空间的数据到test_tran_ts表空间中

Import: Release 11.2.0.1.0 - Production on Thu Jan 22 05:33:10 2015

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

SQL> select segment_name,segment_type,tablespace_name from user_extents where rownum < 10;SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME-------------------------------------------------------------------------------- ------------------ ------------------------------REGIONS TABLE EXAMPLELOCATIONS TABLE EXAMPLEDEPARTMENTS TABLE EXAMPLEJOBS TABLE EXAMPLEEMPLOYEES TABLE EXAMPLEJOB_HISTORYTABLE EXAMPLESTUDENT TABLE USERSADDRESS TABLE USERSDEPT TABLE USERS9 rows selected--会发现表所在表空间并没有变化,是因为原来的已经存在不会覆盖

SQL> select du.username,du.default_tablespace,du.temporary_tablespace from dba_users du where du.username=‘HR‘;USERNAME DEFAULT_TABLESPACE TEMPORARY_TABLESPACE------------------------------ ------------------------------ ------------------------------HR USERS TEMP2注意:经过导入后,用户test_user的缺省表空间被改成了remap_tablespace的目的表空间, 但是这里没有变化也是因为已经存在了。把表和用户删除了,就会发现他们的表空间变额

SQL> drop table student;

Table dropped.

SQL> drop table address;

Table dropped.

SQL> commit;

Commit complete.

SQL> purge recyclebin

2 ;

[oracle@localhost test_impdp_expdp]$ impdp system/oracle@jiagulun directory=TEST_IMPDP_EXPDP dumpfile=exp_03.dmp remap_tablespace=users:test_tran_ts

Import: Release 11.2.0.1.0 - Production on Thu Jan 22 05:48:49 2015

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 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Master table “SYSTEM”.“SYS_IMPORT_FULL_01” successfully loaded/unloaded

Starting “SYSTEM”.“SYS_IMPORT_FULL_01”: system/********@jiagulun directory=TEST_IMPDP_EXPDP dumpfile=exp_03.dmp remap_tablespace=users:test_tran_ts

Processing object type SCHEMA_EXPORT/USER

ORA-31684: Object type USER:“HR” already exists--由于存在所以直接跳过

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/SEQUENCE/SEQUENCE

ORA-31684: Object type SEQUENCE:“HR”.“EMPLOYEES_SEQ” already exists

ORA-31684: Object type SEQUENCE:“HR”.“DEPARTMENTS_SEQ” already exists

ORA-31684: Object type SEQUENCE:“HR”.“LOCATIONS_SEQ” already exists

Processing object type SCHEMA_EXPORT/CLUSTER/CLUSTER

ORA-31684: Object type CLUSTER:“HR”.“CLUSTER1” already exists

Processing object type SCHEMA_EXPORT/CLUSTER/INDEX

ORA-39111: Dependent object type INDEX:“HR”.“CLUSTER_INDEX” skipped, base object type CLUSTER:“HR”.“CLUSTER1” already exists

Processing object type SCHEMA_EXPORT/TABLE/TABLE

ORA-39151: Table “HR”.“COUNTRIES” exists. All dependent metadata and data will be skipped due to table_exists_action of skip

ORA-39151: Table “HR”.“REGIONS” exists. All dependent metadata and data will be skipped due to table_exists_action of skip

ORA-39151: Table “HR”.“LOCATIONS” exists. All dependent metadata and data will be skipped due to table_exists_action of skip

ORA-39151: Table “HR”.“DEPARTMENTS” exists. All dependent metadata and data will be skipped due to table_exists_action of skip

ORA-39151: Table “HR”.“JOBS” exists. All dependent metadata and data will be skipped due to table_exists_action of skip

ORA-39151: Table “HR”.“EMPLOYEES” exists. All dependent metadata and data will be skipped due to table_exists_action of skip

ORA-39151: Table “HR”.“JOB_HISTORY” exists. All dependent metadata and data will be skipped due to table_exists_action of skip

ORA-39151: Table “HR”.“DEPT” exists. All dependent metadata and data will be skipped due to table_exists_action of skip

ORA-39151: Table “HR”.“DROPPED_OBJ” exists. All dependent metadata and data will be skipped due to table_exists_action of skip

ORA-39151: Table “HR”.“TEST_JOB” exists. All dependent metadata and data will be skipped due to table_exists_action of skip

Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA

. . imported “HR”.“ADDRESS”5.476 KB 2 rows

. . imported “HR”.“STUDENT”5.937 KB 3 rows

Processing object type SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT

.. . . . . . . . ..

SQL> select segment_name,segment_type,tablespace_name from user_extents ;SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME-------------------------------------------------------------------------------- ------------------ ------------------------------STUDENT TABLE TEST_TRAN_TSADDRESS TABLE TEST_TRAN_TSCLUSTER1 CLUSTER USERS--你会发现他们的表空间变化了。

注意:一个用户对象是唯一的,即使在不同的表空间中也是一样的

SQL> create table test1(id number);--默认是使用sys

Table created.

SQL> create table test1(id number) tablespace test_tran_ts;--使用test_tran_ts

create table test1(id number) tablespace test_tran_ts

*

ERROR at line 1:

ORA-00955: name is already used by an existing object

篇6:逻辑备份与恢复实战数据库教程

摘 要

结合金华电信IT系统目前正在实施的备份与恢复策略,重点介绍电信业务计算机管理系统(简称97系统)和营销支撑系统的ORALCE数据库备份和恢复方案。

Oracle数据库有三种标准的备份方法,它们分别是导出/导入(EXP/IMP)、热备份和冷备份。要实现简单导出数据(Export)和导入数据(Import),增量导出/导入的按设定日期自动备份,可考虑,将该部分功能开发成可执行程序,然后结合操作系统整合的任务计划,实现特定时间符合备份规划的备份应用程序的运行,实现数据库的本级备份,结合ftp简单开发,实现多服务器的数据更新同步,实现数据备份的异地自动备份。

关键字:数据库 远程异地 集中备份

I

ORACLE数据备份与数据恢复方案

目 录

一、前 言 ··························· 1

二、金华电信ORACLE数据库的备份与恢复方案 ······· 2

2.1 备份系统数据库备份策略································································································· 3 2.2 备份系统数据库恢复策略···················· 3 2.3 金华电信97系统及营销支撑系统的系统状况 ··········· 3 2.4 金华电信97系统、营销支撑系统及备份系统总体结构图 ······ 4 2.5 备份系统结构图说明······················ 4

三、金华电信97系统的数据库备份和恢复 ········ 6

3.1 备份方法··························· 6 3.2 备份策略··························· 6 3.3 恢复策略··························· 6 3.4 性能影响··························· 6

四、金华电信营销支撑系统的备份与恢复········· 7

4.1 备份方法··························· 7 4.2 备份策略··························· 7 4.4 性能影响··························· 7

五、RMAN CATALOG 数据库的备份 ············ 8

II

ORACLE数据备份与数据恢复方案

六、结 语 ······················ 9

III

ORACLE数据备份与数据恢复方案

一、前 言

目前,数据已成为信息系统的基础核心和重要资源,同时也是各单位的宝贵财富,数据的丢失将导致直接经济损失和用户数据的丢失,严重影响对社会提供正常的服务。另一方面,随着信息技术的迅猛发展和广泛应用,业务数据还将会随业务的开展而快速增加。但由于系统故障,数据库有时可能遭到破坏,这时如何尽快恢复数据就成为当务之急。如做了备份,恢复数据就显得很容易。由此可见,做好数据库的备份至关重要。因此,建立一个满足当前和将来的数据备份需求的备份系统是必不可少的。传统的数据备份方式主要采用主机内置或外置的磁带机对数据进行冷备份,这种方式在数据量不大、操作系统种类单

一、服务器数量有限的情况下,不失为一种既经济又简明的备份手段。但随着计算机规模的扩大,数据量几何级的增长以及分布式网络环境的兴起,将越来越多的业务分布在不同的机器、不同的操作平台上,这种单机的人工冷备份方式越来越不适应当今分布式网络环境。

因此迫切需要建立一个集中的、自动在线的企业级备份系统。备份的内容应当包括基于业务的业务数据,又包括IT系统中重要的日志文件、参数文件、配置文件、控制文件等。本文以ORACLE数据库为例,结合金华电信的几个相关业务系统目前正在实施的备份方案,介绍ORACLE数据库的备份与恢复。

ORACLE数据备份与数据恢复方案

二、金华电信ORACLE数据库的备份与恢复方案

由于金华电信IT系统以前只采用逻辑备份方式进行数据库备份,速度较慢并且数据存储管理都很分散,甚至出现备份数据不完整的现象。为了提高备份数据的效率,提供可靠的数据备份,完善备份系统,保证备份数据的完整性,降低数据备份对网络和服务器的影响,对每个IT系统的备份数据进行集中管理,我们对备份工作进行了改进,将逻辑备份与物理备份相结合,在远程建立了一个异地集中、自动在线的备份系统即网络存储管理系统。(这里用到的物理备份指热备份)其具备的主要功能如下:(1)集中式管理 :网络存储备份管理系统对整个网络的数据进行管理。利用集中式管理工具的帮助,系统管理员可对全网的备份策略进行统一管理,备份服务器可以监控所有机器的备份作业,也可以修改备份策略,并可即时浏览所有目录。所有数据可以备份到同备份服务器或应用服务器相连的任意一台磁带库内。(2)全自动的备份: 对于大多数机房管理人员来说,备份是一项繁重的任务。每天都要小心翼翼,不敢有半点闪失,生怕一失足成千古恨。网络备份能够实现定时自动备份,大大减轻管理员的压力。备份系统能根据用户的实际需求,定义需要备份的数据,然后以图形界面方式根据需要设置备份时间表,备份系统将自动启动备份作业,无需人工干预。这个自动备份作业是可自定的,包括一次备份作业、每周的某几日、每月的第几天等项目。设定好计划后,备份作业就会按计划自动进行。(3)数据库备份和恢复: 数据库系统已经相当复杂和庞大,不能用文件的备份方式来备份数据库。企业级的备份系统能够对数据库在不中断业务、不停顿数据库的情况下对数据进行联机的自动备份,包括可以进行数据库备份、日志备份、完全备份、增量备份等。(4)归档管理: 用户可以按项目、时间定期对所有数据进行有效的归档处理。提供统一的数据存储格式从而保证所有的应用数据由一个统一的数据格式来作永久的保存,保证数据的永久可利用性。(5)有效的媒体管理: 备份系统对每一个用于作备份的磁带自动加入一个电子标签,同时在软件中提供了识别标签的功能,如果磁带外面的标签脱落,只需执行这一功能,就会迅速知道该磁带的内容。(6)满足系统不断增加的需求:备份软件必须能支持多平台系统,当网络连接其它的应用服务器时,对于网络存储管理系统来说,只需在其上安装支持这种服务器的客户端软件即可将数据备份到磁带库或光盘库中。

ORACLE数据备份与数据恢复方案

2.1 备份系统数据库备份策略

数据库运行在归档模式下,利用Veritas软件模块调用数据库的备份接口进行在线的热备份,可以在备份时,对备份数据保存在不同的存储对象中,以满足客户容灾的要求,可以利用Veritas的多线程的数据迁移、利用多个磁带驱动器同时读写提高其数据备份的效率。

针对数据库的总数据量和增量数据量大小,我们可以利用数据库的多级的增量备份机制,结合Veritas 强大的备份数据追踪寻址能力和介质管理功能,制定灵活的备份策略,实现全自动的备份数据的全生命周期管理。

2.2 备份系统数据库恢复策略

通过本地的Veritas Server结合Veritas for Databases利用备份数据进行数据恢复。恢复时,Veritas 可以实现多线程的数据恢复,利用Veritas 独特的磁带分类集中存放技术,减少磁带的就位时间,提高数据恢复的效率。

先用最近一次的全备份恢复+恢复最近一次的增量备份+增量备份到断点的ARCHIVE LOG来恢复(要求数据库在ARCHIVE LOG模式下工作)。这种恢复方式比全部用ARCHIVE LOG恢复要快。

如果两份冗余的最近一次增量备份都不可用,可以追溯再上次的增量备份来恢复,然后用增量备份到断点的ARCHIVE LOG恢复。

如果最近一次的全备份恢复都不可用,则利用上个周期的全备份+上个周期的最后一次增量备份+本周期的最近一次增量备份+增量备份到断点的ARCHIVE LOG来恢复。

如果增量备份都不可用,那么用全备份+ARCHIVE LOG来恢复。

2.3 金华电信97系统及营销支撑系统的系统状况

金华电信经过这么多年的信息系统建设,目前已经运行着多个系统,除计费系统有较为完善的备份系统外,其他系统的备份系统都需要完善。其中97系统的机器型号IBM 7040-61R,操作系统 AIX5.2,数据库类型ORALCE8.1.7.4,数据量120G;营销支撑系统机器型号IBM xseries440,操作系统Red Flag Linux Server 4.0,数据库类型ORACLE9.2.0.1,数据量150G。以前,这两个系统的数据备份都是通过逻辑备份(exp)实现并且备份数据管理是分散的,然而一个完善的备份系统必须包含物理备份和逻辑备份两种方式。因此,我们正在实施一个远程

ORACLE数据备份与数据恢复方案

异地在线集中的高效的备份系统,将逻辑备份和物理备份(热备份)相结合,设置了专门的备份服务器。由于97、营销支撑操作系统采用AIX及Red Flag,我们在备份服务器上安装了第三方备份软件Veritias NBU。

2.4 金华电信97系统、营销支撑系统及备份系统总体结构图

对于具体的备份环境和结构,我们结合了Oracle备份技术和LAN环境的SAN备份结构.该系统的结构如下图所示(以97系统与营销支撑系统为例)

备份系统总体结构图

2.5 备份系统结构图说明

此在线存储系统采用了基于SAN(存储区域网络)的结构,SAN是一种高速

ORACLE数据备份与数据恢复方案

网络或子网络,提供在计算机与存储系统之间的数据传输。存储设备是指一张或多张用以存储计算机数据的磁盘设备。一个 SAN 网络由负责网络连接的通信结构如光交换机、负责组织连接的管理层、存储部件以及计算机系统构成,从而保证数据传输的安全性和力度。由于整个SAN系统的数据量比较大,所以备份系统采用SAN结构,将磁盘阵列直接连接到SAN的交换机上,和备份服务器、多台服务器均通过SAN相互连接,利用SAN的高性能来提高备份速度、降低数据备份对网络和服务器的影响。备份系统结构图说明如下:(1)Veritas 服务器(即备份服务器):备份系统是数据安全的关键系统,而备份服务器是备份系统的核心,因此从安全可靠的角度,采用专用的备份服务器,在这台服务器上安装VERTIAS Server端软件,集中管理控制磁带库、定制备份策略、管理备份作业、管理磁带等,同时安装oracle catalog库。(2)备份方案:对97系统购买IBM VERTIAS 备份软件,将数据备份至磁盘阵列上面,备份数据走光纤通道。对营销支撑系统,我们从SAN存储的FATA盘上划部分空间直接挂到系统中,然后直接采用RMAN做备份,以降低成本。之所以采用FATA盘的目的是为了避免和FC盘有IO冲突。(3)M300磁盘阵列:在我们的方案当中,我们采用磁盘阵列来代替一贯采用的磁带库。磁盘阵列具有性能高,可靠性高,维护方便等优点。本方案中采用专业存储厂商富士通的中高端存储ETERNUS3000 M300,作为一种面向开放系统的存储系统,ETERNUS3000在性能、容量及连通性等方面将世界标准提高到一个新层次。M300的容量为6T的FC盘,10T的FATA盘。在FC盘上保留所有系统的一份全备,其他的备份在白天定期转移到FATA盘。在FATA盘上保留1-2份全备,其他的定期转移到3583磁带库中。(3)光纤交换机:为了使整个系统具有良好的扩展性,我们在数据中心采用了被评为最优秀的网络存储产品博科的16口的光纤交换机,在新大楼备份中心采用博科的8口的光纤交换机。(4)磁带库:本方案中的磁带库采用的是原先计费系统所用的3583磁带库。我们定期将FATA盘上的备份自动转移到该磁带库上,做更久的保留。(5)逻辑备份服务器:为了充份利用旧有的设备来提高异地集中备份系统的稳定性,安全性,我们利用旧有设备IBM 7044-170小型机和IBM 3542阵列来搭建一个逻辑备份系统。所有的逻辑备份都放到该机器上面来,使得逻辑备份和物理备份在物理上开离。这样一来避免了IO冲突,二来提高了备份系统的可靠性。

ORACLE数据备份与数据恢复方案

三、金华电信97系统的数据库备份和恢复

3.1 备份方法

采用Veritas NBU物理备份加EXP逻辑备份。Exp逻辑备份在服务器上直接备份,定期转移到逻辑备份服务器。

3.2 备份策略

备份策略:(1)每周进行一次数据库全备份操作,并定期将FC盘上面的物理备份定期转移到FATA盘上,同时将FATA盘阵上面的物理备份定期转移到磁带库上,至少保存 3 个全备份;全备份时间选择在每周星期六凌晨12:00 开始。(2)数据库采用Archive Log 模式,每天晚上12:00 开始进行增量备份。(3)与数据库的逻辑备份相配合,我们每天进行一次数据的exp备份,即每天做一个完整的数据库EXPORT 备份;备份时间选择在每天凌晨1:00 开始。Exp备份还是备到本机,定期将其ftp到逻辑备份服务器上。

3.3 恢复策略

恢复策略:(1)数据文件损坏或磁盘阵列损坏:针对这种情况可以采用Veritas NBU从FC磁盘阵列中恢复。(2)误操作或对象级逻辑上的损坏:针对这种情况可以从exp备份中采用imp恢复。

3.4 性能影响

数据库采用归档模式对97数据库性能将产生一定的影响。因为在归档模式下,oracle需要将归档日志归档到归档目录(也就是copy)。在IO资源不成为瓶颈的情况下,对系统影响将可以不予考虑。97系统目前的瓶颈在于内存这一块。所以对97系统的性能影响可以不加以考虑。

ORACLE数据备份与数据恢复方案

四、金华电信营销支撑系统的备份与恢复

4.1 备份方法

采用物理备份加EXP逻辑备份。物理备份考虑到VERTIAS 的成本,及该系统的重要程度,我们从SAN存储上划一部分空间挂接至该系统OS上面,然后直接采用RMAN备份。这样备份的好处是成本低,缺点是不便于管理和维护,消耗主机的资源,在主机无法启动的情况下,备份文件无法访问,但备份数据还是完好如初的。

4.2 备份策略

备份策略:(1)每周进行一次数据库全备份操作,采用循环覆盖的方式,共保存 2个全备份;备份时间可以选择在周日晚上11:00进行(由于其采用的是FATA盘,与其他的物理备份不会造成IO冲突)。(2)数据库采用Archive Log 模式,每天晚上12:00 增量备份。(3)与数据库的逻辑备份相配合,我们每周进行一次数据的exp备份,即每天做一个完整的数据库EXPORT 备份;备份时间选择在每天凌晨1:00 开始。

4.3 恢复策略

恢复策略:(1)数据文件损坏或磁盘阵列损坏:针对这种情况可以采用RMAN从磁盘中恢复。(2)误操作或对象级逻辑上的损坏:针对这种情况可以从exp备份中采用imp恢复。

4.4 性能影响

数据库采用归档模式对营销支撑系统数据库性能产生的影响也是由于归档进程需要对归档日志进行归档。同时改成归档模式还需要注意的一个问题就是归档目录空间的问题,该系统空间足够。如果该系统的IO资源较为充裕的话,则不会对性能产生很大的影响。

ORACLE数据备份与数据恢复方案

五、RMAN Catalog 数据库的备份

RMAN Catalog库是整个备份系统当中最重要的信息之一。是在物理备份(Veritas)服务器上建立的一个ORACLE数据库,记录了所有备份的数据库数据文件。如果丢失了Catalog信息的话,恢复将非常麻烦,因此我们也需要对RMAN Catalog库做定期备份。RMAN Catalog库采用逻辑备份,每天直接备份到逻辑备份服务器上。

ORACLE数据备份与数据恢复方案

六、结 语

上一篇:英汉互译短文50篇短文下一篇:青春不停步永远跟党走