博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用rman增量备份来更新传输表空间
阅读量:6683 次
发布时间:2019-06-25

本文共 10671 字,大约阅读时间需要 35 分钟。

要使用rman增量备份来更新传输表空间需要了解传输表空间与rman的增量备份。这里主要介绍使用增量备份来更新传输表空间,就不介绍传输表空间与rman增量备份。下面是使用rman增量备份来更新传输表空间的操作。目标主机是weblogic29,原主机是weblogic28。

1.在两台数据库服务器上配置NFS
配置/etc/exports
nfs允许挂载的目录及权限需在文件/etc/exports中进行定义。例如,我们要将数据文件所在目录
/u01/app/oracle/oradata/jytest/与/backup目录共享出来,那么我们需要编辑/etc/exports文件,追加两行

/u01/app/oracle/oradata/jytest/ *(rw,sync)/backup/ *(rw,sync)
[root@weblogic29 oracle]# vi /etc/exports/u01/app/oracle/oradata/jytest/ *(rw,sync)/backup/ *(rw,sync)

启动nfs服务

[root@weblogic29 oracle]# service portmap startStarting portmap: [ OK ][root@weblogic29 oracle]# service nfs startStarting NFS services: [ OK ]Starting NFS quotas: [ OK ]Starting NFS daemon: [ OK ]Starting NFS mountd: [ OK ]

在客户端主机上挂载共享目录

[root@weblogic28 ~]# service portmap startStarting portmap: [ OK ][root@weblogic28 ~]# service nfs startStarting NFS services: [ OK ]Starting NFS quotas: [ OK ]Starting NFS daemon: [ OK ]Starting NFS mountd: [ OK ]

在客户端使用showmount -e IP 查看nfs主机共享情况:

[root@weblogic28 ~]# showmount -e 10.138.130.29Export list for 10.138.130.29:/backup */u01/app/oracle/oradata/jytest *

在客户端建立NFS文件夹并执行mount挂载命令:

[root@weblogic28 ~]# mkdir /jytest_data[root@weblogic28 ~]# mkdir /backup[root@weblogic28 ~]# chown -R oracle:oinstall /jytest_data[root@weblogic28 ~]# chown -R oracle:oinstall /backup[root@weblogic28 ~]# chmod -R 777 /jytest_data[root@weblogic28 ~]# chmod -R 777 /backup[root@weblogic28 ~]# mount -t nfs 10.138.130.29:/u01/app/oracle/oradata/jytest /jytest_data[root@weblogic28 ~]# mount -t nfs 10.138.130.29:/backup /backup[root@weblogic28 ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/sda3 240G 158G 71G 70% //dev/sda1 190M 12M 169M 7% /boottmpfs 16G 0 16G 0% /dev/shm10.138.130.29:/u01/app/oracle/oradata/jytest240G 22G 206G 10% /jytest_data10.138.130.29:/backup240G 22G 206G 10% /backup

2.在源数据库中创建一个表空间jytest与用户jytest

SQL> create tablespace jytest datafile '/u01/app/oracle/oradata/jytest/jytest01.dbf' size 5M autoextend off extent management local segment space management auto;Tablespace created.SQL> create user jytest identified by "jytest" default tablespace jytest temporary tablespace temp;User created.SQL> grant connect,dba,resource to jytest;Grant succeeded.SQL> conn jytest/jytestConnected.SQL> create table t1 as select * from dba_tables;Table created.SQL> select count(*) from t1;COUNT(*)----------1607SQL> insert into t1 select * from t1;1607 rows created.SQL> insert into t1 select * from t1;3214 rows created.SQL> insert into t1 select * from t1;6428 rows created.SQL> commit;Commit complete.

3.将原数据库的jytest表空间设置为只读模式

SQL> alter tablespace jytest read only;Tablespace altered.

4.对原数据库中的表空间jytest使用rman生成镜像副本并存储在NFS所挂载的/jytest_data目录中

[oracle@weblogic28 ~]$ rman target/Recovery Manager: Release 10.2.0.5.0 - Production on Wed Apr 13 12:36:05 2016Copyright (c) 1982, 2007, Oracle. All rights reserved.connected to target database: JYTEST (DBID=3911337604)RMAN> run2> {3> allocate channel c1 type disk format '/jytest_data/jytest01.dbf';4> backup incremental level 1 tag "INCR_JYTEST" for recover of copy with tag "INCR_JYTEST" tablespace jytest;5> }using target database control file instead of recovery catalogallocated channel: c1channel c1: sid=157 devtype=DISKStarting backup at 13-APR-16WARNING: TAG INCR_JYTEST option is ignored; backups will be tagged with INCR_JYTESTno parent backup or copy of datafile 8 foundchannel c1: starting datafile copyinput datafile fno=00008 name=/u01/app/oracle/oradata/jytest/jytest01.dbfoutput filename=/jytest_data/jytest01.dbf tag=INCR_JYTEST recid=2 stamp=909059896channel c1: datafile copy complete, elapsed time: 00:00:01Finished backup at 13-APR-16released channel: c1

虽然这里使用的是incremental level 1,因为这里不存在表空间数据文件jytest01.dbf的0级增量副本,因此会创建一个0级增量副本文件。

SQL> alter tablespace jytest read write;Tablespace altered.

5.将表空间jytest附加到目标数据库

SQL> create or replace directory test_dump as '/backup/';Directory created.SQL> grant read,write on directory test_dump to public;Grant succeeded.'SQL> create public database link dblink_jytest2 connect to jytest identified by "jytest"3 using '(DESCRIPTION =4 (ADDRESS = (PROTOCOL = TCP)(HOST = 10.138.130.28)(PORT = 1521))5 (CONNECT_DATA =6 (SERVICE_NAME = jytest)7 )8 )';Database link created.SQL> select count(*) from t1@dblink_jytest;COUNT(*)----------12856[oracle@weblogic29 jytest]$ impdp jytest/jytest directory=test_dump network_link=dblink_jytest transport_tablespaces=jytest transport_full_check=n transport_datafiles=\'/u01/app/oracle/oradata/jytest/jytest01.dbf\'Import: Release 10.2.0.5.0 - 64bit Production on Wednesday, 13 April, 2016 14:47:43Copyright (c) 2003, 2007, Oracle. All rights reserved.Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsStarting "JYTEST"."SYS_IMPORT_TRANSPORTABLE_01": jytest/******** directory=test_dump network_link=dblink_jytest transport_tablespaces=jytest transport_full_check=n transport_datafiles='/u01/app/oracle/oradata/jytest/jytest01.dbf'Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLKProcessing object type TRANSPORTABLE_EXPORT/TABLEProcessing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLKJob "JYTEST"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at 14:47:48SQL> show parameter compatibleNAME TYPE VALUE------------------------------------ ----------- ------------------------------compatible string 10.2.0.3.0SQL> select count(*) from jytest.t1;COUNT(*)----------12856

6.将表空间jytest从目标数据库中删除,但保留数据文件

SQL> drop tablespace jytest including contents;Tablespace dropped.

7.将原数据库中的表空间jytest联机,继续向表t1插入记录

SQL> alter tablespace jytest read write;Tablespace altered.SQL> insert into t1 select * from t1;insert into t1 select * from t1*ERROR at line 1:ORA-01653: unable to extend table JYTEST.T1 by 128 in tablespace JYTEST

由于表空间jytest没有空间了,如是向表这僮jytest增加一个数据文件jytest02.dbf来增加表空间

SQL> alter tablespace jytest add datafile '/u01/app/oracle/oradata/jytest/jytest02.dbf' size 5M;Tablespace altered.SQL> insert into t1 select * from t1;12856 rows created.SQL> commit;Commit complete.SQL> select count(*) from t1;COUNT(*)----------25712

8.如果自上次增量备份以后原数据库表空间jytest增加了新的数据文件,因此执行以下命令来为新增加的数据文件创建镜像副本。

SQL> alter tablespace jytest read only;Tablespace altered.SQL> select file#,name from v$datafile;FILE# NAME---------- -------------------------------------------------------------------------1 /u01/app/oracle/oradata/jytest/system01.dbf2 /u01/app/oracle/oradata/jytest/undotbs01.dbf3 /u01/app/oracle/oradata/jytest/sysaux01.dbf4 /u01/app/oracle/oradata/jytest/users01.dbf5 /u01/app/oracle/oradata/jytest/example01.dbf6 /u01/app/oracle/oradata/jytest/tspitr01.dbf7 /u01/app/oracle/oradata/jytest/test01.dbf8 /u01/app/oracle/oradata/jytest/jytest01.dbf9 /u01/app/oracle/oradata/jytest/jytest02.dbf9 rows selected.RMAN> run2> {3> allocate channel c1 type disk format '/jytest_data/jytest02.dbf';4> backup incremental level 1 tag "INCR_JYTEST" for recover of copy with tag "INCR_JYTEST" datafile 9;5> }allocated channel: c1channel c1: sid=141 devtype=DISKStarting backup at 13-APR-16WARNING: TAG INCR_JYTEST option is ignored; backups will be tagged with INCR_JYTESTno parent backup or copy of datafile 9 foundchannel c1: starting datafile copyinput datafile fno=00009 name=/u01/app/oracle/oradata/jytest/jytest02.dbfoutput filename=/jytest_data/jytest02.dbf tag=INCR_JYTEST recid=4 stamp=909069392channel c1: datafile copy complete, elapsed time: 00:00:01Finished backup at 13-APR-16released channel: c1

9.对原数据库执行RMAN增量备份并使用目标数据库文件目录中的数据文件与其合并,因些创建一组

新的数据文件

RMAN> run2> {3> allocate channel c1 type disk format '/jytest_data/jytest01_%t.dbf';4> allocate channel c2 type disk format '/jytest_data/jytest02_%t.dbf';5> backup incremental level 1 tag "INCR_JYTEST" for recover of copy with tag "INCR_JYTEST" tablespace jytest;6> recover copy of tablespace jytest with tag "INCR_JYTEST";7> }allocated channel: c1channel c1: sid=141 devtype=DISKallocated channel: c2channel c2: sid=139 devtype=DISKStarting backup at 13-APR-16WARNING: TAG INCR_JYTEST option is ignored; backups will be tagged with INCR_JYTESTchannel c1: starting incremental level 1 datafile backupsetchannel c1: specifying datafile(s) in backupsetinput datafile fno=00008 name=/u01/app/oracle/oradata/jytest/jytest01.dbfchannel c1: starting piece 1 at 13-APR-16channel c2: starting incremental level 1 datafile backupsetchannel c2: specifying datafile(s) in backupsetinput datafile fno=00009 name=/u01/app/oracle/oradata/jytest/jytest02.dbfskipping datafile 00009 because it has not changedchannel c2: backup cancelled because all files were skippedchannel c1: finished piece 1 at 13-APR-16piece handle=/jytest_data/jytest01_909069660.dbf tag=INCR_JYTEST comment=NONEchannel c1: backup set complete, elapsed time: 00:00:01Finished backup at 13-APR-16Starting recover at 13-APR-16channel c1: starting incremental datafile backupset restorechannel c1: specifying datafile copies to recoverrecovering datafile copy fno=00008 name=/jytest_data/jytest01.dbfchannel c1: reading from backup piece /jytest_data/jytest01_909069660.dbfchannel c1: restored backup piece 1piece handle=/jytest_data/jytest01_909069660.dbf tag=INCR_JYTESTchannel c1: restore complete, elapsed time: 00:00:02Finished recover at 13-APR-16released channel: c1released channel: c2

10.将表空间jytest重新附加到目标数据库中

[oracle@weblogic29 jytest]$ impdp jytest/jytest directory=test_dump network_link=dblink_jytest transport_tablespaces=jytest transport_full_check=n transport_datafiles=\'/u01/app/oracle/oradata/jytest/jytest01.dbf\',\'/u01/app/oracle/oradata/jytest/jytest02.dbf\'Import: Release 10.2.0.5.0 - 64bit Production on Wednesday, 13 April, 2016 15:50:37Copyright (c) 2003, 2007, Oracle. All rights reserved.Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsStarting "JYTEST"."SYS_IMPORT_TRANSPORTABLE_01": jytest/******** directory=test_dump network_link=dblink_jytest transport_tablespaces=jytest transport_full_check=n transport_datafiles='/u01/app/oracle/oradata/jytest/jytest01.dbf','/u01/app/oracle/oradata/jytest/jytest02.dbf'Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLKProcessing object type TRANSPORTABLE_EXPORT/TABLEProcessing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLKJob "JYTEST"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at 15:50:42SQL> select count(*) from jytest.t1;COUNT(*)----------25712SQL> alter tablespace jytest read write;Tablespace altered.

与原数据库中表t1记录数一样,说明增量更新传输表空间成功。

总结:使用增量备份来前更新数据文件要比复制整个数据文件所花的时间少。这里使用了NFS来执行数据文件的传输避免了使用ftp等方式传输文件,使用impdp network_link避免了导入和导出元数据与传输元数据这也能节省了时间。

转载地址:http://kcoao.baihongyu.com/

你可能感兴趣的文章
Microsoft Visual C++ Runtime library not enough space for thread data
查看>>
Centos 7 ntp时间服务器搭建
查看>>
要想月薪达到5万,要必备以下9项技能,阿里前大数据工程师说的
查看>>
电压电流采集模块,温湿度采集,称重模块,变送器,adc模数转换模块
查看>>
linux网卡配置
查看>>
RAID和LVM
查看>>
学hadoop需要什么基础
查看>>
2019北京物联网智慧城市大数据博览会开启中国之路
查看>>
华为云网络服务两场景
查看>>
将 Desktop Central 与帮助台和 OS Deployer 集成
查看>>
技巧分享:caj怎么转化为pdf
查看>>
WebPack牛刀小试
查看>>
技巧: iPhone玩游戏手机发烫?有妙招
查看>>
Invalid encoding name "UTF8". 报错 XML
查看>>
Python : 会打扮的装饰器
查看>>
oracle 查找删除重复数据
查看>>
MySQL重点关注性能及相关分析命令详解
查看>>
各种传马wmi c#原代码
查看>>
Derby-10.11学习笔记(三)Derby系统表及存储过程
查看>>
标准W3C盒子模型和IE盒子模型CSS布局经典盒子模型(转)
查看>>