[20171221]利用rman实现2台机器文件拷贝.txt

--//昨天使用rman duplicate建立dg,我看到执行如下代码:

RMAN> duplicate target database for standby from active database nofilenamecheck;
...
contents of Memory Script:
{
   backup as copy reuse
   targetfile  '/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/orapwbook' auxiliary format
 '/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/orapwbookdg'   ;
}

--//是否通过这样的方式可以实现2台服务器之间文件拷贝呢?

1.环境:
SYS@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

2.先测试oracle的口令文件是否可以传输:

$ rlwrap rman target sys/oracle@book auxiliary sys/oracle@bookdg
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Dec 21 10:35:47 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: BOOK (DBID=1337401710)
connected to auxiliary database: BOOK (DBID=1337401710)

RMAN> backup as copy reuse targetfile '/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/orapwbook' auxiliary format '/tmp/orapwbookdg'   ;
Starting backup at 2017-12-21 10:36:16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=106 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=119 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=132 device type=DISK
Finished backup at 2017-12-21 10:36:18

--//在备库检查发现
$ ls -l /tmp/orapwbookdg
-rw-r-----  1 oracle oinstall 1536 2017-12-21 10:36:17 /tmp/orapwbookdg

3.测试其它用户文件:

--//检查主库存在如下文件在/home/oracle,继续测试看看:
$ ls -l aaa.txt
-rw-r--r-- 1 oracle oinstall 54 2017-11-16 11:42:50 aaa.txt

RMAN> backup as copy reuse targetfile '/home/oracle/aaa.txt' auxiliary format '/tmp/aaa.txt.bookdg'   ;
Starting backup at 2017-12-21 10:40:14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=106 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=119 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=132 device type=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 12/21/2017 10:40:17
ORA-19505: failed to identify file "/home/oracle/aaa.txt"
ORA-27046: file size is not a multiple of logical block size
Additional information: 1

--//可以发现不行,文件大小必须是logical block size的整数倍.换一句话文件大小必须是512的倍数.
--//一些发行版本有fallocate可以给文件分配空间.
$ fallocate  -l 512 aaa.txt
--//我的测试机器没有,我使用dd,需要加入512-54 = 458字节

$ dd if=/dev/zero of=aaa.txt seek=54 count=458  bs=1 conv=notrunc
458+0 records in
458+0 records out
458 bytes (458 B) copied, 0.00208456 seconds, 220 kB/s

--//再次提醒加入输入输出不要写反.写入onv=notrunc不管怎样都不会错,这样避免被切断,我个人每次使用dd都心存敬畏..因为1次差错....
--//注意这样写效率不高bs=1.(意味每次写1个字节,写458次),因为前面的seek参数对应54*1,
--//如果你反过来写count=1  bs=458 ,相当于在54*458偏移开始写入.利用这个特性实际上这样执行:

$ ls -l aaa.txt
-rw-r--r-- 1 oracle oinstall 54 2017-12-21 10:55:17 aaa.txt

$ dd if=/dev/zero of=aaa.txt seek=511 count=1  bs=1 conv=notrunc
1+0 records in
1+0 records out
1 byte (1 B) copied, 5.2118e-05 seconds, 19.2 kB/s

$ ls -l aaa.txt
-rw-r--r-- 1 oracle oinstall 512 2017-12-21 10:56:52 aaa.txt

RMAN> backup as copy reuse targetfile '/home/oracle/aaa.txt' auxiliary format '/tmp/aaa.txt.bookdg'   ;
Starting backup at 2017-12-21 10:58:05
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
Finished backup at 2017-12-21 10:58:06

--//OK,现在拷贝过去了.

--//主库:
$ md5sum /home/oracle/aaa.txt
94a6edaabd20f62185e62037f2dbcb21  /home/oracle/aaa.txt

--//备库:
$ md5sum /tmp/aaa.txt.bookdg
94a6edaabd20f62185e62037f2dbcb21  /tmp/aaa.txt.bookdg

--//md5一样,说明没有问题.另外我的测试不使用reuse参数也会覆盖对面的文件.这点要特别注意!!

RMAN> backup as copy  targetfile '/home/oracle/aaa.txt' auxiliary format '/tmp/aaa.txt.bookdg'   ;

Starting backup at 2017-12-21 11:05:48
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
Finished backup at 2017-12-21 11:05:49

4.延伸测试:
--//是否这样可以实现备份:
RMAN> backup as backupset   datafile 6 auxiliary format '/data/testtest/datafile6_%U'  ;
Starting backup at 2017-12-21 11:21:00
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 12/21/2017 11:21:00
RMAN-06955: Network copies are only supported for image copies.

--//^_^,oracle不支持,报RMAN-06955: Network copies are only supported for image copies.
--//也就是做image copy应该没有问题.

RMAN> backup as copy  datafile 6 auxiliary  format '/data/backuptest/datafile6_%U'   ;
Starting backup at 2017-12-21 11:28:22
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/mnt/ramdisk/book/tea01.dbf
output file name=/data/backuptest/datafile6_data_D-BOOK_I-1337401710_TS-TEA_FNO-6_fpsmm16m tag=TAG20171221T112822
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2017-12-21 11:28:23

RMAN> backup as copy  datafile 6 auxiliary  format '/data/backuptest/%b'   ;
Starting backup at 2017-12-21 11:29:01
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/mnt/ramdisk/book/tea01.dbf
output file name=/data/backuptest/tea01.dbf tag=TAG20171221T112901
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2017-12-21 11:29:02
--//OK没有问题.

$ ls -l /data/backuptest
total 12328
-rw-r-----  1 oracle oinstall 6299648 2017-12-21 11:28:22 datafile6_data_D-BOOK_I-1337401710_TS-TEA_FNO-6_fpsmm16m
-rw-r-----  1 oracle oinstall 6299648 2017-12-21 11:29:01 tea01.dbf

$ dbv file=/data/backuptest/tea01.dbf
DBVERIFY: Release 11.2.0.4.0 - Production on Thu Dec 21 11:31:29 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
DBVERIFY - Verification starting : FILE = /data/backuptest/tea01.dbf
DBVERIFY - Verification complete
Total Pages Examined         : 768
Total Pages Processed (Data) : 594
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 128
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 46
Total Pages Marked Corrupt   : 0
Total Pages Influx           : 0
Total Pages Encrypted        : 0
Highest block SCN            : 392434057 (3.392434057)
--//说明没有问题.注意这样备份在控制文件没有记录.

--//主库:
RMAN> list copy of datafile 6;
specification does not match any datafile copy in the repository

--//有点可惜的是11g不支持copy section size,也就是分段拷贝.12c支持,这样可以加快copy的速度.
--//参考链接:http://blog.itpub.net/267265/viewspace-1310778/

总结:
1.这样方式拷贝文件大小存在限制,必须是512的倍数.
2.提供另外一种手工方式建立备库的方式.
3.另外注意这样拷贝方式在控制文件没有记录.
4.注意文件覆盖问题.似乎数据文件copy不会覆盖,除非指定resue参数,参考后面测试:
5.补充测试:

RMAN> backup as copy  database auxiliary  format '/data/backuptest/%b'   ;
Starting backup at 2017-12-21 11:39:12
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/mnt/ramdisk/book/sysaux01.dbf
channel ORA_DISK_2: starting datafile copy
input datafile file number=00003 name=/mnt/ramdisk/book/undotbs01.dbf
channel ORA_DISK_3: starting datafile copy
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
output file name=/data/backuptest/system01.dbf tag=TAG20171221T113912
channel ORA_DISK_3: datafile copy complete, elapsed time: 00:00:55
channel ORA_DISK_3: starting datafile copy
input datafile file number=00005 name=/mnt/ramdisk/book/example01.dbf
output file name=/data/backuptest/sysaux01.dbf tag=TAG20171221T113912
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:58
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/mnt/ramdisk/book/users01.dbf
output file name=/data/backuptest/undotbs01.dbf tag=TAG20171221T113912
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:58
channel ORA_DISK_2: starting datafile copy
input datafile file number=00006 name=/mnt/ramdisk/book/tea01.dbf
--//视乎文件存在不会覆盖..
RMAN-03009: failure of backup command on ORA_DISK_2 channel at 12/21/2017 11:40:12
ORA-17628: Oracle error 19505 returned by remote Oracle server
continuing other job steps, job failed will not be re-run
output file name=/data/backuptest/users01.dbf tag=TAG20171221T113912
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:17
output file name=/data/backuptest/example01.dbf tag=TAG20171221T113912
channel ORA_DISK_3: datafile copy complete, elapsed time: 00:00:20
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_2 channel at 12/21/2017 11:40:12
ORA-17628: Oracle error 19505 returned by remote Oracle server

--//删除前面的备份在重新执行:
RMAN> backup as copy  database auxiliary  format '/data/backuptest/%b'   ;

Starting backup at 2017-12-21 11:43:09
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/mnt/ramdisk/book/sysaux01.dbf
channel ORA_DISK_2: starting datafile copy
input datafile file number=00003 name=/mnt/ramdisk/book/undotbs01.dbf
channel ORA_DISK_3: starting datafile copy
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
output file name=/data/backuptest/sysaux01.dbf tag=TAG20171221T114309
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:05
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/mnt/ramdisk/book/example01.dbf
output file name=/data/backuptest/undotbs01.dbf tag=TAG20171221T114309
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:01:06
channel ORA_DISK_2: starting datafile copy
input datafile file number=00004 name=/mnt/ramdisk/book/users01.dbf
output file name=/data/backuptest/system01.dbf tag=TAG20171221T114309
channel ORA_DISK_3: datafile copy complete, elapsed time: 00:01:06
channel ORA_DISK_3: starting datafile copy
input datafile file number=00006 name=/mnt/ramdisk/book/tea01.dbf
output file name=/data/backuptest/tea01.dbf tag=TAG20171221T114309
channel ORA_DISK_3: datafile copy complete, elapsed time: 00:00:03
output file name=/data/backuptest/example01.dbf tag=TAG20171221T114309
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
output file name=/data/backuptest/users01.dbf tag=TAG20171221T114309
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:15
Finished backup at 2017-12-21 11:44:30
--//ok!!

RMAN> backup as copy  datafile 6 auxiliary  format '/data/backuptest/%b'   ;
Starting backup at 2017-12-21 11:45:32
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/mnt/ramdisk/book/tea01.dbf
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 12/21/2017 11:45:33
ORA-17628: Oracle error 19505 returned by remote Oracle server

--//视乎不能覆盖.加入resue看看.

RMAN> backup reuse as copy  datafile 6 auxiliary  format '/data/backuptest/%b'   ;

Starting backup at 2017-12-21 11:46:19
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/mnt/ramdisk/book/tea01.dbf
output file name=/data/backuptest/tea01.dbf tag=TAG20171221T114619
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2017-12-21 11:46:20

[20171221]利用rman实现2台机器文件拷贝.txt的更多相关文章

  1. Linux下 两台机器文件/文件夹 相互拷贝

    Linux下 两台机器文件/文件夹 相互拷贝 设有两台机器 :A:*.101及 B:*.102. 把A下的.temp/var/a.txt拷贝到B机器的/text/目录下: 进入B机器:scp root ...

  2. linux一台机器文件传到另一台机器上

    登录一台机器35.73: scp -P 端口 要传的文件 user@xxx.xxx.xxx.xxx:/目标文件夹/ 例子 :scp -r -P3561 /home/ismp/build/app/bec ...

  3. 第四课 Grid Control实验 GC Agent安装(第一台机器部署) 及卸载

    3.GC Agent安装(第一台机器部署) 安装Agent 拷贝agent,现在ocm2机器上查找agent.linux  查找文件的方法: find ./ -name agent*linux 把ag ...

  4. 两台linux机器文件传输之scp

    0.写在前面:一定要注意我们是否有源文件的读权限,是否有目标文件夹的写权限!没有的话要先把权限设置好! *.设置权限的方法:切换到有权限操作文件或文件夹的用户,利用chmod命令修改权限 1.安装: ...

  5. 利用Inotify和Rsync将webproject文件自己主动同步到多台应用server

    背景:须要搭建一套跟线上一模一样的环境,用来预公布,这是当中的web分发的一个小模块的实现过程. 1 工具以及环境简单介绍 1.1,Inotify工具 Inotify,它是一个内核用于通知用户空间程序 ...

  6. linux利用ssh远程执行多台机器执行同样的命令

    这篇文章主要介绍了ssh远程执行命令方法和Shell脚本实例,本文讲解了ssh执行远程操作方法和远程执行命令shell脚本示例,需要的朋友可以参考下 ssh执行远程操作命令格式代码如下: ssh -t ...

  7. Hexo博客系列(二)-在多台机器上利用Hexo发布博客

    [原文链接]:https://www.tecchen.xyz/blog-hexo-env-02.html 我的个人博客:https://www.tecchen.xyz,博文同步发布到博客园. 由于精力 ...

  8. 利用Synergy在局域网内让Ubuntu和Windows 7两台机器共用一套键鼠。

    一个主机可以连接多个显示器, 方便自己使用, 但是这只是一个系统分屏显示, 如果想用两台不同系统的电脑, 并且还不想老是在两套键鼠之间来回转换, 那么建议你可以用Synergy软件来实现多台电脑之间的 ...

  9. SCP,scp linux2台机器之间如何传输文件

    关键词:scp 转自: http://blog.csdn.net/gatieme https://blog.csdn.net/gatieme/article/details/51673229 scp传 ...

随机推荐

  1. Xcode 8.1 : Unable to read from device

    今天升级了Xcode 8.1,准备在iOS10.0.2的iPhone 6 Plus上调试,提示:Unable to read from device. 查看文件路径:"~/Library/D ...

  2. laravel 取sql语句

    \DB::connection()->enableQueryLog(); some sql action... $query = \DB::getQueryLog(); $lastQuery = ...

  3. hdu 1175 连连看 DFS

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1175 解题思路:从出发点开始DFS.出发点与终点中间只能通过0相连,或者直接相连,判断能否找出这样的路 ...

  4. 《Ruby语言入门教程v1.0》学习笔记-01

    <Ruby语言入门教程v1.0> 编著:张开川 邮箱:kaichuan_zhang@126.com 想要学习ruby是因为公司的自动化测试使用到了ruby语言,但是公司关于ruby只给了一 ...

  5. a/b + c/d

    a/b + c/d Time Limit : 1000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Sub ...

  6. HashMap和ConcurrentHashMap实现原理及源码分析

    HashMap实现原理及源码分析 哈希表(hash table)也叫散列表,是一种非常重要的数据结构,应用场景及其丰富,许多缓存技术(比如memcached)的核心其实就是在内存中维护一张大的哈希表, ...

  7. 用python给邮箱发邮件,问题,以及解决方法。

    模版 import smtplib #导入相关模块 from email.mime.text import MIMEText from email.utils import formataddr de ...

  8. 【appium】根据name定位元素

    目前没有尝试成功,等成功后补充 个人建议可以尝试先用view显示的文本作为name看是否能拿到该控件,按照我个人的经验一般都是会成功的,所以我很怀疑安卓上面控件的name是否就等于text.

  9. 浅谈__dict__

    类的 __dict__ 先看一个例子: > class A(object): pass > ... > A.__dict__ dict_proxy({'__dict__': < ...

  10. 【bzoj2272】[Usaco2011 Feb]Cowlphabet 奶牛文字 dp

    题目描述 Like all bovines, Farmer John's cows speak the peculiar 'Cow'language. Like so many languages, ...